Skip to main content

rustc_session/
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;
7
8use rustc_abi::ExternAbi;
9use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
10use rustc_hir::attrs::{CfgEntry, NativeLibKind, PeImportNameType};
11use rustc_hir::def_id::{
12    CrateNum, DefId, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap,
13};
14use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions};
15use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic};
16use rustc_span::{Span, Symbol};
17
18// lonely orphan structs and enums looking for a better home
19
20/// Where a crate came from on the local filesystem. One of these three options
21/// must be non-None.
22#[derive(#[automatically_derived]
impl ::core::cmp::PartialEq for CrateSource {
    #[inline]
    fn eq(&self, other: &CrateSource) -> 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]
    fn clone(&self) -> CrateSource {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "CrateSource",
            "dylib", &self.dylib, "rlib", &self.rlib, "rmeta", &self.rmeta,
            "sdylib_interface", &&self.sdylib_interface)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for CrateSource where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    CrateSource {
                        dylib: ref __binding_0,
                        rlib: ref __binding_1,
                        rmeta: ref __binding_2,
                        sdylib_interface: ref __binding_3 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CrateSource {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    CrateSource {
                        dylib: ref __binding_0,
                        rlib: ref __binding_1,
                        rmeta: ref __binding_2,
                        sdylib_interface: ref __binding_3 } => {
                        ::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)]
23pub struct CrateSource {
24    pub dylib: Option<PathBuf>,
25    pub rlib: Option<PathBuf>,
26    pub rmeta: Option<PathBuf>,
27    pub sdylib_interface: Option<PathBuf>,
28}
29
30impl CrateSource {
31    #[inline]
32    pub fn paths(&self) -> impl Iterator<Item = &PathBuf> {
33        self.dylib.iter().chain(self.rlib.iter()).chain(self.rmeta.iter())
34    }
35}
36
37#[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);
                match *self {
                    CrateDepKind::MacrosOnly => {}
                    CrateDepKind::Conditional => {}
                    CrateDepKind::Unconditional => {}
                }
            }
        }
    };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]
impl ::core::clone::Clone for CrateDepKind {
    #[inline]
    fn clone(&self) -> CrateDepKind { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::Ord for CrateDepKind {
    #[inline]
    fn cmp(&self, other: &CrateDepKind) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord, #[automatically_derived]
impl ::core::cmp::PartialOrd for CrateDepKind {
    #[inline]
    fn partial_cmp(&self, other: &CrateDepKind)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for CrateDepKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for CrateDepKind {
    #[inline]
    fn eq(&self, other: &CrateDepKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for CrateDepKind {
    #[inline]
    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)]
38#[derive(const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for CrateDepKind where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    CrateDepKind::MacrosOnly => {}
                    CrateDepKind::Conditional => {}
                    CrateDepKind::Unconditional => {}
                }
            }
        }
    };HashStable_Generic)]
39pub enum CrateDepKind {
40    /// A dependency that is only used for its macros.
41    MacrosOnly,
42    /// A dependency that is injected into the crate graph but which only
43    /// sometimes needs to actually be linked in, e.g., the injected panic runtime.
44    Conditional,
45    /// A dependency that is required by an rlib version of this crate.
46    /// Ordinary `extern crate`s as well as most injected dependencies result
47    /// in `Unconditional` dependencies.
48    Unconditional,
49}
50
51impl CrateDepKind {
52    #[inline]
53    pub fn macros_only(self) -> bool {
54        match self {
55            CrateDepKind::MacrosOnly => true,
56            CrateDepKind::Conditional | CrateDepKind::Unconditional => false,
57        }
58    }
59}
60
61#[derive(#[automatically_derived]
impl ::core::marker::Copy for LinkagePreference { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for LinkagePreference {
    #[inline]
    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::cmp::PartialEq for LinkagePreference {
    #[inline]
    fn eq(&self, other: &LinkagePreference) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::clone::Clone for LinkagePreference {
    #[inline]
    fn clone(&self) -> LinkagePreference { *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);
                match *self {
                    LinkagePreference::RequireDynamic => {}
                    LinkagePreference::RequireStatic => {}
                }
            }
        }
    };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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LinkagePreference where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    LinkagePreference::RequireDynamic => {}
                    LinkagePreference::RequireStatic => {}
                }
            }
        }
    };HashStable_Generic)]
62pub enum LinkagePreference {
63    RequireDynamic,
64    RequireStatic,
65}
66
67#[derive(#[automatically_derived]
impl ::core::fmt::Debug for NativeLib {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["kind", "name", "filename", "cfg", "foreign_module", "verbatim",
                        "dll_imports"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.kind, &self.name, &self.filename, &self.cfg,
                        &self.foreign_module, &self.verbatim, &&self.dll_imports];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "NativeLib",
            names, values)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for NativeLib {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    NativeLib {
                        kind: ref __binding_0,
                        name: ref __binding_1,
                        filename: ref __binding_2,
                        cfg: ref __binding_3,
                        foreign_module: ref __binding_4,
                        verbatim: ref __binding_5,
                        dll_imports: ref __binding_6 } => {
                        ::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);
                    }
                }
            }
        }
    };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),
                    filename: ::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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for NativeLib where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    NativeLib {
                        kind: ref __binding_0,
                        name: ref __binding_1,
                        filename: ref __binding_2,
                        cfg: ref __binding_3,
                        foreign_module: ref __binding_4,
                        verbatim: ref __binding_5,
                        dll_imports: ref __binding_6 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
68pub struct NativeLib {
69    pub kind: NativeLibKind,
70    pub name: Symbol,
71    /// If packed_bundled_libs enabled, actual filename of library is stored.
72    pub filename: Option<Symbol>,
73    pub cfg: Option<CfgEntry>,
74    pub foreign_module: Option<DefId>,
75    pub verbatim: Option<bool>,
76    pub dll_imports: Vec<DllImport>,
77}
78
79impl NativeLib {
80    pub fn has_modifiers(&self) -> bool {
81        self.verbatim.is_some() || self.kind.has_modifiers()
82    }
83
84    pub fn wasm_import_module(&self) -> Option<Symbol> {
85        if self.kind == NativeLibKind::WasmImportModule { Some(self.name) } else { None }
86    }
87}
88
89#[derive(#[automatically_derived]
impl ::core::clone::Clone for DllImport {
    #[inline]
    fn clone(&self) -> DllImport {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["name", "import_name_type", "calling_convention", "span",
                        "symbol_type", "size"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.name, &self.import_name_type, &self.calling_convention,
                        &self.span, &self.symbol_type, &&self.size];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "DllImport",
            names, values)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for DllImport {
            fn encode(&self, __encoder: &mut __E) {
                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 } => {
                        ::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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for DllImport where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
90pub struct DllImport {
91    pub name: Symbol,
92    pub import_name_type: Option<PeImportNameType>,
93    /// Calling convention for the function.
94    ///
95    /// On x86_64, this is always `DllCallingConvention::C`; on i686, it can be any
96    /// of the values, and we use `DllCallingConvention::C` to represent `"cdecl"`.
97    pub calling_convention: DllCallingConvention,
98    /// Span of import's "extern" declaration; used for diagnostics.
99    pub span: Span,
100    pub symbol_type: DllImportSymbolType,
101    pub size: rustc_abi::Size,
102}
103
104#[derive(#[automatically_derived]
impl ::core::marker::Copy for DllImportSymbolType { }Copy, #[automatically_derived]
impl ::core::clone::Clone for DllImportSymbolType {
    #[inline]
    fn clone(&self) -> DllImportSymbolType { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DllImportSymbolType {
    #[inline]
    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);
                match *self {
                    DllImportSymbolType::Function => {}
                    DllImportSymbolType::Static => {}
                    DllImportSymbolType::ThreadLocal => {}
                }
            }
        }
    };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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for DllImportSymbolType where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    DllImportSymbolType::Function => {}
                    DllImportSymbolType::Static => {}
                    DllImportSymbolType::ThreadLocal => {}
                }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::cmp::PartialEq for DllImportSymbolType {
    #[inline]
    fn eq(&self, other: &DllImportSymbolType) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq)]
105pub enum DllImportSymbolType {
106    Function,
107    Static,
108    ThreadLocal,
109}
110
111impl DllImport {
112    pub fn ordinal(&self) -> Option<u16> {
113        if let Some(PeImportNameType::Ordinal(ordinal)) = self.import_name_type {
114            Some(ordinal)
115        } else {
116            None
117        }
118    }
119
120    pub fn is_missing_decorations(&self) -> bool {
121        self.import_name_type == Some(PeImportNameType::Undecorated)
122            || self.import_name_type == Some(PeImportNameType::NoPrefix)
123    }
124}
125
126/// Calling convention for a function defined in an external library.
127///
128/// The usize value, where present, indicates the size of the function's argument list
129/// in bytes.
130#[derive(#[automatically_derived]
impl ::core::clone::Clone for DllCallingConvention {
    #[inline]
    fn clone(&self) -> DllCallingConvention {
        match self {
            DllCallingConvention::C => DllCallingConvention::C,
            DllCallingConvention::Stdcall(__self_0) =>
                DllCallingConvention::Stdcall(::core::clone::Clone::clone(__self_0)),
            DllCallingConvention::Fastcall(__self_0) =>
                DllCallingConvention::Fastcall(::core::clone::Clone::clone(__self_0)),
            DllCallingConvention::Vectorcall(__self_0) =>
                DllCallingConvention::Vectorcall(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for DllCallingConvention {
    #[inline]
    fn eq(&self, other: &DllCallingConvention) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (DllCallingConvention::Stdcall(__self_0),
                    DllCallingConvention::Stdcall(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (DllCallingConvention::Fastcall(__self_0),
                    DllCallingConvention::Fastcall(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (DllCallingConvention::Vectorcall(__self_0),
                    DllCallingConvention::Vectorcall(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for DllCallingConvention {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            DllCallingConvention::C =>
                ::core::fmt::Formatter::write_str(f, "C"),
            DllCallingConvention::Stdcall(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Stdcall", &__self_0),
            DllCallingConvention::Fastcall(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Fastcall", &__self_0),
            DllCallingConvention::Vectorcall(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for DllCallingConvention where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    DllCallingConvention::C => {}
                    DllCallingConvention::Stdcall(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    DllCallingConvention::Fastcall(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    DllCallingConvention::Vectorcall(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
131pub enum DllCallingConvention {
132    C,
133    Stdcall(usize),
134    Fastcall(usize),
135    Vectorcall(usize),
136}
137
138#[derive(#[automatically_derived]
impl ::core::clone::Clone for ForeignModule {
    #[inline]
    fn clone(&self) -> ForeignModule {
        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) {
                match *self {
                    ForeignModule {
                        foreign_items: ref __binding_0,
                        def_id: ref __binding_1,
                        abi: ref __binding_2 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                    }
                }
            }
        }
    };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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ForeignModule where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ForeignModule {
                        foreign_items: ref __binding_0,
                        def_id: ref __binding_1,
                        abi: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::fmt::Debug for ForeignModule {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "ForeignModule",
            "foreign_items", &self.foreign_items, "def_id", &self.def_id,
            "abi", &&self.abi)
    }
}Debug)]
139pub struct ForeignModule {
140    pub foreign_items: Vec<DefId>,
141    pub def_id: DefId,
142    pub abi: ExternAbi,
143}
144
145#[derive(#[automatically_derived]
impl ::core::marker::Copy for ExternCrate { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ExternCrate {
    #[inline]
    fn clone(&self) -> ExternCrate {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "ExternCrate",
            "src", &self.src, "span", &self.span, "path_len", &self.path_len,
            "dependency_of", &&self.dependency_of)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ExternCrate where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ExternCrate {
                        src: ref __binding_0,
                        span: ref __binding_1,
                        path_len: ref __binding_2,
                        dependency_of: ref __binding_3 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
146pub struct ExternCrate {
147    pub src: ExternCrateSource,
148
149    /// span of the extern crate that caused this to be loaded
150    pub span: Span,
151
152    /// Number of links to reach the extern;
153    /// used to select the extern with the shortest path
154    pub path_len: usize,
155
156    /// Crate that depends on this crate
157    pub dependency_of: CrateNum,
158}
159
160impl ExternCrate {
161    /// If true, then this crate is the crate named by the extern
162    /// crate referenced above. If false, then this crate is a dep
163    /// of the crate.
164    #[inline]
165    pub fn is_direct(&self) -> bool {
166        self.dependency_of == LOCAL_CRATE
167    }
168
169    #[inline]
170    pub fn rank(&self) -> impl PartialOrd {
171        // Prefer:
172        // - direct extern crate to indirect
173        // - shorter paths to longer
174        (self.is_direct(), !self.path_len)
175    }
176}
177
178#[derive(#[automatically_derived]
impl ::core::marker::Copy for ExternCrateSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ExternCrateSource {
    #[inline]
    fn clone(&self) -> ExternCrateSource {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ExternCrateSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ExternCrateSource::Extern(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Extern",
                    &__self_0),
            ExternCrateSource::Path =>
                ::core::fmt::Formatter::write_str(f, "Path"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ExternCrateSource where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    ExternCrateSource::Extern(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExternCrateSource::Path => {}
                }
            }
        }
    };HashStable_Generic)]
179pub enum ExternCrateSource {
180    /// Crate is loaded by `extern crate`.
181    Extern(
182        /// def_id of the item in the current crate that caused
183        /// this crate to be loaded; note that there could be multiple
184        /// such ids
185        DefId,
186    ),
187    /// Crate is implicitly loaded by a path resolving through extern prelude.
188    Path,
189}
190
191/// A store of Rust crates, through which their metadata can be accessed.
192///
193/// Note that this trait should probably not be expanding today. All new
194/// functionality should be driven through queries instead!
195///
196/// If you find a method on this trait named `{name}_untracked` it signifies
197/// that it's *not* tracked for dependency information throughout compilation
198/// (it'd break incremental compilation) and should only be called pre-HIR (e.g.
199/// during resolve)
200pub trait CrateStore: std::fmt::Debug {
201    fn as_any(&self) -> &dyn Any;
202    fn untracked_as_any(&mut self) -> &mut dyn Any;
203
204    // Foreign definitions.
205    // This information is safe to access, since it's hashed as part of the DefPathHash, which incr.
206    // comp. uses to identify a DefId.
207    fn def_key(&self, def: DefId) -> DefKey;
208    fn def_path(&self, def: DefId) -> DefPath;
209    fn def_path_hash(&self, def: DefId) -> DefPathHash;
210
211    // This information is safe to access, since it's hashed as part of the StableCrateId, which
212    // incr. comp. uses to identify a CrateNum.
213    fn crate_name(&self, cnum: CrateNum) -> Symbol;
214    fn stable_crate_id(&self, cnum: CrateNum) -> StableCrateId;
215}
216
217pub type CrateStoreDyn = dyn CrateStore + sync::DynSync + sync::DynSend;
218
219pub struct Untracked {
220    pub cstore: FreezeLock<Box<CrateStoreDyn>>,
221    /// Reference span for definitions.
222    pub source_span: AppendOnlyIndexVec<LocalDefId, Span>,
223    pub definitions: FreezeLock<Definitions>,
224    /// The interned [StableCrateId]s.
225    pub stable_crate_ids: FreezeLock<StableCrateIdMap>,
226}