Skip to main content

rustc_codegen_ssa/
lib.rs

1// tidy-alphabetical-start
2#![feature(deref_patterns)]
3#![feature(file_buffered)]
4#![feature(negative_impls)]
5#![feature(option_into_flat_iter)]
6#![feature(trait_alias)]
7#![feature(try_blocks)]
8#![recursion_limit = "256"]
9// tidy-alphabetical-end
10
11//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
12//! The backend-agnostic functions of this crate use functions defined in various traits that
13//! have to be implemented by each backend.
14
15use std::collections::BTreeSet;
16use std::io;
17use std::path::{Path, PathBuf};
18use std::sync::Arc;
19
20use rustc_abi::Size;
21use rustc_attr_ir::{CfgEntry, WindowsSubsystemKind};
22use rustc_crate_store::{self as cstore, CrateSource};
23use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
24use rustc_data_structures::unord::{UnordMap, UnordSet};
25use rustc_hir::CRATE_HIR_ID;
26use rustc_hir::def_id::CrateNum;
27use rustc_lint_defs::builtin::{LINKER_INFO, LINKER_MESSAGES};
28use rustc_macros::{Decodable, Encodable};
29use rustc_metadata::EncodedMetadata;
30use rustc_middle::dep_graph::WorkProduct;
31use rustc_middle::lint::StableLevelSpec;
32use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
33use rustc_middle::middle::dependency_format::Dependencies;
34use rustc_middle::middle::exported_symbols::SymbolExportKind;
35use rustc_middle::ty::TyCtxt;
36use rustc_middle::util::Providers;
37use rustc_serialize::opaque::{FileEncoder, MemDecoder};
38use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
39use rustc_session::Session;
40use rustc_session::config::OutputFilenames;
41use rustc_session::output::OutputType;
42use rustc_span::{Span, Symbol};
43use rustc_structures::{CrateType, NativeLibKind};
44
45pub mod assert_module_sources;
46pub mod back;
47pub mod base;
48pub mod codegen_attrs;
49pub mod common;
50pub mod debuginfo;
51pub mod diagnostics;
52pub mod meth;
53pub mod mir;
54pub mod mono_item;
55pub mod size_of_val;
56pub mod target_features;
57pub mod traits;
58
59pub struct ModuleCodegen<M> {
60    /// The name of the module. When the crate may be saved between
61    /// compilations, incremental compilation requires that name be
62    /// unique amongst **all** crates. Therefore, it should contain
63    /// something unique to this crate (e.g., a module path) as well
64    /// as the crate name and disambiguator.
65    /// We currently generate these names via CodegenUnit::build_cgu_name().
66    pub name: String,
67    pub module_llvm: M,
68    pub kind: ModuleKind,
69}
70
71impl<M> ModuleCodegen<M> {
72    pub fn new_regular(name: impl Into<String>, module: M) -> Self {
73        Self { name: name.into(), module_llvm: module, kind: ModuleKind::Regular }
74    }
75
76    pub fn new_allocator(name: impl Into<String>, module: M) -> Self {
77        Self { name: name.into(), module_llvm: module, kind: ModuleKind::Allocator }
78    }
79
80    pub fn into_compiled_module(
81        self,
82        emit_obj: bool,
83        emit_dwarf_obj: bool,
84        emit_bc: bool,
85        emit_asm: bool,
86        emit_ir: bool,
87        outputs: &OutputFilenames,
88    ) -> CompiledModule {
89        let object = emit_obj.then(|| outputs.temp_path_for_cgu(OutputType::Object, &self.name));
90        let dwarf_object = emit_dwarf_obj.then(|| outputs.temp_path_dwo_for_cgu(&self.name));
91        let bytecode = emit_bc.then(|| outputs.temp_path_for_cgu(OutputType::Bitcode, &self.name));
92        let assembly =
93            emit_asm.then(|| outputs.temp_path_for_cgu(OutputType::Assembly, &self.name));
94        let llvm_ir =
95            emit_ir.then(|| outputs.temp_path_for_cgu(OutputType::LlvmAssembly, &self.name));
96
97        CompiledModule {
98            name: self.name,
99            kind: self.kind,
100            object,
101            global_asm_object: None,
102            dwarf_object,
103            bytecode,
104            assembly,
105            llvm_ir,
106        }
107    }
108}
109
110#[derive(#[automatically_derived]impl ::core::fmt::Debug for CompiledModule {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "CompiledModule name kind object global_asm_object dwarf_object bytecode assembly llvm_ir",
            &[&self.name, &self.kind, &self.object, &self.global_asm_object,
                        &self.dwarf_object, &self.bytecode, &self.assembly,
                        &&self.llvm_ir])
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CompiledModule {
            fn encode(&self, __encoder: &mut __E) {
                let CompiledModule {
                        name: ref __binding_0,
                        kind: ref __binding_1,
                        object: ref __binding_2,
                        global_asm_object: ref __binding_3,
                        dwarf_object: ref __binding_4,
                        bytecode: ref __binding_5,
                        assembly: ref __binding_6,
                        llvm_ir: ref __binding_7 } = *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);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CompiledModule {
            fn decode(__decoder: &mut __D) -> Self {
                CompiledModule {
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    object: ::rustc_serialize::Decodable::decode(__decoder),
                    global_asm_object: ::rustc_serialize::Decodable::decode(__decoder),
                    dwarf_object: ::rustc_serialize::Decodable::decode(__decoder),
                    bytecode: ::rustc_serialize::Decodable::decode(__decoder),
                    assembly: ::rustc_serialize::Decodable::decode(__decoder),
                    llvm_ir: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
111pub struct CompiledModule {
112    pub name: String,
113    pub kind: ModuleKind,
114    pub object: Option<PathBuf>,
115    pub global_asm_object: Option<PathBuf>,
116    pub dwarf_object: Option<PathBuf>,
117    pub bytecode: Option<PathBuf>,
118    pub assembly: Option<PathBuf>, // --emit=asm
119    pub llvm_ir: Option<PathBuf>,  // --emit=llvm-ir, llvm-bc is in bytecode
120}
121
122impl CompiledModule {
123    /// Call `emit` function with every artifact type currently compiled
124    pub fn for_each_output(&self, mut emit: impl FnMut(&Path, OutputType)) {
125        if let Some(path) = self.object.as_deref() {
126            emit(path, OutputType::Object);
127        }
128        if let Some(path) = self.bytecode.as_deref() {
129            emit(path, OutputType::Bitcode);
130        }
131        if let Some(path) = self.llvm_ir.as_deref() {
132            emit(path, OutputType::LlvmAssembly);
133        }
134        if let Some(path) = self.assembly.as_deref() {
135            emit(path, OutputType::Assembly);
136        }
137    }
138}
139
140pub(crate) struct CachedModuleCodegen {
141    pub name: String,
142    pub source: WorkProduct,
143}
144
145#[derive(#[automatically_derived]impl ::core::marker::Copy for ModuleKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ModuleKind {
}
#[automatically_derived]impl ::core::clone::Clone for ModuleKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ModuleKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ModuleKind::Regular => "Regular",
                ModuleKind::Allocator => "Allocator",
            })
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ModuleKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ModuleKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ModuleKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ModuleKind::Regular => { 0usize }
                        ModuleKind::Allocator => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ModuleKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { ModuleKind::Regular }
                    1usize => { ModuleKind::Allocator }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ModuleKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
146pub enum ModuleKind {
147    Regular,
148    Allocator,
149}
150
151#[doc =
r" This previously had an `UNALIGNED` variant, but that should never be done via flags."]
#[doc =
r" If you want something to be unaligned, see [`mir::place::PlaceRef::unaligned`]."]
pub struct MemFlags(<MemFlags as
    ::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]impl ::core::fmt::Debug for MemFlags {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "MemFlags",
            &&self.0)
    }
}
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for MemFlags {
}
#[automatically_derived]impl ::core::clone::Clone for MemFlags {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<<MemFlags as
                ::bitflags::__private::PublicFlags>::Internal>;
        *self
    }
}
#[automatically_derived]impl ::core::marker::Copy for MemFlags { }
#[automatically_derived]impl ::core::marker::StructuralPartialEq for MemFlags
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for MemFlags {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]impl ::core::cmp::Eq for MemFlags {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _:
                ::core::cmp::AssertParamIsEq<<MemFlags as
                ::bitflags::__private::PublicFlags>::Internal>;
    }
}
impl MemFlags {
    #[allow(deprecated, non_upper_case_globals,)]
    pub const VOLATILE: Self = Self::from_bits_retain(1 << 0);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const NONTEMPORAL: Self = Self::from_bits_retain(1 << 1);
    #[doc =
    r" Indicates that writing through the stored pointer is undefined behavior."]
    #[doc =
    r" Only valid on stores of pointers, or pairs where the first element is a pointer."]
    #[doc =
    r" In the latter case, the flag only applies to the first element of the pair."]
    #[allow(deprecated, non_upper_case_globals,)]
    pub const CAPTURES_READ_ONLY: Self = Self::from_bits_retain(1 << 3);
}
impl ::bitflags::Flags for MemFlags {
    const FLAGS: &'static [::bitflags::Flag<MemFlags>] =
        &[{

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("VOLATILE", MemFlags::VOLATILE)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("NONTEMPORAL", MemFlags::NONTEMPORAL)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("CAPTURES_READ_ONLY",
                            MemFlags::CAPTURES_READ_ONLY)
                    }];
    type Bits = u8;
    fn bits(&self) -> u8 { MemFlags::bits(self) }
    fn from_bits_retain(bits: u8) -> MemFlags {
        MemFlags::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 :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[repr(transparent)]
        pub struct InternalBitFlags(u8);
        #[automatically_derived]
        #[doc(hidden)]
        unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::clone::Clone for InternalBitFlags {
            #[inline]
            #[rustc_trivial_field_reads]
            fn clone(&self) -> Self {
                let _: ::core::clone::AssertParamIsClone<u8>;
                *self
            }
        }
        #[automatically_derived]
        impl ::core::marker::Copy for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::cmp::PartialEq for InternalBitFlags {
            #[inline]
            fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
        }
        #[automatically_derived]
        impl ::core::cmp::Eq for InternalBitFlags {
            #[inline]
            #[doc(hidden)]
            #[coverage(off)]
            fn assert_fields_are_eq(&self) {
                let _: ::core::cmp::AssertParamIsEq<u8>;
            }
        }
        #[automatically_derived]
        impl ::core::cmp::PartialOrd for InternalBitFlags {
            #[inline]
            fn partial_cmp(&self, other: &Self)
                -> ::core::option::Option<::core::cmp::Ordering> {
                ::core::option::Option::Some(::core::cmp::Ord::cmp(self,
                        other))
            }
        }
        #[automatically_derived]
        impl ::core::cmp::Ord for InternalBitFlags {
            #[inline]
            fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
                ::core::cmp::Ord::cmp(&self.0, &other.0)
            }
        }
        #[automatically_derived]
        impl ::core::hash::Hash for InternalBitFlags {
            #[inline]
            fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
                ::core::hash::Hash::hash(&self.0, state)
            }
        }
        impl ::bitflags::__private::PublicFlags for MemFlags {
            type Primitive = u8;
            type Internal = InternalBitFlags;
        }
        impl ::bitflags::__private::core::default::Default for
            InternalBitFlags {
            #[inline]
            fn default() -> Self { InternalBitFlags::empty() }
        }
        impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                if self.is_empty() {
                    f.write_fmt(format_args!("{0:#x}",
                            <u8 as ::bitflags::Bits>::EMPTY))
                } else {
                    ::bitflags::__private::core::fmt::Display::fmt(self, f)
                }
            }
        }
        impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                ::bitflags::parser::to_writer(&MemFlags(*self), f)
            }
        }
        impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
            type Err = ::bitflags::parser::ParseError;
            fn from_str(s: &str)
                ->
                    ::bitflags::__private::core::result::Result<Self,
                    Self::Err> {
                ::bitflags::parser::from_str::<MemFlags>(s).map(|flags|
                        flags.0)
            }
        }
        impl ::bitflags::__private::core::convert::AsRef<u8> for
            InternalBitFlags {
            fn as_ref(&self) -> &u8 { &self.0 }
        }
        impl ::bitflags::__private::core::convert::From<u8> for
            InternalBitFlags {
            fn from(bits: u8) -> Self { Self::from_bits_retain(bits) }
        }
        #[allow(dead_code, deprecated, unused_attributes)]
        impl InternalBitFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self {
                Self(<u8 as ::bitflags::Bits>::EMPTY)
            }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self {
                let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
                let mut i = 0;
                {
                    {
                        let flag =
                            <MemFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <MemFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <MemFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                let _ = i;
                Self(truncated)
            }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0 }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::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 }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(bits & Self::all().0)
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self { Self(bits) }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                {
                    if name == "VOLATILE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(MemFlags::VOLATILE.bits()));
                    }
                };
                ;
                {
                    if name == "NONTEMPORAL" {
                        return ::bitflags::__private::core::option::Option::Some(Self(MemFlags::NONTEMPORAL.bits()));
                    }
                };
                ;
                {
                    if name == "CAPTURES_READ_ONLY" {
                        return ::bitflags::__private::core::option::Option::Some(Self(MemFlags::CAPTURES_READ_ONLY.bits()));
                    }
                };
                ;
                let _ = name;
                ::bitflags::__private::core::option::Option::None
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool {
                self.0 == <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool {
                Self::all().0 | self.0 == self.0
            }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0 & other.0 != <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0 & other.0 == other.0
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) {
                *self = Self(self.0).union(other);
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) {
                *self = Self(self.0).difference(other);
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) {
                *self = Self(self.0).symmetric_difference(other);
            }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                if value { self.insert(other); } else { self.remove(other); }
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0 & other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0 | other.0)
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0 & !other.0)
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0 ^ other.0)
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self::from_bits_truncate(!self.0)
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
            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 InternalBitFlags {
            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 InternalBitFlags {
            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 InternalBitFlags {
            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 InternalBitFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: InternalBitFlags) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for
            InternalBitFlags {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for
            InternalBitFlags {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
            {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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<InternalBitFlags>
            for InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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 InternalBitFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<MemFlags> {
                ::bitflags::iter::Iter::__private_const_new(<MemFlags as
                        ::bitflags::Flags>::FLAGS,
                    MemFlags::from_bits_retain(self.bits()),
                    MemFlags::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<MemFlags> {
                ::bitflags::iter::IterNames::__private_const_new(<MemFlags as
                        ::bitflags::Flags>::FLAGS,
                    MemFlags::from_bits_retain(self.bits()),
                    MemFlags::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            InternalBitFlags {
            type Item = MemFlags;
            type IntoIter = ::bitflags::iter::Iter<MemFlags>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
        impl InternalBitFlags {
            /// Returns a mutable reference to the raw value of the flags currently stored.
            #[inline]
            pub fn bits_mut(&mut self) -> &mut u8 { &mut self.0 }
        }
        #[allow(dead_code, deprecated, unused_attributes)]
        impl MemFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self { Self(InternalBitFlags::all()) }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0.bits() }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_bits(bits) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(InternalBitFlags::from_bits_truncate(bits))
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self {
                Self(InternalBitFlags::from_bits_retain(bits))
            }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_name(name) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool { self.0.is_empty() }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool { self.0.is_all() }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0.intersects(other.0)
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0.contains(other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                self.0.set(other.0, value)
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0.intersection(other.0))
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0.union(other.0))
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0.difference(other.0))
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0.symmetric_difference(other.0))
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self(self.0.complement())
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for MemFlags {
            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 MemFlags {
            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 MemFlags {
            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 MemFlags {
            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 MemFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: MemFlags) -> Self { self.union(other) }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for MemFlags {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for MemFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for MemFlags {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for MemFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for MemFlags {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for MemFlags {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for MemFlags {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for MemFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<MemFlags> for MemFlags
            {
            /// The bitwise or (`|`) of the bits in each flags value.
            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<MemFlags> for
            MemFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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 MemFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<MemFlags> {
                ::bitflags::iter::Iter::__private_const_new(<MemFlags as
                        ::bitflags::Flags>::FLAGS,
                    MemFlags::from_bits_retain(self.bits()),
                    MemFlags::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<MemFlags> {
                ::bitflags::iter::IterNames::__private_const_new(<MemFlags as
                        ::bitflags::Flags>::FLAGS,
                    MemFlags::from_bits_retain(self.bits()),
                    MemFlags::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for MemFlags {
            type Item = MemFlags;
            type IntoIter = ::bitflags::iter::Iter<MemFlags>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
152    /// This previously had an `UNALIGNED` variant, but that should never be done via flags.
153    /// If you want something to be unaligned, see [`mir::place::PlaceRef::unaligned`].
154    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
155    pub struct MemFlags: u8 {
156        const VOLATILE = 1 << 0;
157        const NONTEMPORAL = 1 << 1;
158        /// Indicates that writing through the stored pointer is undefined behavior.
159        /// Only valid on stores of pointers, or pairs where the first element is a pointer.
160        /// In the latter case, the flag only applies to the first element of the pair.
161        const CAPTURES_READ_ONLY = 1 << 3;
162    }
163}
164
165#[derive(#[automatically_derived]impl<V: ::core::fmt::Debug> ::core::fmt::Debug for
    RetagInfo<V> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "RetagInfo size flags im_layout pin_layout", &self.size,
            &self.flags, &self.im_layout, &&self.pin_layout)
    }
}Debug, #[automatically_derived]impl<V: ::core::marker::Copy> ::core::marker::Copy for
    RetagInfo<V> {
}Copy, #[automatically_derived]impl<V: ::core::clone::Clone> ::core::clone::Clone for
    RetagInfo<V> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        RetagInfo {
            size: ::core::clone::Clone::clone(&self.size),
            flags: ::core::clone::Clone::clone(&self.flags),
            im_layout: ::core::clone::Clone::clone(&self.im_layout),
            pin_layout: ::core::clone::Clone::clone(&self.pin_layout),
        }
    }
}Clone)]
166pub struct RetagInfo<V> {
167    /// The size of the initial range within the allocation that is
168    /// associated with the permission created by the retag.
169    pub size: Size,
170    /// Encoded type information used to determine the kind of permission
171    /// created by the retag.
172    pub flags: RetagFlags,
173    /// A pointer to a constant array of (offset, size) pairs describing
174    /// the ranges covered by `UnsafeCell` within the pointee type.
175    pub im_layout: V,
176    /// A pointer to a constant array of (offset, size) pairs describing
177    /// the ranges covered by `UnsafePinned` within the pointee type.
178    pub pin_layout: V,
179}
180
181#[repr(C)]
pub struct RetagFlags(<RetagFlags as
    ::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]impl ::core::fmt::Debug for RetagFlags {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "RetagFlags",
            &&self.0)
    }
}
#[automatically_derived]impl ::core::marker::Copy for RetagFlags { }
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for RetagFlags {
}
#[automatically_derived]impl ::core::clone::Clone for RetagFlags {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<<RetagFlags as
                ::bitflags::__private::PublicFlags>::Internal>;
        *self
    }
}
#[automatically_derived]impl ::core::marker::StructuralPartialEq for
    RetagFlags {
}
#[automatically_derived]impl ::core::cmp::PartialEq for RetagFlags {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]impl ::core::cmp::Eq for RetagFlags {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _:
                ::core::cmp::AssertParamIsEq<<RetagFlags as
                ::bitflags::__private::PublicFlags>::Internal>;
    }
}
#[automatically_derived]impl ::core::hash::Hash for RetagFlags {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}
impl RetagFlags {
    #[doc = r" If this is a function-entry retag."]
    #[allow(deprecated, non_upper_case_globals,)]
    pub const IS_PROTECTED: Self = Self::from_bits_retain(1 << 0);
    #[doc = r" If this is a mutable reference or a `Box`."]
    #[allow(deprecated, non_upper_case_globals,)]
    pub const IS_MUTABLE: Self = Self::from_bits_retain(1 << 1);
    #[doc = r" If this is a `Box`."]
    #[allow(deprecated, non_upper_case_globals,)]
    pub const IS_BOX: Self = Self::from_bits_retain(1 << 2);
    #[doc = r" If the pointee type is `Freeze`"]
    #[allow(deprecated, non_upper_case_globals,)]
    pub const IS_FREEZE: Self = Self::from_bits_retain(1 << 3);
}
impl ::bitflags::Flags for RetagFlags {
    const FLAGS: &'static [::bitflags::Flag<RetagFlags>] =
        &[{

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("IS_PROTECTED",
                            RetagFlags::IS_PROTECTED)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("IS_MUTABLE", RetagFlags::IS_MUTABLE)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("IS_BOX", RetagFlags::IS_BOX)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("IS_FREEZE", RetagFlags::IS_FREEZE)
                    }];
    type Bits = u8;
    fn bits(&self) -> u8 { RetagFlags::bits(self) }
    fn from_bits_retain(bits: u8) -> RetagFlags {
        RetagFlags::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 :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[repr(transparent)]
        pub struct InternalBitFlags(u8);
        #[automatically_derived]
        #[doc(hidden)]
        unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::clone::Clone for InternalBitFlags {
            #[inline]
            #[rustc_trivial_field_reads]
            fn clone(&self) -> Self {
                let _: ::core::clone::AssertParamIsClone<u8>;
                *self
            }
        }
        #[automatically_derived]
        impl ::core::marker::Copy for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::cmp::PartialEq for InternalBitFlags {
            #[inline]
            fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
        }
        #[automatically_derived]
        impl ::core::cmp::Eq for InternalBitFlags {
            #[inline]
            #[doc(hidden)]
            #[coverage(off)]
            fn assert_fields_are_eq(&self) {
                let _: ::core::cmp::AssertParamIsEq<u8>;
            }
        }
        #[automatically_derived]
        impl ::core::cmp::PartialOrd for InternalBitFlags {
            #[inline]
            fn partial_cmp(&self, other: &Self)
                -> ::core::option::Option<::core::cmp::Ordering> {
                ::core::option::Option::Some(::core::cmp::Ord::cmp(self,
                        other))
            }
        }
        #[automatically_derived]
        impl ::core::cmp::Ord for InternalBitFlags {
            #[inline]
            fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
                ::core::cmp::Ord::cmp(&self.0, &other.0)
            }
        }
        #[automatically_derived]
        impl ::core::hash::Hash for InternalBitFlags {
            #[inline]
            fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
                ::core::hash::Hash::hash(&self.0, state)
            }
        }
        impl ::bitflags::__private::PublicFlags for RetagFlags {
            type Primitive = u8;
            type Internal = InternalBitFlags;
        }
        impl ::bitflags::__private::core::default::Default for
            InternalBitFlags {
            #[inline]
            fn default() -> Self { InternalBitFlags::empty() }
        }
        impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                if self.is_empty() {
                    f.write_fmt(format_args!("{0:#x}",
                            <u8 as ::bitflags::Bits>::EMPTY))
                } else {
                    ::bitflags::__private::core::fmt::Display::fmt(self, f)
                }
            }
        }
        impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                ::bitflags::parser::to_writer(&RetagFlags(*self), f)
            }
        }
        impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
            type Err = ::bitflags::parser::ParseError;
            fn from_str(s: &str)
                ->
                    ::bitflags::__private::core::result::Result<Self,
                    Self::Err> {
                ::bitflags::parser::from_str::<RetagFlags>(s).map(|flags|
                        flags.0)
            }
        }
        impl ::bitflags::__private::core::convert::AsRef<u8> for
            InternalBitFlags {
            fn as_ref(&self) -> &u8 { &self.0 }
        }
        impl ::bitflags::__private::core::convert::From<u8> for
            InternalBitFlags {
            fn from(bits: u8) -> Self { Self::from_bits_retain(bits) }
        }
        #[allow(dead_code, deprecated, unused_attributes)]
        impl InternalBitFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self {
                Self(<u8 as ::bitflags::Bits>::EMPTY)
            }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self {
                let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
                let mut i = 0;
                {
                    {
                        let flag =
                            <RetagFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <RetagFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <RetagFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <RetagFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                let _ = i;
                Self(truncated)
            }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0 }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::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 }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(bits & Self::all().0)
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self { Self(bits) }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                {
                    if name == "IS_PROTECTED" {
                        return ::bitflags::__private::core::option::Option::Some(Self(RetagFlags::IS_PROTECTED.bits()));
                    }
                };
                ;
                {
                    if name == "IS_MUTABLE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(RetagFlags::IS_MUTABLE.bits()));
                    }
                };
                ;
                {
                    if name == "IS_BOX" {
                        return ::bitflags::__private::core::option::Option::Some(Self(RetagFlags::IS_BOX.bits()));
                    }
                };
                ;
                {
                    if name == "IS_FREEZE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(RetagFlags::IS_FREEZE.bits()));
                    }
                };
                ;
                let _ = name;
                ::bitflags::__private::core::option::Option::None
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool {
                self.0 == <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool {
                Self::all().0 | self.0 == self.0
            }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0 & other.0 != <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0 & other.0 == other.0
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) {
                *self = Self(self.0).union(other);
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) {
                *self = Self(self.0).difference(other);
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) {
                *self = Self(self.0).symmetric_difference(other);
            }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                if value { self.insert(other); } else { self.remove(other); }
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0 & other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0 | other.0)
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0 & !other.0)
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0 ^ other.0)
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self::from_bits_truncate(!self.0)
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
            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 InternalBitFlags {
            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 InternalBitFlags {
            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 InternalBitFlags {
            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 InternalBitFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: InternalBitFlags) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for
            InternalBitFlags {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for
            InternalBitFlags {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
            {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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<InternalBitFlags>
            for InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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 InternalBitFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<RetagFlags> {
                ::bitflags::iter::Iter::__private_const_new(<RetagFlags as
                        ::bitflags::Flags>::FLAGS,
                    RetagFlags::from_bits_retain(self.bits()),
                    RetagFlags::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<RetagFlags> {
                ::bitflags::iter::IterNames::__private_const_new(<RetagFlags
                        as ::bitflags::Flags>::FLAGS,
                    RetagFlags::from_bits_retain(self.bits()),
                    RetagFlags::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            InternalBitFlags {
            type Item = RetagFlags;
            type IntoIter = ::bitflags::iter::Iter<RetagFlags>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
        impl InternalBitFlags {
            /// Returns a mutable reference to the raw value of the flags currently stored.
            #[inline]
            pub fn bits_mut(&mut self) -> &mut u8 { &mut self.0 }
        }
        #[allow(dead_code, deprecated, unused_attributes)]
        impl RetagFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self { Self(InternalBitFlags::all()) }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0.bits() }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_bits(bits) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(InternalBitFlags::from_bits_truncate(bits))
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self {
                Self(InternalBitFlags::from_bits_retain(bits))
            }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_name(name) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool { self.0.is_empty() }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool { self.0.is_all() }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0.intersects(other.0)
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0.contains(other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                self.0.set(other.0, value)
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0.intersection(other.0))
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0.union(other.0))
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0.difference(other.0))
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0.symmetric_difference(other.0))
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self(self.0.complement())
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for RetagFlags {
            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 RetagFlags {
            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 RetagFlags {
            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 RetagFlags {
            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 RetagFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: RetagFlags) -> Self { self.union(other) }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for RetagFlags {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for RetagFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for RetagFlags {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for RetagFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for RetagFlags {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for RetagFlags {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for RetagFlags {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for RetagFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<RetagFlags> for
            RetagFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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<RetagFlags> for
            RetagFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            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 RetagFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<RetagFlags> {
                ::bitflags::iter::Iter::__private_const_new(<RetagFlags as
                        ::bitflags::Flags>::FLAGS,
                    RetagFlags::from_bits_retain(self.bits()),
                    RetagFlags::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<RetagFlags> {
                ::bitflags::iter::IterNames::__private_const_new(<RetagFlags
                        as ::bitflags::Flags>::FLAGS,
                    RetagFlags::from_bits_retain(self.bits()),
                    RetagFlags::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for RetagFlags {
            type Item = RetagFlags;
            type IntoIter = ::bitflags::iter::Iter<RetagFlags>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
182    #[repr(C)]
183    #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
184    pub struct RetagFlags: u8 {
185        /// If this is a function-entry retag.
186        const IS_PROTECTED = 1 << 0;
187        /// If this is a mutable reference or a `Box`.
188        const IS_MUTABLE = 1 << 1;
189        /// If this is a `Box`.
190        const IS_BOX = 1 << 2;
191        /// If the pointee type is `Freeze`
192        const IS_FREEZE = 1 << 3;
193    }
194}
195
196// This is the same as `rustc_crate_store::NativeLib`, except:
197// - (important) the `foreign_module` field is missing, because it contains a `DefId`, which can't
198//   be encoded with `FileEncoder`.
199// - (less important) the `verbatim` field is a `bool` rather than an `Option<bool>`, because here
200//   we can treat `false` and `absent` the same.
201#[derive(#[automatically_derived]impl ::core::clone::Clone for NativeLib {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        NativeLib {
            kind: ::core::clone::Clone::clone(&self.kind),
            name: ::core::clone::Clone::clone(&self.name),
            cfg: ::core::clone::Clone::clone(&self.cfg),
            verbatim: ::core::clone::Clone::clone(&self.verbatim),
            dll_imports: ::core::clone::Clone::clone(&self.dll_imports),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for NativeLib {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f,
            "NativeLib kind name cfg verbatim dll_imports", &self.kind,
            &self.name, &self.cfg, &self.verbatim, &&self.dll_imports)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for NativeLib {
            fn encode(&self, __encoder: &mut __E) {
                let NativeLib {
                        kind: ref __binding_0,
                        name: ref __binding_1,
                        cfg: ref __binding_2,
                        verbatim: ref __binding_3,
                        dll_imports: ref __binding_4 } = *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);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for NativeLib {
            fn decode(__decoder: &mut __D) -> Self {
                NativeLib {
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    cfg: ::rustc_serialize::Decodable::decode(__decoder),
                    verbatim: ::rustc_serialize::Decodable::decode(__decoder),
                    dll_imports: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
202pub struct NativeLib {
203    pub kind: NativeLibKind,
204    pub name: Symbol,
205    pub cfg: Option<CfgEntry>,
206    pub verbatim: bool,
207    pub dll_imports: Vec<cstore::DllImport>,
208}
209
210impl From<&cstore::NativeLib> for NativeLib {
211    fn from(lib: &cstore::NativeLib) -> Self {
212        NativeLib {
213            kind: lib.kind,
214            name: lib.name,
215            cfg: lib.cfg.clone(),
216            verbatim: lib.verbatim.unwrap_or(false),
217            dll_imports: lib.dll_imports.clone(),
218        }
219    }
220}
221
222/// A symbol to make visible from a linked artifact.
223#[derive(#[automatically_derived]impl ::core::clone::Clone for SymbolExport {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        SymbolExport {
            name: ::core::clone::Clone::clone(&self.name),
            kind: ::core::clone::Clone::clone(&self.kind),
            link_name: ::core::clone::Clone::clone(&self.link_name),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for SymbolExport {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "SymbolExport name kind link_name", &self.name, &self.kind,
            &&self.link_name)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for SymbolExport {
            fn encode(&self, __encoder: &mut __E) {
                let SymbolExport {
                        name: ref __binding_0,
                        kind: ref __binding_1,
                        link_name: 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);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for SymbolExport {
            fn decode(__decoder: &mut __D) -> Self {
                SymbolExport {
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    kind: ::rustc_serialize::Decodable::decode(__decoder),
                    link_name: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
224pub struct SymbolExport {
225    /// Name to make visible from the linked artifact.
226    pub name: String,
227    /// Kind of symbol, used for target-specific export directives and name decoration.
228    pub kind: SymbolExportKind,
229    /// Name of the symbol as seen by the linker, when it differs from `name`.
230    pub link_name: Option<String>,
231}
232
233impl SymbolExport {
234    pub fn new(name: String, kind: SymbolExportKind) -> SymbolExport {
235        SymbolExport { name, kind, link_name: None }
236    }
237
238    pub fn with_link_name(name: String, kind: SymbolExportKind, link_name: String) -> SymbolExport {
239        let link_name = if link_name == name { None } else { Some(link_name) };
240        SymbolExport { name, kind, link_name }
241    }
242}
243
244#[derive(#[automatically_derived]impl ::core::clone::Clone for EiiLinkageImplInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        EiiLinkageImplInfo {
            span: ::core::clone::Clone::clone(&self.span),
            impl_crate: ::core::clone::Clone::clone(&self.impl_crate),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for EiiLinkageImplInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "EiiLinkageImplInfo span impl_crate", &self.span,
            &&self.impl_crate)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for EiiLinkageImplInfo {
            fn encode(&self, __encoder: &mut __E) {
                let EiiLinkageImplInfo {
                        span: ref __binding_0, impl_crate: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for EiiLinkageImplInfo {
            fn decode(__decoder: &mut __D) -> Self {
                EiiLinkageImplInfo {
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                    impl_crate: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
245pub struct EiiLinkageImplInfo {
246    pub span: Span,
247    pub impl_crate: CrateNum,
248}
249
250#[derive(#[automatically_derived]impl ::core::clone::Clone for EiiLinkageInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        EiiLinkageInfo {
            name: ::core::clone::Clone::clone(&self.name),
            impls: ::core::clone::Clone::clone(&self.impls),
            default_impl: ::core::clone::Clone::clone(&self.default_impl),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for EiiLinkageInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "EiiLinkageInfo name impls default_impl", &self.name, &self.impls,
            &&self.default_impl)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for EiiLinkageInfo {
            fn encode(&self, __encoder: &mut __E) {
                let EiiLinkageInfo {
                        name: ref __binding_0,
                        impls: ref __binding_1,
                        default_impl: 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);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for EiiLinkageInfo {
            fn decode(__decoder: &mut __D) -> Self {
                EiiLinkageInfo {
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    impls: ::rustc_serialize::Decodable::decode(__decoder),
                    default_impl: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
251pub struct EiiLinkageInfo {
252    pub name: Symbol,
253    pub impls: Vec<EiiLinkageImplInfo>,
254    pub default_impl: Option<EiiLinkageImplInfo>,
255}
256
257/// Misc info we load from metadata to persist beyond the tcx.
258///
259/// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo`
260/// is self-contained. `CrateNum` can be viewed as a unique identifier within a `CrateInfo`, where
261/// `used_crate_source` contains all `CrateSource` of the dependents, and maintains a mapping from
262/// identifiers (`CrateNum`) to `CrateSource`. The other fields map `CrateNum` to the crate's own
263/// additional properties, so that effectively we can retrieve each dependent crate's `CrateSource`
264/// and the corresponding properties without referencing information outside of a `CrateInfo`.
265// rustc_codegen_cranelift needs a Clone impl for its jit mode, which isn't tested in rust CI
266#[derive(#[automatically_derived]impl ::core::clone::Clone for CrateInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        CrateInfo {
            target_cpu: ::core::clone::Clone::clone(&self.target_cpu),
            target_features: ::core::clone::Clone::clone(&self.target_features),
            crate_types: ::core::clone::Clone::clone(&self.crate_types),
            exported_symbols: ::core::clone::Clone::clone(&self.exported_symbols),
            linked_symbols: ::core::clone::Clone::clone(&self.linked_symbols),
            local_crate_name: ::core::clone::Clone::clone(&self.local_crate_name),
            compiler_builtins: ::core::clone::Clone::clone(&self.compiler_builtins),
            profiler_runtime: ::core::clone::Clone::clone(&self.profiler_runtime),
            is_no_builtins: ::core::clone::Clone::clone(&self.is_no_builtins),
            native_libraries: ::core::clone::Clone::clone(&self.native_libraries),
            crate_name: ::core::clone::Clone::clone(&self.crate_name),
            used_libraries: ::core::clone::Clone::clone(&self.used_libraries),
            used_crate_source: ::core::clone::Clone::clone(&self.used_crate_source),
            used_crates: ::core::clone::Clone::clone(&self.used_crates),
            dependency_formats: ::core::clone::Clone::clone(&self.dependency_formats),
            eii_linkage: ::core::clone::Clone::clone(&self.eii_linkage),
            windows_subsystem: ::core::clone::Clone::clone(&self.windows_subsystem),
            natvis_debugger_visualizers: ::core::clone::Clone::clone(&self.natvis_debugger_visualizers),
            lint_level_specs: ::core::clone::Clone::clone(&self.lint_level_specs),
            metadata_symbol: ::core::clone::Clone::clone(&self.metadata_symbol),
            symbol_rename_suffix: ::core::clone::Clone::clone(&self.symbol_rename_suffix),
            each_linked_rlib_file_for_lto: ::core::clone::Clone::clone(&self.each_linked_rlib_file_for_lto),
            exported_symbols_for_lto: ::core::clone::Clone::clone(&self.exported_symbols_for_lto),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for CrateInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "CrateInfo target_cpu target_features crate_types exported_symbols linked_symbols local_crate_name compiler_builtins profiler_runtime is_no_builtins native_libraries crate_name used_libraries used_crate_source used_crates dependency_formats eii_linkage windows_subsystem natvis_debugger_visualizers lint_level_specs metadata_symbol symbol_rename_suffix each_linked_rlib_file_for_lto exported_symbols_for_lto",
            &[&self.target_cpu, &self.target_features, &self.crate_types,
                        &self.exported_symbols, &self.linked_symbols,
                        &self.local_crate_name, &self.compiler_builtins,
                        &self.profiler_runtime, &self.is_no_builtins,
                        &self.native_libraries, &self.crate_name,
                        &self.used_libraries, &self.used_crate_source,
                        &self.used_crates, &self.dependency_formats,
                        &self.eii_linkage, &self.windows_subsystem,
                        &self.natvis_debugger_visualizers, &self.lint_level_specs,
                        &self.metadata_symbol, &self.symbol_rename_suffix,
                        &self.each_linked_rlib_file_for_lto,
                        &&self.exported_symbols_for_lto])
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CrateInfo {
            fn encode(&self, __encoder: &mut __E) {
                let CrateInfo {
                        target_cpu: ref __binding_0,
                        target_features: ref __binding_1,
                        crate_types: ref __binding_2,
                        exported_symbols: ref __binding_3,
                        linked_symbols: ref __binding_4,
                        local_crate_name: ref __binding_5,
                        compiler_builtins: ref __binding_6,
                        profiler_runtime: ref __binding_7,
                        is_no_builtins: ref __binding_8,
                        native_libraries: ref __binding_9,
                        crate_name: ref __binding_10,
                        used_libraries: ref __binding_11,
                        used_crate_source: ref __binding_12,
                        used_crates: ref __binding_13,
                        dependency_formats: ref __binding_14,
                        eii_linkage: ref __binding_15,
                        windows_subsystem: ref __binding_16,
                        natvis_debugger_visualizers: ref __binding_17,
                        lint_level_specs: ref __binding_18,
                        metadata_symbol: ref __binding_19,
                        symbol_rename_suffix: ref __binding_20,
                        each_linked_rlib_file_for_lto: ref __binding_21,
                        exported_symbols_for_lto: ref __binding_22 } = *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);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_18,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_19,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_20,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_21,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_22,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CrateInfo {
            fn decode(__decoder: &mut __D) -> Self {
                CrateInfo {
                    target_cpu: ::rustc_serialize::Decodable::decode(__decoder),
                    target_features: ::rustc_serialize::Decodable::decode(__decoder),
                    crate_types: ::rustc_serialize::Decodable::decode(__decoder),
                    exported_symbols: ::rustc_serialize::Decodable::decode(__decoder),
                    linked_symbols: ::rustc_serialize::Decodable::decode(__decoder),
                    local_crate_name: ::rustc_serialize::Decodable::decode(__decoder),
                    compiler_builtins: ::rustc_serialize::Decodable::decode(__decoder),
                    profiler_runtime: ::rustc_serialize::Decodable::decode(__decoder),
                    is_no_builtins: ::rustc_serialize::Decodable::decode(__decoder),
                    native_libraries: ::rustc_serialize::Decodable::decode(__decoder),
                    crate_name: ::rustc_serialize::Decodable::decode(__decoder),
                    used_libraries: ::rustc_serialize::Decodable::decode(__decoder),
                    used_crate_source: ::rustc_serialize::Decodable::decode(__decoder),
                    used_crates: ::rustc_serialize::Decodable::decode(__decoder),
                    dependency_formats: ::rustc_serialize::Decodable::decode(__decoder),
                    eii_linkage: ::rustc_serialize::Decodable::decode(__decoder),
                    windows_subsystem: ::rustc_serialize::Decodable::decode(__decoder),
                    natvis_debugger_visualizers: ::rustc_serialize::Decodable::decode(__decoder),
                    lint_level_specs: ::rustc_serialize::Decodable::decode(__decoder),
                    metadata_symbol: ::rustc_serialize::Decodable::decode(__decoder),
                    symbol_rename_suffix: ::rustc_serialize::Decodable::decode(__decoder),
                    each_linked_rlib_file_for_lto: ::rustc_serialize::Decodable::decode(__decoder),
                    exported_symbols_for_lto: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
267pub struct CrateInfo {
268    pub target_cpu: String,
269    pub target_features: Vec<String>,
270    pub crate_types: Vec<CrateType>,
271    pub exported_symbols: UnordMap<CrateType, Vec<SymbolExport>>,
272    pub linked_symbols: FxIndexMap<CrateType, Vec<(String, SymbolExportKind)>>,
273    pub local_crate_name: Symbol,
274    pub compiler_builtins: Option<CrateNum>,
275    pub profiler_runtime: Option<CrateNum>,
276    pub is_no_builtins: FxHashSet<CrateNum>,
277    pub native_libraries: FxIndexMap<CrateNum, Vec<NativeLib>>,
278    pub crate_name: UnordMap<CrateNum, Symbol>,
279    pub used_libraries: Vec<NativeLib>,
280    pub used_crate_source: UnordMap<CrateNum, Arc<CrateSource>>,
281    pub used_crates: Vec<CrateNum>,
282    pub dependency_formats: Arc<Dependencies>,
283    /// EII implementations used by the link-time duplicate check, so `-Zno-link` can serialize the data needed by a
284    /// later `-Zlink-only` invocation.
285    pub eii_linkage: Vec<EiiLinkageInfo>,
286    pub windows_subsystem: Option<WindowsSubsystemKind>,
287    pub natvis_debugger_visualizers: BTreeSet<DebuggerVisualizerFile>,
288    pub lint_level_specs: CodegenLintLevelSpecs,
289    pub metadata_symbol: String,
290    pub symbol_rename_suffix: String,
291    pub each_linked_rlib_file_for_lto: Vec<PathBuf>,
292    pub exported_symbols_for_lto: Vec<String>,
293}
294
295/// Target-specific options that get set in `sess`/`cfg(...)`.
296///
297/// RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
298pub struct TargetConfig {
299    /// Options to be set in `sess.internal_target_features`.
300    pub internal_target_features: UnordSet<Symbol>,
301    /// Option for `cfg(target_has_reliable_f16)`, true if `f16` basic arithmetic works.
302    pub has_reliable_f16: bool,
303    /// Option for `cfg(target_has_reliable_f16_math)`, true if `f16` math calls work.
304    pub has_reliable_f16_math: bool,
305    /// Option for `cfg(target_has_reliable_f16b)`, presently true if both the ABI
306    /// and LLVM version supports `f16b`.
307    pub has_reliable_f16b: bool,
308    /// Option for `cfg(target_has_reliable_f128)`, true if `f128` basic arithmetic works.
309    pub has_reliable_f128: bool,
310    /// Option for `cfg(target_has_reliable_f128_math)`, true if `f128` math calls work.
311    pub has_reliable_f128_math: bool,
312}
313
314#[derive(const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CompiledModules {
            fn encode(&self, __encoder: &mut __E) {
                let CompiledModules {
                        modules: ref __binding_0, allocator_module: ref __binding_1
                        } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CompiledModules {
            fn decode(__decoder: &mut __D) -> Self {
                CompiledModules {
                    modules: ::rustc_serialize::Decodable::decode(__decoder),
                    allocator_module: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
315pub struct CompiledModules {
316    pub modules: Vec<CompiledModule>,
317    pub allocator_module: Option<CompiledModule>,
318}
319
320pub enum CodegenError {
321    WrongFileType,
322    EmptyVersionNumber,
323    EncodingVersionMismatch { version_array: String, rlink_version: u32 },
324    RustcVersionMismatch { rustc_version: String },
325    CorruptFile,
326}
327
328pub fn provide(providers: &mut Providers) {
329    crate::back::symbol_export::provide(providers);
330    crate::target_features::provide(&mut providers.queries);
331    crate::codegen_attrs::provide(&mut providers.queries);
332}
333
334const RLINK_VERSION: u32 = 1;
335const RLINK_MAGIC: &[u8] = b"rustlink";
336
337impl CompiledModules {
338    pub fn serialize_rlink(
339        sess: &Session,
340        rlink_file: &Path,
341        compiled_modules: &CompiledModules,
342        crate_info: &CrateInfo,
343        metadata: &EncodedMetadata,
344        outputs: &OutputFilenames,
345    ) -> Result<usize, io::Error> {
346        let mut encoder = FileEncoder::new(rlink_file)?;
347        encoder.emit_raw_bytes(RLINK_MAGIC);
348        // `emit_raw_bytes` is used to make sure that the version representation does not depend on
349        // Encoder's inner representation of `u32`.
350        encoder.emit_raw_bytes(&RLINK_VERSION.to_be_bytes());
351        encoder.emit_str(sess.cfg_version);
352        Encodable::encode(compiled_modules, &mut encoder);
353        Encodable::encode(crate_info, &mut encoder);
354        Encodable::encode(metadata, &mut encoder);
355        Encodable::encode(outputs, &mut encoder);
356        encoder.finish().map_err(|(_path, err)| err)
357    }
358
359    pub fn deserialize_rlink(
360        sess: &Session,
361        data: Vec<u8>,
362    ) -> Result<(Self, CrateInfo, EncodedMetadata, OutputFilenames), CodegenError> {
363        // The Decodable machinery is not used here because it panics if the input data is invalid
364        // and because its internal representation may change.
365        if !data.starts_with(RLINK_MAGIC) {
366            return Err(CodegenError::WrongFileType);
367        }
368        let data = &data[RLINK_MAGIC.len()..];
369        if data.len() < 4 {
370            return Err(CodegenError::EmptyVersionNumber);
371        }
372
373        let mut version_array: [u8; 4] = Default::default();
374        version_array.copy_from_slice(&data[..4]);
375        if u32::from_be_bytes(version_array) != RLINK_VERSION {
376            return Err(CodegenError::EncodingVersionMismatch {
377                version_array: String::from_utf8_lossy(&version_array).to_string(),
378                rlink_version: RLINK_VERSION,
379            });
380        }
381
382        let Ok(mut decoder) = MemDecoder::new(&data[4..], 0) else {
383            return Err(CodegenError::CorruptFile);
384        };
385        let rustc_version = decoder.read_str();
386        if rustc_version != sess.cfg_version {
387            return Err(CodegenError::RustcVersionMismatch {
388                rustc_version: rustc_version.to_string(),
389            });
390        }
391
392        let compiled_modules = CompiledModules::decode(&mut decoder);
393        let crate_info = CrateInfo::decode(&mut decoder);
394        let metadata = EncodedMetadata::decode(&mut decoder);
395        let outputs = OutputFilenames::decode(&mut decoder);
396        Ok((compiled_modules, crate_info, metadata, outputs))
397    }
398}
399
400/// A list of lint levels used in codegen.
401///
402/// When using `-Z link-only`, we don't have access to the tcx and must work
403/// solely from the `.rlink` file. `Lint`s are defined too early to be encodeable.
404/// Instead, encode exactly the information we need.
405#[derive(#[automatically_derived]impl ::core::marker::Copy for CodegenLintLevelSpecs {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for CodegenLintLevelSpecs {
}
#[automatically_derived]impl ::core::clone::Clone for CodegenLintLevelSpecs {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<StableLevelSpec>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for CodegenLintLevelSpecs {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "CodegenLintLevelSpecs linker_messages linker_info",
            &self.linker_messages, &&self.linker_info)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CodegenLintLevelSpecs {
            fn encode(&self, __encoder: &mut __E) {
                let CodegenLintLevelSpecs {
                        linker_messages: ref __binding_0,
                        linker_info: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CodegenLintLevelSpecs {
            fn decode(__decoder: &mut __D) -> Self {
                CodegenLintLevelSpecs {
                    linker_messages: ::rustc_serialize::Decodable::decode(__decoder),
                    linker_info: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
406pub struct CodegenLintLevelSpecs {
407    linker_messages: StableLevelSpec,
408    linker_info: StableLevelSpec,
409}
410
411impl CodegenLintLevelSpecs {
412    pub fn from_tcx(tcx: TyCtxt<'_>) -> Self {
413        Self {
414            linker_messages: tcx.lint_level_spec_at_node(LINKER_MESSAGES, CRATE_HIR_ID),
415            linker_info: tcx.lint_level_spec_at_node(LINKER_INFO, CRATE_HIR_ID),
416        }
417    }
418}