1use std::borrow::Cow;
2
3use rustc_abi::Align;
4use rustc_hir::attrs::{InlineAttr, InstructionSetAttr, Linkage, OptimizeAttr, RtsanSetting};
5use rustc_hir::def_id::DefId;
6use rustc_macros::{StableHash, TyDecodable, TyEncodable};
7use rustc_span::Symbol;
8use rustc_target::spec::SanitizerSet;
9
10use crate::mono::Visibility;
11use crate::ty::{InstanceKind, ShimKind, TyCtxt};
12
13impl<'tcx> TyCtxt<'tcx> {
14 pub fn codegen_instance_attrs(
15 self,
16 instance_kind: InstanceKind<'_>,
17 ) -> Cow<'tcx, CodegenFnAttrs> {
18 let mut attrs = Cow::Borrowed(self.codegen_fn_attrs(instance_kind.def_id()));
21
22 if !#[allow(non_exhaustive_omitted_patterns)] match instance_kind {
InstanceKind::Item(_) => true,
_ => false,
}matches!(instance_kind, InstanceKind::Item(_)) {
25 if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
26 attrs.to_mut().flags.remove(CodegenFnAttrFlags::NAKED);
27 }
28 }
29
30 if let InstanceKind::Shim(ShimKind::Reify(_, _)) = instance_kind
37 && attrs.flags.contains(CodegenFnAttrFlags::TRACK_CALLER)
38 {
39 if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) {
40 attrs.to_mut().flags.remove(CodegenFnAttrFlags::NO_MANGLE);
41 }
42
43 if attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {
44 attrs.to_mut().flags.remove(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
45 }
46
47 if attrs.flags.contains(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM) {
48 attrs.to_mut().flags.remove(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM);
49 }
50
51 if attrs.symbol_name.is_some() {
52 attrs.to_mut().symbol_name = None;
53 }
54 }
55
56 if let InstanceKind::Shim(ShimKind::ClosureOnce {
58 call_once: _,
59 closure,
60 track_caller: _,
61 }) = instance_kind
62 {
63 let closure_attrs = self.codegen_fn_attrs(closure);
64 attrs.to_mut().optimize = closure_attrs.optimize;
65 }
66
67 attrs
68 }
69}
70
71#[derive(#[automatically_derived]
impl ::core::clone::Clone for CodegenFnAttrs {
#[inline]
fn clone(&self) -> CodegenFnAttrs {
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) {
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 } => {
::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]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["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"];
let values: &[&dyn ::core::fmt::Debug] =
&[&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];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"CodegenFnAttrs", names, values)
}
}Debug)]
72pub struct CodegenFnAttrs {
73 pub flags: CodegenFnAttrFlags,
74 pub inline: InlineAttr,
76 pub optimize: OptimizeAttr,
78 pub symbol_name: Option<Symbol>,
82 pub foreign_item_symbol_aliases: Vec<(DefId, Linkage, Visibility)>,
88 pub link_ordinal: Option<u16>,
93 pub target_features: Vec<TargetFeature>,
97 pub safe_target_features: bool,
99 pub linkage: Option<Linkage>,
101 pub import_linkage: Option<Linkage>,
103 pub link_section: Option<Symbol>,
106 pub sanitizers: SanitizerFnAttrs,
109 pub instruction_set: Option<InstructionSetAttr>,
113 pub alignment: Option<Align>,
116 pub patchable_function_entry: Option<PatchableFunctionEntry>,
119 pub objc_class: Option<Symbol>,
121 pub objc_selector: Option<Symbol>,
123 pub instrument_fn: InstrumentFnAttr,
125}
126
127#[derive(#[automatically_derived]
impl ::core::marker::Copy for InstrumentFnAttr { }Copy, #[automatically_derived]
impl ::core::clone::Clone for InstrumentFnAttr {
#[inline]
fn clone(&self) -> InstrumentFnAttr { *self }
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for InstrumentFnAttr {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
InstrumentFnAttr::On => { 0usize }
InstrumentFnAttr::Off => { 1usize }
InstrumentFnAttr::Default => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
InstrumentFnAttr::On => {}
InstrumentFnAttr::Off => {}
InstrumentFnAttr::Default => {}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for InstrumentFnAttr {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { InstrumentFnAttr::On }
1usize => { InstrumentFnAttr::Off }
2usize => { InstrumentFnAttr::Default }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `InstrumentFnAttr`, expected 0..3, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
InstrumentFnAttr {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
InstrumentFnAttr::On => {}
InstrumentFnAttr::Off => {}
InstrumentFnAttr::Default => {}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::fmt::Debug for InstrumentFnAttr {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
InstrumentFnAttr::On => "On",
InstrumentFnAttr::Off => "Off",
InstrumentFnAttr::Default => "Default",
})
}
}Debug)]
128pub enum InstrumentFnAttr {
129 On,
131 Off,
133 Default,
135}
136
137const impl Default for InstrumentFnAttr {
138 fn default() -> Self {
139 InstrumentFnAttr::Default
140 }
141}
142
143#[derive(#[automatically_derived]
impl ::core::marker::Copy for TargetFeatureKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TargetFeatureKind {
#[inline]
fn clone(&self) -> TargetFeatureKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for TargetFeatureKind {
#[inline]
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);
match *self {
TargetFeatureKind::Implied => {}
TargetFeatureKind::Enabled => {}
TargetFeatureKind::Forced => {}
}
}
}
};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) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
TargetFeatureKind::Implied => {}
TargetFeatureKind::Enabled => {}
TargetFeatureKind::Forced => {}
}
}
}
};StableHash, #[automatically_derived]
impl ::core::cmp::PartialEq for TargetFeatureKind {
#[inline]
fn eq(&self, other: &TargetFeatureKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TargetFeatureKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq)]
144pub enum TargetFeatureKind {
145 Implied,
148 Enabled,
150 Forced,
152}
153
154#[derive(#[automatically_derived]
impl ::core::marker::Copy for TargetFeature { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TargetFeature {
#[inline]
fn clone(&self) -> TargetFeature {
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<TargetFeatureKind>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for TargetFeature {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "TargetFeature",
"name", &self.name, "kind", &&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::cmp::PartialEq for TargetFeature {
#[inline]
fn eq(&self, other: &TargetFeature) -> 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) {
match *self {
TargetFeature { name: ref __binding_0, kind: ref __binding_1
} => {
::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)]
155pub struct TargetFeature {
156 pub name: Symbol,
158 pub kind: TargetFeatureKind,
160}
161
162#[derive(#[automatically_derived]
impl ::core::marker::Copy for PatchableFunctionEntry { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PatchableFunctionEntry {
#[inline]
fn clone(&self) -> PatchableFunctionEntry {
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]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"PatchableFunctionEntry", "prefix", &self.prefix, "entry",
&self.entry, "section", &&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) {
match *self {
PatchableFunctionEntry {
prefix: ref __binding_0,
entry: ref __binding_1,
section: ref __binding_2 } => {
::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)]
163pub struct PatchableFunctionEntry {
164 prefix: Option<u8>,
166 entry: Option<u8>,
168 section: Option<Symbol>,
170}
171
172impl PatchableFunctionEntry {
173 pub fn from_prefix_entry_and_section(
174 prefix: Option<u8>,
175 entry: Option<u8>,
176 section: Option<Symbol>,
177 ) -> Self {
178 Self { prefix, entry, section }
179 }
180 pub fn from_prefix_and_entry(prefix: u8, entry: u8) -> Self {
181 Self { prefix: Some(prefix), entry: Some(entry), section: None }
182 }
183 pub fn prefix(&self) -> Option<u8> {
184 self.prefix
185 }
186 pub fn entry(&self) -> Option<u8> {
187 self.entry
188 }
189 pub fn section(&self) -> Option<Symbol> {
190 self.section
191 }
192}
193
194#[derive(#[automatically_derived]
impl ::core::clone::Clone for CodegenFnAttrFlags {
#[inline]
fn clone(&self) -> CodegenFnAttrFlags {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CodegenFnAttrFlags { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for CodegenFnAttrFlags {
#[inline]
fn eq(&self, other: &CodegenFnAttrFlags) -> 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) {
match *self {
CodegenFnAttrFlags(ref __binding_0) => {
::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)]
195pub struct CodegenFnAttrFlags(u32);
196impl 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" `#[no_mangle]`: an indicator that the function's name should be the same"]
#[doc = r" as its symbol."]
#[allow(deprecated, non_upper_case_globals,)]
pub const NO_MANGLE: Self = Self::from_bits_retain(1 << 3);
#[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("NO_MANGLE",
CodegenFnAttrFlags::NO_MANGLE)
},
{
#[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 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 == "NO_MANGLE" {
return ::bitflags::__private::core::option::Option::Some(Self(CodegenFnAttrFlags::NO_MANGLE.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! {
197 impl CodegenFnAttrFlags: u32 {
198 const COLD = 1 << 0;
201 const NEVER_UNWIND = 1 << 1;
203 const NAKED = 1 << 2;
206 const NO_MANGLE = 1 << 3;
209 const RUSTC_STD_INTERNAL_SYMBOL = 1 << 4;
213 const THREAD_LOCAL = 1 << 5;
216 const USED_COMPILER = 1 << 6;
219 const USED_LINKER = 1 << 7;
222 const TRACK_CALLER = 1 << 8;
224 const FFI_PURE = 1 << 9;
227 const FFI_CONST = 1 << 10;
230 const ALLOCATOR = 1 << 11;
233 const DEALLOCATOR = 1 << 12;
235 const REALLOCATOR = 1 << 13;
237 const ALLOCATOR_ZEROED = 1 << 14;
239 const NO_BUILTINS = 1 << 15;
241 const FOREIGN_ITEM = 1 << 16;
243 const OFFLOAD_KERNEL = 1 << 17;
245 const EXTERNALLY_IMPLEMENTABLE_ITEM = 1 << 18;
251 }
252}
253impl ::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 }
254
255impl CodegenFnAttrs {
256 pub const EMPTY: &'static Self = &Self::new();
257
258 pub const fn new() -> CodegenFnAttrs {
259 CodegenFnAttrs {
260 flags: CodegenFnAttrFlags::empty(),
261 inline: InlineAttr::None,
262 optimize: OptimizeAttr::Default,
263 symbol_name: None,
264 link_ordinal: None,
265 target_features: ::alloc::vec::Vec::new()vec![],
266 foreign_item_symbol_aliases: ::alloc::vec::Vec::new()vec![],
267 safe_target_features: false,
268 linkage: None,
269 import_linkage: None,
270 link_section: None,
271 sanitizers: SanitizerFnAttrs::default(),
272 instruction_set: None,
273 alignment: None,
274 patchable_function_entry: None,
275 objc_class: None,
276 objc_selector: None,
277 instrument_fn: InstrumentFnAttr::default(),
278 }
279 }
280
281 pub fn contains_extern_indicator(&self) -> bool {
289 if self.flags.contains(CodegenFnAttrFlags::FOREIGN_ITEM) {
290 return false;
291 }
292
293 self.flags.contains(CodegenFnAttrFlags::NO_MANGLE)
294 || self.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
295 || self.flags.contains(CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM)
298 || self.symbol_name.is_some()
299 || match self.linkage {
300 None | Some(Linkage::Internal) => false,
303 Some(_) => true,
304 }
305 }
306}
307
308#[derive(#[automatically_derived]
impl ::core::clone::Clone for SanitizerFnAttrs {
#[inline]
fn clone(&self) -> SanitizerFnAttrs {
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]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"SanitizerFnAttrs", "disabled", &self.disabled, "rtsan_setting",
&&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) {
match *self {
SanitizerFnAttrs {
disabled: ref __binding_0, rtsan_setting: ref __binding_1 }
=> {
::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::cmp::PartialEq for SanitizerFnAttrs {
#[inline]
fn eq(&self, other: &SanitizerFnAttrs) -> bool {
self.disabled == other.disabled &&
self.rtsan_setting == other.rtsan_setting
}
}PartialEq)]
309pub struct SanitizerFnAttrs {
310 pub disabled: SanitizerSet,
311 pub rtsan_setting: RtsanSetting,
312}
313
314const impl Default for SanitizerFnAttrs {
315 fn default() -> Self {
316 Self { disabled: SanitizerSet::empty(), rtsan_setting: RtsanSetting::default() }
317 }
318}