| 1 |
use link_section::{section, in_section, TypedSection}; |
| 2 |
#[allow(non_camel_case_types)] |
| 3 |
struct FOO; |
| 4 |
#[allow(non_snake_case)] |
| 5 |
mod __FOO__link_sectionrs_L4_C8_H970cb50608f99e49__private_macro { |
| 6 |
#[doc(hidden)] |
| 7 |
pub use __FOO__link_sectionrs_L4_C8_H970cb50608f99e49__private_macro as __MACRO; |
| 8 |
} |
| 9 |
#[allow(unused_imports)] |
| 10 |
#[doc(hidden)] |
| 11 |
use __FOO__link_sectionrs_L4_C8_H970cb50608f99e49__private_macro::__MACRO as FOO; |
| 12 |
impl FOO { |
| 13 |
/// Get a `const` reference to the underlying section. In |
| 14 |
/// non-const contexts, `deref` is sufficient. |
| 15 |
pub const fn const_deref(&self) -> &'static TypedSection<fn()> { |
| 16 |
static SECTION: TypedSection<fn()> = { |
| 17 |
let section = { |
| 18 |
mod item {} |
| 19 |
::link_section::__support::PtrBounds::new( |
| 20 |
{ |
| 21 |
#[allow(missing_unsafe_on_extern)] |
| 22 |
extern "C" { |
| 23 |
#[link_name = "__start__data_link_section_FOObh0r0BSfLQP"] |
| 24 |
static __SYMBOL: u8; |
| 25 |
} |
| 26 |
unsafe { &raw const __SYMBOL as *const () } |
| 27 |
}, |
| 28 |
{ |
| 29 |
#[allow(missing_unsafe_on_extern)] |
| 30 |
extern "C" { |
| 31 |
#[link_name = "__stop__data_link_section_FOObh0r0BSfLQP"] |
| 32 |
static __SYMBOL: u8; |
| 33 |
} |
| 34 |
unsafe { &raw const __SYMBOL as *const () } |
| 35 |
}, |
| 36 |
) |
| 37 |
}; |
| 38 |
let name = "_data_link_section_FOObh0r0BSfLQP"; |
| 39 |
::link_section::__support::validate_section_name(name); |
| 40 |
unsafe { <TypedSection<fn()>>::new(name, section) } |
| 41 |
}; |
| 42 |
&SECTION |
| 43 |
} |
| 44 |
} |
| 45 |
impl ::core::fmt::Debug for FOO { |
| 46 |
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { |
| 47 |
::core::ops::Deref::deref(self).fmt(f) |
| 48 |
} |
| 49 |
} |
| 50 |
impl ::core::ops::Deref for FOO { |
| 51 |
type Target = TypedSection<fn()>; |
| 52 |
fn deref(&self) -> &Self::Target { |
| 53 |
self.const_deref() |
| 54 |
} |
| 55 |
} |
| 56 |
impl ::link_section::__support::SectionItemType for FOO { |
| 57 |
type Item = (fn()); |
| 58 |
} |
| 59 |
impl ::link_section::__support::SectionItemTyped<(fn())> for FOO { |
| 60 |
type Item = (fn()); |
| 61 |
} |
| 62 |
impl FOO { |
| 63 |
/// Get the section as a slice. |
| 64 |
pub fn as_slice(&self) -> &[(fn())] { |
| 65 |
self.const_deref().as_slice() |
| 66 |
} |
| 67 |
} |
| 68 |
impl ::core::iter::IntoIterator for FOO { |
| 69 |
type Item = &'static (fn()); |
| 70 |
type IntoIter = ::core::slice::Iter<'static, (fn())>; |
| 71 |
fn into_iter(self) -> Self::IntoIter { |
| 72 |
self.const_deref().as_slice().iter() |
| 73 |
} |
| 74 |
} |
| 75 |
fn foo() { |
| 76 |
const _: fn() = const { |
| 77 |
type __InSecStoredTy = <FOO as ::link_section::__support::SectionItemType>::Item; |
| 78 |
const __LINK_SECTION_CONST_ITEM_VALUE: __InSecStoredTy = foo; |
| 79 |
#[used] |
| 80 |
#[link_section = "_data_link_section_FOObh0r0BSfLQP"] |
| 81 |
static __LINK_SECTION_CONST_ITEM: __InSecStoredTy = __LINK_SECTION_CONST_ITEM_VALUE; |
| 82 |
__LINK_SECTION_CONST_ITEM_VALUE |
| 83 |
}; |
| 84 |
{ |
| 85 |
::std::io::_print(format_args!("foo\n")); |
| 86 |
}; |
| 87 |
} |
| 88 |
fn main() {} |