1use std::borrow::Cow;
2
3use rustc_abi::Align;
4use rustc_attr_ir::{
5 InlineAttr, InstructionSetAttr, InstrumentFnAttr, Linkage, OptimizeAttr, RtsanSetting,
6};
7use rustc_hir::def_id::DefId;
8use rustc_macros::{StableHash, TyDecodable, TyEncodable};
9use rustc_span::Symbol;
10use rustc_target::spec::SanitizerSet;
11
12use crate::mono::Visibility;
13use crate::ty::{InstanceKind, ShimKind, TyCtxt};
14
15impl<'tcx> TyCtxt<'tcx> {
16 pub fn codegen_instance_attrs(
17 self,
18 instance_kind: InstanceKind<'_>,
19 ) -> Cow<'tcx, CodegenFnAttrs> {
20 let mut attrs = Cow::Borrowed(self.codegen_fn_attrs(instance_kind.def_id()));
23
24 if !#[allow(non_exhaustive_omitted_patterns)] match instance_kind {
InstanceKind::Item(_) => true,
_ => false,
}matches!(instance_kind, InstanceKind::Item(_)) {
27 if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
28 attrs.to_mut().flags.remove(CodegenFnAttrFlags::NAKED);
29 }
30 }
31
32 if let InstanceKind::Shim(ShimKind::Reify(_, _)) = instance_kind
39 && attrs.flags.contains(CodegenFnAttrFlags::TRACK_CALLER)
40 {
41 if attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {
42 attrs.to_mut().flags.remove(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
43 }
44
45 if attrs.flags.contains(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM) {
46 attrs.to_mut().flags.remove(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM);
47 }
48
49 if attrs.symbol_name.is_some() {
50 attrs.to_mut().symbol_name = None;
51 }
52 }
53
54 if let InstanceKind::Shim(ShimKind::ClosureOnce {
56 call_once: _,
57 closure,
58 track_caller: _,
59 }) = instance_kind
60 {
61 let closure_attrs = self.codegen_fn_attrs(closure);
62 attrs.to_mut().optimize = closure_attrs.optimize;
63 }
64
65 attrs
66 }
67}
68
69#[derive(#[automatically_derived]impl ::core::clone::Clone for CodegenFnAttrs {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
CodegenFnAttrs {
flags: ::core::clone::Clone::clone(&self.flags),
inline: ::core::clone::Clone::clone(&self.inline),
optimize: ::core::clone::Clone::clone(&self.optimize),
symbol_name: ::core::clone::Clone::clone(&self.symbol_name),
foreign_item_symbol_aliases: ::core::clone::Clone::clone(&self.foreign_item_symbol_aliases),
link_ordinal: ::core::clone::Clone::clone(&self.link_ordinal),
target_features: ::core::clone::Clone::clone(&self.target_features),
safe_target_features: ::core::clone::Clone::clone(&self.safe_target_features),
linkage: ::core::clone::Clone::clone(&self.linkage),
import_linkage: ::core::clone::Clone::clone(&self.import_linkage),
link_section: ::core::clone::Clone::clone(&self.link_section),
sanitizers: ::core::clone::Clone::clone(&self.sanitizers),
instruction_set: ::core::clone::Clone::clone(&self.instruction_set),
alignment: ::core::clone::Clone::clone(&self.alignment),
patchable_function_entry: ::core::clone::Clone::clone(&self.patchable_function_entry),
objc_class: ::core::clone::Clone::clone(&self.objc_class),
objc_selector: ::core::clone::Clone::clone(&self.objc_selector),
instrument_fn: ::core::clone::Clone::clone(&self.instrument_fn),
}
}
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for CodegenFnAttrs {
fn encode(&self, __encoder: &mut __E) {
let CodegenFnAttrs {
flags: ref __binding_0,
inline: ref __binding_1,
optimize: ref __binding_2,
symbol_name: ref __binding_3,
foreign_item_symbol_aliases: ref __binding_4,
link_ordinal: ref __binding_5,
target_features: ref __binding_6,
safe_target_features: ref __binding_7,
linkage: ref __binding_8,
import_linkage: ref __binding_9,
link_section: ref __binding_10,
sanitizers: ref __binding_11,
instruction_set: ref __binding_12,
alignment: ref __binding_13,
patchable_function_entry: ref __binding_14,
objc_class: ref __binding_15,
objc_selector: ref __binding_16,
instrument_fn: ref __binding_17 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_5,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_6,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_7,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_8,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_9,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_10,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_11,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_12,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_13,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_14,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_15,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_16,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_17,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for CodegenFnAttrs {
fn decode(__decoder: &mut __D) -> Self {
CodegenFnAttrs {
flags: ::rustc_serialize::Decodable::decode(__decoder),
inline: ::rustc_serialize::Decodable::decode(__decoder),
optimize: ::rustc_serialize::Decodable::decode(__decoder),
symbol_name: ::rustc_serialize::Decodable::decode(__decoder),
foreign_item_symbol_aliases: ::rustc_serialize::Decodable::decode(__decoder),
link_ordinal: ::rustc_serialize::Decodable::decode(__decoder),
target_features: ::rustc_serialize::Decodable::decode(__decoder),
safe_target_features: ::rustc_serialize::Decodable::decode(__decoder),
linkage: ::rustc_serialize::Decodable::decode(__decoder),
import_linkage: ::rustc_serialize::Decodable::decode(__decoder),
link_section: ::rustc_serialize::Decodable::decode(__decoder),
sanitizers: ::rustc_serialize::Decodable::decode(__decoder),
instruction_set: ::rustc_serialize::Decodable::decode(__decoder),
alignment: ::rustc_serialize::Decodable::decode(__decoder),
patchable_function_entry: ::rustc_serialize::Decodable::decode(__decoder),
objc_class: ::rustc_serialize::Decodable::decode(__decoder),
objc_selector: ::rustc_serialize::Decodable::decode(__decoder),
instrument_fn: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
CodegenFnAttrs {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
CodegenFnAttrs {
flags: ref __binding_0,
inline: ref __binding_1,
optimize: ref __binding_2,
symbol_name: ref __binding_3,
foreign_item_symbol_aliases: ref __binding_4,
link_ordinal: ref __binding_5,
target_features: ref __binding_6,
safe_target_features: ref __binding_7,
linkage: ref __binding_8,
import_linkage: ref __binding_9,
link_section: ref __binding_10,
sanitizers: ref __binding_11,
instruction_set: ref __binding_12,
alignment: ref __binding_13,
patchable_function_entry: ref __binding_14,
objc_class: ref __binding_15,
objc_selector: ref __binding_16,
instrument_fn: ref __binding_17 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
{ __binding_3.stable_hash(__hcx, __hasher); }
{ __binding_4.stable_hash(__hcx, __hasher); }
{ __binding_5.stable_hash(__hcx, __hasher); }
{ __binding_6.stable_hash(__hcx, __hasher); }
{ __binding_7.stable_hash(__hcx, __hasher); }
{ __binding_8.stable_hash(__hcx, __hasher); }
{ __binding_9.stable_hash(__hcx, __hasher); }
{ __binding_10.stable_hash(__hcx, __hasher); }
{ __binding_11.stable_hash(__hcx, __hasher); }
{ __binding_12.stable_hash(__hcx, __hasher); }
{ __binding_13.stable_hash(__hcx, __hasher); }
{ __binding_14.stable_hash(__hcx, __hasher); }
{ __binding_15.stable_hash(__hcx, __hasher); }
{ __binding_16.stable_hash(__hcx, __hasher); }
{ __binding_17.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, #[automatically_derived]impl ::core::fmt::Debug for CodegenFnAttrs {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_fields_finish(f,
"CodegenFnAttrs flags inline optimize symbol_name foreign_item_symbol_aliases link_ordinal target_features safe_target_features linkage import_linkage link_section sanitizers instruction_set alignment patchable_function_entry objc_class objc_selector instrument_fn",
&[&self.flags, &self.inline, &self.optimize, &self.symbol_name,
&self.foreign_item_symbol_aliases, &self.link_ordinal,
&self.target_features, &self.safe_target_features,
&self.linkage, &self.import_linkage, &self.link_section,
&self.sanitizers, &self.instruction_set, &self.alignment,
&self.patchable_function_entry, &self.objc_class,
&self.objc_selector, &&self.instrument_fn])
}
}Debug)]
70pub struct CodegenFnAttrs {
71 pub flags: CodegenFnAttrFlags,
72 pub inline: InlineAttr,
74 pub optimize: OptimizeAttr,
76 pub symbol_name: Option<Symbol>,
80 pub foreign_item_symbol_aliases: Vec<(DefId, Linkage, Visibility)>,
86 pub link_ordinal: Option<u16>,
91 pub target_features: Vec<TargetFeature>,
95 pub safe_target_features: bool,
97 pub linkage: Option<Linkage>,
99 pub import_linkage: Option<Linkage>,
101 pub link_section: Option<Symbol>,
104 pub sanitizers: SanitizerFnAttrs,
107 pub instruction_set: Option<InstructionSetAttr>,
111 pub alignment: Option<Align>,
114 pub patchable_function_entry: Option<PatchableFunctionEntry>,
117 pub objc_class: Option<Symbol>,
119 pub objc_selector: Option<Symbol>,
121 pub instrument_fn: Option<InstrumentFnAttr>,
123}
124
125#[derive(#[automatically_derived]impl ::core::marker::Copy for TargetFeatureKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for TargetFeatureKind {
}
#[automatically_derived]impl ::core::clone::Clone for TargetFeatureKind {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for TargetFeatureKind {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
TargetFeatureKind::Implied => "Implied",
TargetFeatureKind::Enabled => "Enabled",
TargetFeatureKind::Forced => "Forced",
})
}
}Debug, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for TargetFeatureKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
TargetFeatureKind::Implied => { 0usize }
TargetFeatureKind::Enabled => { 1usize }
TargetFeatureKind::Forced => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for TargetFeatureKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { TargetFeatureKind::Implied }
1usize => { TargetFeatureKind::Enabled }
2usize => { TargetFeatureKind::Forced }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `TargetFeatureKind`, expected 0..3, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
TargetFeatureKind {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TargetFeatureKind::Implied =>
0u8.stable_hash(__hcx, __hasher),
TargetFeatureKind::Enabled =>
1u8.stable_hash(__hcx, __hasher),
TargetFeatureKind::Forced =>
2u8.stable_hash(__hcx, __hasher),
}
match *self {
TargetFeatureKind::Implied => {}
TargetFeatureKind::Enabled => {}
TargetFeatureKind::Forced => {}
}
}
}
};StableHash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
TargetFeatureKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for TargetFeatureKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for TargetFeatureKind { }Eq)]
126pub enum TargetFeatureKind {
127 Implied,
130 Enabled,
132 Forced,
134}
135
136#[derive(#[automatically_derived]impl ::core::marker::Copy for TargetFeature { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for TargetFeature {
}
#[automatically_derived]impl ::core::clone::Clone for TargetFeature {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<TargetFeatureKind>;
*self
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for TargetFeature {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"TargetFeature name kind", &self.name, &&self.kind)
}
}Debug, #[automatically_derived]impl ::core::cmp::Eq for TargetFeature {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Symbol>;
let _: ::core::cmp::AssertParamIsEq<TargetFeatureKind>;
}
}Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
TargetFeature {
}
#[automatically_derived]impl ::core::cmp::PartialEq for TargetFeature {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.name == other.name && self.kind == other.kind
}
}PartialEq, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for TargetFeature {
fn encode(&self, __encoder: &mut __E) {
let TargetFeature {
name: ref __binding_0, kind: ref __binding_1 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for TargetFeature {
fn decode(__decoder: &mut __D) -> Self {
TargetFeature {
name: ::rustc_serialize::Decodable::decode(__decoder),
kind: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
TargetFeature {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
TargetFeature { name: ref __binding_0, kind: ref __binding_1
} => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
137pub struct TargetFeature {
138 pub name: Symbol,
140 pub kind: TargetFeatureKind,
142}
143
144#[derive(#[automatically_derived]impl ::core::marker::Copy for PatchableFunctionEntry {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for PatchableFunctionEntry {
}
#[automatically_derived]impl ::core::clone::Clone for PatchableFunctionEntry {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<Option<u8>>;
let _: ::core::clone::AssertParamIsClone<Option<u8>>;
let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
*self
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for PatchableFunctionEntry {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"PatchableFunctionEntry prefix entry section", &self.prefix,
&self.entry, &&self.section)
}
}Debug, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for PatchableFunctionEntry {
fn encode(&self, __encoder: &mut __E) {
let PatchableFunctionEntry {
prefix: ref __binding_0,
entry: ref __binding_1,
section: ref __binding_2 } = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for PatchableFunctionEntry {
fn decode(__decoder: &mut __D) -> Self {
PatchableFunctionEntry {
prefix: ::rustc_serialize::Decodable::decode(__decoder),
entry: ::rustc_serialize::Decodable::decode(__decoder),
section: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
PatchableFunctionEntry {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
PatchableFunctionEntry {
prefix: ref __binding_0,
entry: ref __binding_1,
section: ref __binding_2 } => {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
{ __binding_2.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
145pub struct PatchableFunctionEntry {
146 prefix: Option<u8>,
148 entry: Option<u8>,
150 section: Option<Symbol>,
152}
153
154impl PatchableFunctionEntry {
155 pub fn from_prefix_entry_and_section(
156 prefix: Option<u8>,
157 entry: Option<u8>,
158 section: Option<Symbol>,
159 ) -> Self {
160 Self { prefix, entry, section }
161 }
162 pub fn from_prefix_and_entry(prefix: u8, entry: u8) -> Self {
163 Self { prefix: Some(prefix), entry: Some(entry), section: None }
164 }
165 pub fn prefix(&self) -> Option<u8> {
166 self.prefix
167 }
168 pub fn entry(&self) -> Option<u8> {
169 self.entry
170 }
171 pub fn section(&self) -> Option<Symbol> {
172 self.section
173 }
174}
175
176#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for CodegenFnAttrFlags {
}
#[automatically_derived]impl ::core::clone::Clone for CodegenFnAttrFlags {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for CodegenFnAttrFlags { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
CodegenFnAttrFlags {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CodegenFnAttrFlags {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for CodegenFnAttrFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}Eq, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for CodegenFnAttrFlags {
fn encode(&self, __encoder: &mut __E) {
let CodegenFnAttrFlags(ref __binding_0) = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for CodegenFnAttrFlags {
fn decode(__decoder: &mut __D) -> Self {
CodegenFnAttrFlags(::rustc_serialize::Decodable::decode(__decoder))
}
}
};TyDecodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
CodegenFnAttrFlags {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
CodegenFnAttrFlags(ref __binding_0) => {
{ __binding_0.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash)]
177pub struct CodegenFnAttrFlags(u32);
178impl CodegenFnAttrFlags {
#[doc =
r" `#[cold]`: a hint to LLVM that this function, when called, is never on"]
#[doc = r" the hot path."]
#[allow(deprecated, non_upper_case_globals,)]
pub const COLD: Self = Self::from_bits_retain(1 << 0);
#[doc =
r" `#[rustc_nounwind]`: An indicator that function will never unwind."]
#[allow(deprecated, non_upper_case_globals,)]
pub const NEVER_UNWIND: Self = Self::from_bits_retain(1 << 1);
#[doc =
r" `#[naked]`: an indicator to LLVM that no function prologue/epilogue"]
#[doc = r" should be generated."]
#[allow(deprecated, non_upper_case_globals,)]
pub const NAKED: Self = Self::from_bits_retain(1 << 2);
#[doc =
r" `#[rustc_std_internal_symbol]`: an indicator that this symbol is a"]
#[doc =
r#" "weird symbol" for the standard library in that it has slightly"#]
#[doc = r" different linkage, visibility, and reachability rules."]
#[allow(deprecated, non_upper_case_globals,)]
pub const RUSTC_STD_INTERNAL_SYMBOL: Self =
Self::from_bits_retain(1 << 4);
#[doc =
r" `#[thread_local]`: indicates a static is actually a thread local"]
#[doc = r" piece of memory"]
#[allow(deprecated, non_upper_case_globals,)]
pub const THREAD_LOCAL: Self = Self::from_bits_retain(1 << 5);
#[doc =
r" `#[used(compiler)]`: indicates that LLVM can't eliminate this function (but the"]
#[doc = r" linker can!)."]
#[allow(deprecated, non_upper_case_globals,)]
pub const USED_COMPILER: Self = Self::from_bits_retain(1 << 6);
#[doc = r" `#[used(linker)]`:"]
#[doc =
r" indicates that neither LLVM nor the linker will eliminate this function."]
#[allow(deprecated, non_upper_case_globals,)]
pub const USED_LINKER: Self = Self::from_bits_retain(1 << 7);
#[doc = r" `#[track_caller]`: allow access to the caller location"]
#[allow(deprecated, non_upper_case_globals,)]
pub const TRACK_CALLER: Self = Self::from_bits_retain(1 << 8);
#[doc =
r" #[ffi_pure]: applies clang's `pure` attribute to a foreign function"]
#[doc = r" declaration."]
#[allow(deprecated, non_upper_case_globals,)]
pub const FFI_PURE: Self = Self::from_bits_retain(1 << 9);
#[doc =
r" #[ffi_const]: applies clang's `const` attribute to a foreign function"]
#[doc = r" declaration."]
#[allow(deprecated, non_upper_case_globals,)]
pub const FFI_CONST: Self = Self::from_bits_retain(1 << 10);
#[doc =
r" `#[rustc_allocator]`: a hint to LLVM that the pointer returned from this"]
#[doc =
r" function is never null and the function has no side effects other than allocating."]
#[allow(deprecated, non_upper_case_globals,)]
pub const ALLOCATOR: Self = Self::from_bits_retain(1 << 11);
#[doc =
r" `#[rustc_deallocator]`: a hint to LLVM that the function only deallocates memory."]
#[allow(deprecated, non_upper_case_globals,)]
pub const DEALLOCATOR: Self = Self::from_bits_retain(1 << 12);
#[doc =
r" `#[rustc_reallocator]`: a hint to LLVM that the function only reallocates memory."]
#[allow(deprecated, non_upper_case_globals,)]
pub const REALLOCATOR: Self = Self::from_bits_retain(1 << 13);
#[doc =
r" `#[rustc_allocator_zeroed]`: a hint to LLVM that the function only allocates zeroed memory."]
#[allow(deprecated, non_upper_case_globals,)]
pub const ALLOCATOR_ZEROED: Self = Self::from_bits_retain(1 << 14);
#[doc =
r" `#[no_builtins]`: indicates that disable implicit builtin knowledge of functions for the function."]
#[allow(deprecated, non_upper_case_globals,)]
pub const NO_BUILTINS: Self = Self::from_bits_retain(1 << 15);
#[doc =
r" Marks foreign items, to make `contains_extern_indicator` cheaper."]
#[allow(deprecated, non_upper_case_globals,)]
pub const FOREIGN_ITEM: Self = Self::from_bits_retain(1 << 16);
#[doc =
r" `#[rustc_offload_kernel]`: indicates that this is an offload kernel, an extra ptr arg will be added."]
#[allow(deprecated, non_upper_case_globals,)]
pub const OFFLOAD_KERNEL: Self = Self::from_bits_retain(1 << 17);
#[doc =
r" Externally implementable item symbols act a little like `RUSTC_STD_INTERNAL_SYMBOL`."]
#[doc =
r" When a crate declares an EII and dependencies expect the symbol to exist,"]
#[doc =
r" they will refer to this symbol name before a definition is given."]
#[doc =
r" As such, we must make sure these symbols really do exist in the final binary/library."]
#[doc =
r" This flag is put on both the implementations of EIIs and the foreign item they implement."]
#[allow(deprecated, non_upper_case_globals,)]
pub const EXTERNALLY_IMPLEMENTABLE_ITEM: Self =
Self::from_bits_retain(1 << 18);
}
impl ::bitflags::Flags for CodegenFnAttrFlags {
const FLAGS: &'static [::bitflags::Flag<CodegenFnAttrFlags>] =
&[{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("COLD", CodegenFnAttrFlags::COLD)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("NEVER_UNWIND",
CodegenFnAttrFlags::NEVER_UNWIND)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("NAKED", CodegenFnAttrFlags::NAKED)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("RUSTC_STD_INTERNAL_SYMBOL",
CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("THREAD_LOCAL",
CodegenFnAttrFlags::THREAD_LOCAL)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("USED_COMPILER",
CodegenFnAttrFlags::USED_COMPILER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("USED_LINKER",
CodegenFnAttrFlags::USED_LINKER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("TRACK_CALLER",
CodegenFnAttrFlags::TRACK_CALLER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("FFI_PURE",
CodegenFnAttrFlags::FFI_PURE)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("FFI_CONST",
CodegenFnAttrFlags::FFI_CONST)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("ALLOCATOR",
CodegenFnAttrFlags::ALLOCATOR)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("DEALLOCATOR",
CodegenFnAttrFlags::DEALLOCATOR)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("REALLOCATOR",
CodegenFnAttrFlags::REALLOCATOR)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("ALLOCATOR_ZEROED",
CodegenFnAttrFlags::ALLOCATOR_ZEROED)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("NO_BUILTINS",
CodegenFnAttrFlags::NO_BUILTINS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("FOREIGN_ITEM",
CodegenFnAttrFlags::FOREIGN_ITEM)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("OFFLOAD_KERNEL",
CodegenFnAttrFlags::OFFLOAD_KERNEL)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("EXTERNALLY_IMPLEMENTABLE_ITEM",
CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM)
}];
type Bits = u32;
fn bits(&self) -> u32 { CodegenFnAttrFlags::bits(self) }
fn from_bits_retain(bits: u32) -> CodegenFnAttrFlags {
CodegenFnAttrFlags::from_bits_retain(bits)
}
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: iter_without_into_iter,)]
const _: () =
{
#[allow(dead_code, deprecated, unused_attributes)]
impl CodegenFnAttrFlags {
#[inline]
pub const fn empty() -> Self {
Self(<u32 as ::bitflags::Bits>::EMPTY)
}
#[inline]
pub const fn all() -> Self {
let mut truncated = <u32 as ::bitflags::Bits>::EMPTY;
let mut i = 0;
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<CodegenFnAttrFlags as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
let _ = i;
Self(truncated)
}
#[inline]
pub const fn bits(&self) -> u32 { self.0 }
#[inline]
pub const fn from_bits(bits: u32)
-> ::bitflags::__private::core::option::Option<Self> {
let truncated = Self::from_bits_truncate(bits).0;
if truncated == bits {
::bitflags::__private::core::option::Option::Some(Self(bits))
} else { ::bitflags::__private::core::option::Option::None }
}
#[inline]
pub const fn from_bits_truncate(bits: u32) -> Self {
Self(bits & Self::all().0)
}
#[inline]
pub const fn from_bits_retain(bits: u32) -> Self { Self(bits) }
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
{
if name == "COLD" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::COLD.bits()));
}
};
;
{
if name == "NEVER_UNWIND" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::NEVER_UNWIND.bits()));
}
};
;
{
if name == "NAKED" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::NAKED.bits()));
}
};
;
{
if name == "RUSTC_STD_INTERNAL_SYMBOL" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL.bits()));
}
};
;
{
if name == "THREAD_LOCAL" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::THREAD_LOCAL.bits()));
}
};
;
{
if name == "USED_COMPILER" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::USED_COMPILER.bits()));
}
};
;
{
if name == "USED_LINKER" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::USED_LINKER.bits()));
}
};
;
{
if name == "TRACK_CALLER" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::TRACK_CALLER.bits()));
}
};
;
{
if name == "FFI_PURE" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::FFI_PURE.bits()));
}
};
;
{
if name == "FFI_CONST" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::FFI_CONST.bits()));
}
};
;
{
if name == "ALLOCATOR" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::ALLOCATOR.bits()));
}
};
;
{
if name == "DEALLOCATOR" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::DEALLOCATOR.bits()));
}
};
;
{
if name == "REALLOCATOR" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::REALLOCATOR.bits()));
}
};
;
{
if name == "ALLOCATOR_ZEROED" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::ALLOCATOR_ZEROED.bits()));
}
};
;
{
if name == "NO_BUILTINS" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::NO_BUILTINS.bits()));
}
};
;
{
if name == "FOREIGN_ITEM" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::FOREIGN_ITEM.bits()));
}
};
;
{
if name == "OFFLOAD_KERNEL" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::OFFLOAD_KERNEL.bits()));
}
};
;
{
if name == "EXTERNALLY_IMPLEMENTABLE_ITEM" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM.bits()));
}
};
;
let _ = name;
::bitflags::__private::core::option::Option::None
}
#[inline]
pub const fn is_empty(&self) -> bool {
self.0 == <u32 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn is_all(&self) -> bool {
Self::all().0 | self.0 == self.0
}
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0 & other.0 != <u32 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[inline]
pub fn insert(&mut self, other: Self) {
*self = Self(self.0).union(other);
}
#[inline]
pub fn remove(&mut self, other: Self) {
*self = Self(self.0).difference(other);
}
#[inline]
pub fn toggle(&mut self, other: Self) {
*self = Self(self.0).symmetric_difference(other);
}
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
if value { self.insert(other); } else { self.remove(other); }
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self::from_bits_truncate(!self.0)
}
}
impl ::bitflags::__private::core::fmt::Binary for CodegenFnAttrFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for CodegenFnAttrFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for CodegenFnAttrFlags
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for CodegenFnAttrFlags
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for CodegenFnAttrFlags {
type Output = Self;
#[inline]
fn bitor(self, other: CodegenFnAttrFlags) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
CodegenFnAttrFlags {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for CodegenFnAttrFlags {
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
CodegenFnAttrFlags {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for CodegenFnAttrFlags {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
CodegenFnAttrFlags {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for CodegenFnAttrFlags {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for
CodegenFnAttrFlags {
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for CodegenFnAttrFlags {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<CodegenFnAttrFlags> for
CodegenFnAttrFlags {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<CodegenFnAttrFlags>
for CodegenFnAttrFlags {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl CodegenFnAttrFlags {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<CodegenFnAttrFlags> {
::bitflags::iter::Iter::__private_const_new(<CodegenFnAttrFlags
as ::bitflags::Flags>::FLAGS,
CodegenFnAttrFlags::from_bits_retain(self.bits()),
CodegenFnAttrFlags::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<CodegenFnAttrFlags> {
::bitflags::iter::IterNames::__private_const_new(<CodegenFnAttrFlags
as ::bitflags::Flags>::FLAGS,
CodegenFnAttrFlags::from_bits_retain(self.bits()),
CodegenFnAttrFlags::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
CodegenFnAttrFlags {
type Item = CodegenFnAttrFlags;
type IntoIter = ::bitflags::iter::Iter<CodegenFnAttrFlags>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
};bitflags::bitflags! {
179 impl CodegenFnAttrFlags: u32 {
180 const COLD = 1 << 0;
183 const NEVER_UNWIND = 1 << 1;
185 const NAKED = 1 << 2;
188 const RUSTC_STD_INTERNAL_SYMBOL = 1 << 4;
192 const THREAD_LOCAL = 1 << 5;
195 const USED_COMPILER = 1 << 6;
198 const USED_LINKER = 1 << 7;
201 const TRACK_CALLER = 1 << 8;
203 const FFI_PURE = 1 << 9;
206 const FFI_CONST = 1 << 10;
209 const ALLOCATOR = 1 << 11;
212 const DEALLOCATOR = 1 << 12;
214 const REALLOCATOR = 1 << 13;
216 const ALLOCATOR_ZEROED = 1 << 14;
218 const NO_BUILTINS = 1 << 15;
220 const FOREIGN_ITEM = 1 << 16;
222 const OFFLOAD_KERNEL = 1 << 17;
224 const EXTERNALLY_IMPLEMENTABLE_ITEM = 1 << 18;
230 }
231}
232impl ::std::fmt::Debug for CodegenFnAttrFlags {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::bitflags::parser::to_writer(self, f)
}
}rustc_data_structures::external_bitflags_debug! { CodegenFnAttrFlags }
233
234impl CodegenFnAttrs {
235 pub const EMPTY: &'static Self = &Self::new();
236
237 pub const fn new() -> CodegenFnAttrs {
238 CodegenFnAttrs {
239 flags: CodegenFnAttrFlags::empty(),
240 inline: InlineAttr::None,
241 optimize: OptimizeAttr::Default,
242 symbol_name: None,
243 link_ordinal: None,
244 target_features: ::alloc::vec::Vec::new()vec![],
245 foreign_item_symbol_aliases: ::alloc::vec::Vec::new()vec![],
246 safe_target_features: false,
247 linkage: None,
248 import_linkage: None,
249 link_section: None,
250 sanitizers: SanitizerFnAttrs::default(),
251 instruction_set: None,
252 alignment: None,
253 patchable_function_entry: None,
254 objc_class: None,
255 objc_selector: None,
256 instrument_fn: None,
257 }
258 }
259
260 pub fn contains_extern_indicator(&self) -> bool {
270 if self.flags.contains(CodegenFnAttrFlags::FOREIGN_ITEM) {
271 return false;
272 }
273
274 self.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
275 || self.flags.contains(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM)
278 || self.flags.contains(CodegenFnAttrFlags::OFFLOAD_KERNEL)
280 || self.symbol_name.is_some()
281 || match self.linkage {
282 None | Some(Linkage::Internal) => false,
285 Some(_) => true,
286 }
287 }
288}
289
290#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for SanitizerFnAttrs {
}
#[automatically_derived]impl ::core::clone::Clone for SanitizerFnAttrs {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<SanitizerSet>;
let _: ::core::clone::AssertParamIsClone<RtsanSetting>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::Copy for SanitizerFnAttrs { }Copy, #[automatically_derived]impl ::core::fmt::Debug for SanitizerFnAttrs {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"SanitizerFnAttrs disabled rtsan_setting", &self.disabled,
&&self.rtsan_setting)
}
}Debug, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
SanitizerFnAttrs {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
match *self {
SanitizerFnAttrs {
disabled: ref __binding_0, rtsan_setting: ref __binding_1 }
=> {
{ __binding_0.stable_hash(__hcx, __hasher); }
{ __binding_1.stable_hash(__hcx, __hasher); }
}
}
}
}
};StableHash, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for SanitizerFnAttrs {
fn encode(&self, __encoder: &mut __E) {
let SanitizerFnAttrs {
disabled: ref __binding_0, rtsan_setting: ref __binding_1
} = *self;
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for SanitizerFnAttrs {
fn decode(__decoder: &mut __D) -> Self {
SanitizerFnAttrs {
disabled: ::rustc_serialize::Decodable::decode(__decoder),
rtsan_setting: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, #[automatically_derived]impl ::core::cmp::Eq for SanitizerFnAttrs {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<SanitizerSet>;
let _: ::core::cmp::AssertParamIsEq<RtsanSetting>;
}
}Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
SanitizerFnAttrs {
}
#[automatically_derived]impl ::core::cmp::PartialEq for SanitizerFnAttrs {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.disabled == other.disabled &&
self.rtsan_setting == other.rtsan_setting
}
}PartialEq)]
291pub struct SanitizerFnAttrs {
292 pub disabled: SanitizerSet,
293 pub rtsan_setting: RtsanSetting,
294}
295
296const impl Default for SanitizerFnAttrs {
297 fn default() -> Self {
298 Self { disabled: SanitizerSet::empty(), rtsan_setting: RtsanSetting::default() }
299 }
300}