Skip to main content

rustc_crate_store/
cstore.rs

1//! the rustc crate store interface. This also includes types that
2//! are *mostly* used as a part of that interface, but these should
3//! probably get a better home if someone can find one.
4
5use std::any::Any;
6use std::path::PathBuf;
7use std::sync::OnceLock;
8
9use rustc_abi::ExternAbi;
10use rustc_attr_ir::{CfgEntry, PeImportNameType};
11use rustc_data_structures::svh::Svh;
12use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
13use rustc_hir_id::definitions::{DefKey, DefPath, Definitions};
14use rustc_macros::{BlobDecodable, Decodable, Encodable, StableHash};
15use rustc_span::def_id::{
16    CrateNum, DefId, DefPathHash, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap,
17};
18use rustc_span::{Span, Symbol};
19use rustc_structures::NativeLibKind;
20
21/// Where a crate came from on the local filesystem. One of these three options
22/// must be non-None.
23#[derive(#[automatically_derived]impl ::core::marker::StructuralPartialEq for
    CrateSource {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CrateSource {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.dylib == other.dylib && self.rlib == other.rlib &&
                self.rmeta == other.rmeta &&
            self.sdylib_interface == other.sdylib_interface
    }
}PartialEq, #[automatically_derived]impl ::core::clone::Clone for CrateSource {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        CrateSource {
            dylib: ::core::clone::Clone::clone(&self.dylib),
            rlib: ::core::clone::Clone::clone(&self.rlib),
            rmeta: ::core::clone::Clone::clone(&self.rmeta),
            sdylib_interface: ::core::clone::Clone::clone(&self.sdylib_interface),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for CrateSource {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "CrateSource dylib rlib rmeta sdylib_interface", &self.dylib,
            &self.rlib, &self.rmeta, &&self.sdylib_interface)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for CrateSource
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CrateSource {
                        dylib: ref __binding_0,
                        rlib: ref __binding_1,
                        rmeta: ref __binding_2,
                        sdylib_interface: ref __binding_3 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CrateSource {
            fn encode(&self, __encoder: &mut __E) {
                let CrateSource {
                        dylib: ref __binding_0,
                        rlib: ref __binding_1,
                        rmeta: ref __binding_2,
                        sdylib_interface: ref __binding_3 } = *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);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CrateSource {
            fn decode(__decoder: &mut __D) -> Self {
                CrateSource {
                    dylib: ::rustc_serialize::Decodable::decode(__decoder),
                    rlib: ::rustc_serialize::Decodable::decode(__decoder),
                    rmeta: ::rustc_serialize::Decodable::decode(__decoder),
                    sdylib_interface: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
24pub struct CrateSource {
25    pub dylib: Option<PathBuf>,
26    pub rlib: Option<PathBuf>,
27    pub rmeta: Option<PathBuf>,
28    pub sdylib_interface: Option<PathBuf>,
29}
30/// Flags about where a crate came from on the local filesystem.
31///
32/// Used to avoid introducing dependencies on absolute paths for incrementals when
33/// the caller only needs to know if a field of `CrateSource` is_some.
34#[derive(#[automatically_derived]impl ::core::marker::StructuralPartialEq for
    CrateSourceFlags {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CrateSourceFlags {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for CrateSourceFlags {
}
#[automatically_derived]impl ::core::clone::Clone for CrateSourceFlags {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<u8>;
        *self
    }
}Clone, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            CrateSourceFlags {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CrateSourceFlags(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, #[automatically_derived]impl ::core::marker::Copy for CrateSourceFlags { }Copy)]
35pub struct CrateSourceFlags(u8);
36impl CrateSourceFlags {
    #[allow(deprecated, non_upper_case_globals,)]
    pub const DYLIB: Self = Self::from_bits_retain(1 << 0);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const RLIB: Self = Self::from_bits_retain(1 << 1);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const RMETA: Self = Self::from_bits_retain(1 << 2);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const SDYLIB_INTERFACE: Self = Self::from_bits_retain(1 << 3);
}
impl ::bitflags::Flags for CrateSourceFlags {
    const FLAGS: &'static [::bitflags::Flag<CrateSourceFlags>] =
        &[{

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

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

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

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("SDYLIB_INTERFACE",
                            CrateSourceFlags::SDYLIB_INTERFACE)
                    }];
    type Bits = u8;
    fn bits(&self) -> u8 { CrateSourceFlags::bits(self) }
    fn from_bits_retain(bits: u8) -> CrateSourceFlags {
        CrateSourceFlags::from_bits_retain(bits)
    }
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[allow(dead_code, deprecated, unused_attributes)]
        impl CrateSourceFlags {
            /// 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 =
                            <CrateSourceFlags as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CrateSourceFlags as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CrateSourceFlags as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <CrateSourceFlags 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 == "DYLIB" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CrateSourceFlags::DYLIB.bits()));
                    }
                };
                ;
                {
                    if name == "RLIB" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CrateSourceFlags::RLIB.bits()));
                    }
                };
                ;
                {
                    if name == "RMETA" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CrateSourceFlags::RMETA.bits()));
                    }
                };
                ;
                {
                    if name == "SDYLIB_INTERFACE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(CrateSourceFlags::SDYLIB_INTERFACE.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 CrateSourceFlags {
            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 CrateSourceFlags {
            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 CrateSourceFlags {
            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 CrateSourceFlags {
            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 CrateSourceFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: CrateSourceFlags) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            CrateSourceFlags {
            /// 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 CrateSourceFlags {
            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
            CrateSourceFlags {
            /// 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 CrateSourceFlags {
            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
            CrateSourceFlags {
            /// 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 CrateSourceFlags {
            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 CrateSourceFlags
            {
            /// 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 CrateSourceFlags {
            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<CrateSourceFlags> for
            CrateSourceFlags {
            /// 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<CrateSourceFlags>
            for CrateSourceFlags {
            /// 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 CrateSourceFlags {
            /// 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<CrateSourceFlags> {
                ::bitflags::iter::Iter::__private_const_new(<CrateSourceFlags
                        as ::bitflags::Flags>::FLAGS,
                    CrateSourceFlags::from_bits_retain(self.bits()),
                    CrateSourceFlags::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<CrateSourceFlags> {
                ::bitflags::iter::IterNames::__private_const_new(<CrateSourceFlags
                        as ::bitflags::Flags>::FLAGS,
                    CrateSourceFlags::from_bits_retain(self.bits()),
                    CrateSourceFlags::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            CrateSourceFlags {
            type Item = CrateSourceFlags;
            type IntoIter = ::bitflags::iter::Iter<CrateSourceFlags>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
37    impl CrateSourceFlags: u8 {
38        const DYLIB = 1 << 0;
39        const RLIB = 1 << 1;
40        const RMETA = 1 << 2;
41        const SDYLIB_INTERFACE = 1 << 3;
42    }
43}
44impl ::std::fmt::Debug for CrateSourceFlags {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        ::bitflags::parser::to_writer(self, f)
    }
}rustc_data_structures::external_bitflags_debug! { CrateSourceFlags }
45
46impl CrateSource {
47    #[inline]
48    pub fn paths(&self) -> impl Iterator<Item = &PathBuf> {
49        self.dylib.iter().chain(self.rlib.iter()).chain(self.rmeta.iter())
50    }
51
52    #[inline]
53    pub fn flags(&self) -> CrateSourceFlags {
54        let mut flags = CrateSourceFlags::empty();
55
56        if self.dylib.is_some() {
57            flags |= CrateSourceFlags::DYLIB;
58        }
59        if self.rlib.is_some() {
60            flags |= CrateSourceFlags::RLIB;
61        }
62        if self.rmeta.is_some() {
63            flags |= CrateSourceFlags::RMETA;
64        }
65        if self.sdylib_interface.is_some() {
66            flags |= CrateSourceFlags::SDYLIB_INTERFACE;
67        }
68
69        flags
70    }
71}
72
73#[derive(const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CrateDepKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        CrateDepKind::MacrosOnly => { 0usize }
                        CrateDepKind::Conditional => { 1usize }
                        CrateDepKind::Unconditional => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
            for CrateDepKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { CrateDepKind::MacrosOnly }
                    1usize => { CrateDepKind::Conditional }
                    2usize => { CrateDepKind::Unconditional }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CrateDepKind`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };BlobDecodable, #[automatically_derived]impl ::core::marker::Copy for CrateDepKind { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for CrateDepKind {
}
#[automatically_derived]impl ::core::clone::Clone for CrateDepKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::cmp::Ord for CrateDepKind {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
            &::core::intrinsics::discriminant_value(other))
    }
}Ord, #[automatically_derived]impl ::core::cmp::PartialOrd for CrateDepKind {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl ::core::cmp::Eq for CrateDepKind { }Eq, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    CrateDepKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CrateDepKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::fmt::Debug for CrateDepKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CrateDepKind::MacrosOnly => "MacrosOnly",
                CrateDepKind::Conditional => "Conditional",
                CrateDepKind::Unconditional => "Unconditional",
            })
    }
}Debug)]
74#[derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for CrateDepKind
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CrateDepKind::MacrosOnly =>
                        0u8.stable_hash(__hcx, __hasher),
                    CrateDepKind::Conditional =>
                        1u8.stable_hash(__hcx, __hasher),
                    CrateDepKind::Unconditional =>
                        2u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    CrateDepKind::MacrosOnly => {}
                    CrateDepKind::Conditional => {}
                    CrateDepKind::Unconditional => {}
                }
            }
        }
    };StableHash)]
75pub enum CrateDepKind {
76    /// A dependency that is only used for its macros.
77    MacrosOnly,
78    /// A dependency that is injected into the crate graph but which only
79    /// sometimes needs to actually be linked in, e.g., the injected panic runtime.
80    Conditional,
81    /// A dependency that is required by an rlib version of this crate.
82    /// Ordinary `extern crate`s as well as most injected dependencies result
83    /// in `Unconditional` dependencies.
84    Unconditional,
85}
86
87impl CrateDepKind {
88    #[inline]
89    pub fn macros_only(self) -> bool {
90        match self {
91            CrateDepKind::MacrosOnly => true,
92            CrateDepKind::Conditional | CrateDepKind::Unconditional => false,
93        }
94    }
95}
96
97#[derive(#[automatically_derived]impl ::core::marker::Copy for LinkagePreference { }Copy, #[automatically_derived]impl ::core::fmt::Debug for LinkagePreference {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                LinkagePreference::RequireDynamic => "RequireDynamic",
                LinkagePreference::RequireStatic => "RequireStatic",
            })
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    LinkagePreference {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LinkagePreference {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for LinkagePreference {
}
#[automatically_derived]impl ::core::clone::Clone for LinkagePreference {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for LinkagePreference {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        LinkagePreference::RequireDynamic => { 0usize }
                        LinkagePreference::RequireStatic => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
            for LinkagePreference {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { LinkagePreference::RequireDynamic }
                    1usize => { LinkagePreference::RequireStatic }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `LinkagePreference`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };BlobDecodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            LinkagePreference {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    LinkagePreference::RequireDynamic =>
                        0u8.stable_hash(__hcx, __hasher),
                    LinkagePreference::RequireStatic =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    LinkagePreference::RequireDynamic => {}
                    LinkagePreference::RequireStatic => {}
                }
            }
        }
    };StableHash)]
98pub enum LinkagePreference {
99    RequireDynamic,
100    RequireStatic,
101}
102
103#[derive(#[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_fields_finish(f,
            "NativeLib kind name cfg foreign_module verbatim dll_imports",
            &[&self.kind, &self.name, &self.cfg, &self.foreign_module,
                        &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,
                        foreign_module: ref __binding_3,
                        verbatim: ref __binding_4,
                        dll_imports: ref __binding_5 } = *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);
            }
        }
    };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),
                    foreign_module: ::rustc_serialize::Decodable::decode(__decoder),
                    verbatim: ::rustc_serialize::Decodable::decode(__decoder),
                    dll_imports: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for NativeLib {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    NativeLib {
                        kind: ref __binding_0,
                        name: ref __binding_1,
                        cfg: ref __binding_2,
                        foreign_module: ref __binding_3,
                        verbatim: ref __binding_4,
                        dll_imports: ref __binding_5 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                        { __binding_4.stable_hash(__hcx, __hasher); }
                        { __binding_5.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
104pub struct NativeLib {
105    pub kind: NativeLibKind,
106    pub name: Symbol,
107    pub cfg: Option<CfgEntry>,
108    pub foreign_module: Option<DefId>,
109    pub verbatim: Option<bool>,
110    pub dll_imports: Vec<DllImport>,
111}
112
113impl NativeLib {
114    pub fn has_modifiers(&self) -> bool {
115        self.verbatim.is_some() || self.kind.has_modifiers()
116    }
117
118    pub fn wasm_import_module(&self) -> Option<Symbol> {
119        if self.kind == NativeLibKind::WasmImportModule { Some(self.name) } else { None }
120    }
121}
122
123#[derive(#[automatically_derived]impl ::core::clone::Clone for DllImport {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        DllImport {
            name: ::core::clone::Clone::clone(&self.name),
            import_name_type: ::core::clone::Clone::clone(&self.import_name_type),
            calling_convention: ::core::clone::Clone::clone(&self.calling_convention),
            span: ::core::clone::Clone::clone(&self.span),
            symbol_type: ::core::clone::Clone::clone(&self.symbol_type),
            size: ::core::clone::Clone::clone(&self.size),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for DllImport {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "DllImport name import_name_type calling_convention span symbol_type size",
            &[&self.name, &self.import_name_type, &self.calling_convention,
                        &self.span, &self.symbol_type, &&self.size])
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for DllImport {
            fn encode(&self, __encoder: &mut __E) {
                let DllImport {
                        name: ref __binding_0,
                        import_name_type: ref __binding_1,
                        calling_convention: ref __binding_2,
                        span: ref __binding_3,
                        symbol_type: ref __binding_4,
                        size: ref __binding_5 } = *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);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for DllImport {
            fn decode(__decoder: &mut __D) -> Self {
                DllImport {
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    import_name_type: ::rustc_serialize::Decodable::decode(__decoder),
                    calling_convention: ::rustc_serialize::Decodable::decode(__decoder),
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                    symbol_type: ::rustc_serialize::Decodable::decode(__decoder),
                    size: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for DllImport {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    DllImport {
                        name: ref __binding_0,
                        import_name_type: ref __binding_1,
                        calling_convention: ref __binding_2,
                        span: ref __binding_3,
                        symbol_type: ref __binding_4,
                        size: ref __binding_5 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                        { __binding_4.stable_hash(__hcx, __hasher); }
                        { __binding_5.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
124pub struct DllImport {
125    pub name: Symbol,
126    pub import_name_type: Option<PeImportNameType>,
127    /// Calling convention for the function.
128    ///
129    /// On x86_64, this is always `DllCallingConvention::C`; on i686, it can be any
130    /// of the values, and we use `DllCallingConvention::C` to represent `"cdecl"`.
131    pub calling_convention: DllCallingConvention,
132    /// Span of import's "extern" declaration; used for diagnostics.
133    pub span: Span,
134    pub symbol_type: DllImportSymbolType,
135    pub size: rustc_abi::Size,
136}
137
138#[derive(#[automatically_derived]impl ::core::marker::Copy for DllImportSymbolType { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for DllImportSymbolType {
}
#[automatically_derived]impl ::core::clone::Clone for DllImportSymbolType {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for DllImportSymbolType {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                DllImportSymbolType::Function => "Function",
                DllImportSymbolType::Static => "Static",
                DllImportSymbolType::ThreadLocal => "ThreadLocal",
            })
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for DllImportSymbolType {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        DllImportSymbolType::Function => { 0usize }
                        DllImportSymbolType::Static => { 1usize }
                        DllImportSymbolType::ThreadLocal => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for DllImportSymbolType {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { DllImportSymbolType::Function }
                    1usize => { DllImportSymbolType::Static }
                    2usize => { DllImportSymbolType::ThreadLocal }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `DllImportSymbolType`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            DllImportSymbolType {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    DllImportSymbolType::Function =>
                        0u8.stable_hash(__hcx, __hasher),
                    DllImportSymbolType::Static =>
                        1u8.stable_hash(__hcx, __hasher),
                    DllImportSymbolType::ThreadLocal =>
                        2u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    DllImportSymbolType::Function => {}
                    DllImportSymbolType::Static => {}
                    DllImportSymbolType::ThreadLocal => {}
                }
            }
        }
    };StableHash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    DllImportSymbolType {
}
#[automatically_derived]impl ::core::cmp::PartialEq for DllImportSymbolType {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq)]
139pub enum DllImportSymbolType {
140    Function,
141    Static,
142    ThreadLocal,
143}
144
145impl DllImport {
146    pub fn ordinal(&self) -> Option<u16> {
147        if let Some(PeImportNameType::Ordinal(ordinal)) = self.import_name_type {
148            Some(ordinal)
149        } else {
150            None
151        }
152    }
153
154    pub fn is_missing_decorations(&self) -> bool {
155        self.import_name_type == Some(PeImportNameType::Undecorated)
156            || self.import_name_type == Some(PeImportNameType::NoPrefix)
157    }
158}
159
160/// Calling convention for a function defined in an external library.
161///
162/// The usize value, where present, indicates the size of the function's argument list
163/// in bytes.
164#[derive(#[automatically_derived]impl ::core::clone::Clone for DllCallingConvention {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        match self {
            Self::C => DllCallingConvention::C,
            Self::Stdcall(__self_0) =>
                DllCallingConvention::Stdcall(::core::clone::Clone::clone(__self_0)),
            Self::Fastcall(__self_0) =>
                DllCallingConvention::Fastcall(::core::clone::Clone::clone(__self_0)),
            Self::Vectorcall(__self_0) =>
                DllCallingConvention::Vectorcall(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    DllCallingConvention {
}
#[automatically_derived]impl ::core::cmp::PartialEq for DllCallingConvention {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Stdcall(__self_0), Self::Stdcall(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Fastcall(__self_0), Self::Fastcall(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Vectorcall(__self_0), Self::Vectorcall(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl ::core::fmt::Debug for DllCallingConvention {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::C => ::core::fmt::Formatter::write_str(f, "C"),
            Self::Stdcall(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Stdcall", &__self_0),
            Self::Fastcall(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Fastcall", &__self_0),
            Self::Vectorcall(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Vectorcall", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for DllCallingConvention {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        DllCallingConvention::C => { 0usize }
                        DllCallingConvention::Stdcall(ref __binding_0) => { 1usize }
                        DllCallingConvention::Fastcall(ref __binding_0) => {
                            2usize
                        }
                        DllCallingConvention::Vectorcall(ref __binding_0) => {
                            3usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    DllCallingConvention::C => {}
                    DllCallingConvention::Stdcall(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    DllCallingConvention::Fastcall(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    DllCallingConvention::Vectorcall(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for DllCallingConvention {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { DllCallingConvention::C }
                    1usize => {
                        DllCallingConvention::Stdcall(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        DllCallingConvention::Fastcall(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    3usize => {
                        DllCallingConvention::Vectorcall(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `DllCallingConvention`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            DllCallingConvention {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    DllCallingConvention::C => 0u8.stable_hash(__hcx, __hasher),
                    DllCallingConvention::Stdcall(ref __binding_0) =>
                        1u8.stable_hash(__hcx, __hasher),
                    DllCallingConvention::Fastcall(ref __binding_0) =>
                        2u8.stable_hash(__hcx, __hasher),
                    DllCallingConvention::Vectorcall(ref __binding_0) =>
                        3u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    DllCallingConvention::C => {}
                    DllCallingConvention::Stdcall(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    DllCallingConvention::Fastcall(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    DllCallingConvention::Vectorcall(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
165pub enum DllCallingConvention {
166    C,
167    Stdcall(usize),
168    Fastcall(usize),
169    Vectorcall(usize),
170}
171
172#[derive(#[automatically_derived]impl ::core::clone::Clone for ForeignModule {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        ForeignModule {
            foreign_items: ::core::clone::Clone::clone(&self.foreign_items),
            def_id: ::core::clone::Clone::clone(&self.def_id),
            abi: ::core::clone::Clone::clone(&self.abi),
        }
    }
}Clone, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ForeignModule {
            fn encode(&self, __encoder: &mut __E) {
                let ForeignModule {
                        foreign_items: ref __binding_0,
                        def_id: ref __binding_1,
                        abi: 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 ForeignModule {
            fn decode(__decoder: &mut __D) -> Self {
                ForeignModule {
                    foreign_items: ::rustc_serialize::Decodable::decode(__decoder),
                    def_id: ::rustc_serialize::Decodable::decode(__decoder),
                    abi: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            ForeignModule {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ForeignModule {
                        foreign_items: ref __binding_0,
                        def_id: ref __binding_1,
                        abi: ref __binding_2 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, #[automatically_derived]impl ::core::fmt::Debug for ForeignModule {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "ForeignModule foreign_items def_id abi", &self.foreign_items,
            &self.def_id, &&self.abi)
    }
}Debug)]
173pub struct ForeignModule {
174    pub foreign_items: Vec<DefId>,
175    pub def_id: DefId,
176    pub abi: ExternAbi,
177}
178
179#[derive(#[automatically_derived]impl ::core::marker::Copy for ExternCrate { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ExternCrate {
}
#[automatically_derived]impl ::core::clone::Clone for ExternCrate {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<ExternCrateSource>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<usize>;
        let _: ::core::clone::AssertParamIsClone<CrateNum>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ExternCrate {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "ExternCrate src span path_len dependency_of", &self.src,
            &self.span, &self.path_len, &&self.dependency_of)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for ExternCrate
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ExternCrate {
                        src: ref __binding_0,
                        span: ref __binding_1,
                        path_len: ref __binding_2,
                        dependency_of: ref __binding_3 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
180pub struct ExternCrate {
181    pub src: ExternCrateSource,
182
183    /// span of the extern crate that caused this to be loaded
184    pub span: Span,
185
186    /// Number of links to reach the extern;
187    /// used to select the extern with the shortest path
188    pub path_len: usize,
189
190    /// Crate that depends on this crate
191    pub dependency_of: CrateNum,
192}
193
194impl ExternCrate {
195    /// If true, then this crate is the crate named by the extern
196    /// crate referenced above. If false, then this crate is a dep
197    /// of the crate.
198    #[inline]
199    pub fn is_direct(&self) -> bool {
200        self.dependency_of == LOCAL_CRATE
201    }
202
203    #[inline]
204    pub fn rank(&self) -> impl PartialOrd {
205        // Prefer:
206        // - direct extern crate to indirect
207        // - shorter paths to longer
208        (self.is_direct(), !self.path_len)
209    }
210}
211
212#[derive(#[automatically_derived]impl ::core::marker::Copy for ExternCrateSource { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ExternCrateSource {
}
#[automatically_derived]impl ::core::clone::Clone for ExternCrateSource {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ExternCrateSource {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Extern(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Extern", &__self_0),
            Self::Path => ::core::fmt::Formatter::write_str(f, "Path"),
        }
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            ExternCrateSource {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ExternCrateSource::Extern(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    ExternCrateSource::Path => 1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    ExternCrateSource::Extern(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    ExternCrateSource::Path => {}
                }
            }
        }
    };StableHash)]
213pub enum ExternCrateSource {
214    /// Crate is loaded by `extern crate`.
215    Extern(
216        /// def_id of the item in the current crate that caused
217        /// this crate to be loaded; note that there could be multiple
218        /// such ids
219        DefId,
220    ),
221    /// Crate is implicitly loaded by a path resolving through extern prelude.
222    Path,
223}
224
225/// A store of Rust crates, through which their metadata can be accessed.
226///
227/// Note that this trait should probably not be expanding today. All new
228/// functionality should be driven through queries instead!
229///
230/// If you find a method on this trait named `{name}_untracked` it signifies
231/// that it's *not* tracked for dependency information throughout compilation
232/// (it'd break incremental compilation) and should only be called pre-HIR (e.g.
233/// during resolve)
234pub trait CrateStore: std::fmt::Debug {
235    fn as_any(&self) -> &dyn Any;
236    fn untracked_as_any(&mut self) -> &mut dyn Any;
237
238    // Foreign definitions.
239    // This information is safe to access, since it's hashed as part of the DefPathHash, which incr.
240    // comp. uses to identify a DefId.
241    fn def_key(&self, def: DefId) -> DefKey;
242    fn def_path(&self, def: DefId) -> DefPath;
243    fn def_path_hash(&self, def: DefId) -> DefPathHash;
244
245    // This information is safe to access, since it's hashed as part of the StableCrateId, which
246    // incr. comp. uses to identify a CrateNum.
247    fn crate_name(&self, cnum: CrateNum) -> Symbol;
248    fn stable_crate_id(&self, cnum: CrateNum) -> StableCrateId;
249}
250
251pub type CrateStoreDyn = dyn CrateStore + sync::DynSync + sync::DynSend;
252
253pub struct Untracked {
254    pub cstore: FreezeLock<Box<CrateStoreDyn>>,
255    /// Reference span for definitions.
256    pub source_span: AppendOnlyIndexVec<LocalDefId, Span>,
257    pub definitions: FreezeLock<Definitions>,
258    /// The interned [StableCrateId]s.
259    pub stable_crate_ids: FreezeLock<StableCrateIdMap>,
260    /// The hash of the local crate as computed in metadata encoding.
261    pub local_crate_hash: OnceLock<Svh>,
262}
263
264impl Untracked {
265    /// Freezes the cstore and, with it, the `StableCrateId` map, making reads of
266    /// both lock-free. The cstore is frozen first so any in-flight crate loading
267    /// (which writes the map) finishes before the map is frozen.
268    pub fn freeze_cstore(&self) {
269        self.cstore.freeze();
270        self.stable_crate_ids.freeze();
271    }
272}