rustc_middle/middle/
dependency_format.rs

1//! Type definitions for learning about the dependency formats of all upstream
2//! crates (rlibs/dylibs/oh my).
3//!
4//! For all the gory details, see the provider of the `dependency_formats`
5//! query.
6
7// FIXME: move this file to rustc_metadata::dependency_format, but
8// this will introduce circular dependency between rustc_metadata and rustc_middle
9
10use rustc_data_structures::fx::FxIndexMap;
11use rustc_hir::def_id::CrateNum;
12use rustc_index::IndexVec;
13use rustc_macros::{Decodable, Encodable, HashStable};
14use rustc_session::config::CrateType;
15
16/// A list of dependencies for a certain crate type.
17pub type DependencyList = IndexVec<CrateNum, Linkage>;
18
19/// A mapping of all required dependencies for a particular flavor of output.
20///
21/// This is local to the tcx, and is generally relevant to one session.
22pub type Dependencies = FxIndexMap<CrateType, DependencyList>;
23
24#[derive(#[automatically_derived]
impl ::core::marker::Copy for Linkage { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Linkage {
    #[inline]
    fn clone(&self) -> Linkage { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Linkage {
    #[inline]
    fn eq(&self, other: &Linkage) -> 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 Linkage {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Linkage::NotLinked => "NotLinked",
                Linkage::IncludedFromDylib => "IncludedFromDylib",
                Linkage::Static => "Static",
                Linkage::Dynamic => "Dynamic",
            })
    }
}Debug, const _: () =
    {
        impl<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_query_system::ich::StableHashingContext<'__ctx>>
            for Linkage {
            #[inline]
            fn hash_stable(&self,
                __hcx:
                    &mut ::rustc_query_system::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    Linkage::NotLinked => {}
                    Linkage::IncludedFromDylib => {}
                    Linkage::Static => {}
                    Linkage::Dynamic => {}
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Linkage {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Linkage::NotLinked => { 0usize }
                        Linkage::IncludedFromDylib => { 1usize }
                        Linkage::Static => { 2usize }
                        Linkage::Dynamic => { 3usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Linkage::NotLinked => {}
                    Linkage::IncludedFromDylib => {}
                    Linkage::Static => {}
                    Linkage::Dynamic => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Linkage {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Linkage::NotLinked }
                    1usize => { Linkage::IncludedFromDylib }
                    2usize => { Linkage::Static }
                    3usize => { Linkage::Dynamic }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Linkage`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
25pub enum Linkage {
26    NotLinked,
27    IncludedFromDylib,
28    Static,
29    Dynamic,
30}