pub(crate) struct CrateMetadata {Show 20 fields
blob: MetadataBlob,
root: CrateRoot,
trait_impls: FxIndexMap<(u32, DefIndex), LazyArray<(DefIndex, Option<SimplifiedType>)>>,
incoherent_impls: FxIndexMap<SimplifiedType, LazyArray<DefIndex>>,
raw_proc_macros: Option<&'static [ProcMacro]>,
source_map_import_info: Lock<Vec<Option<ImportedSourceFile>>>,
def_path_hash_map: DefPathHashMapRef<'static>,
expn_hash_map: OnceLock<UnhashMap<ExpnHash, ExpnIndex>>,
alloc_decoding_state: AllocDecodingState,
def_key_cache: Lock<FxHashMap<DefIndex, DefKey>>,
cnum: CrateNum,
cnum_map: IndexVec<CrateNum, CrateNum>,
dependencies: Vec<CrateNum>,
dep_kind: CrateDepKind,
source: Lrc<CrateSource>,
private_dep: bool,
host_hash: Option<Svh>,
used: bool,
hygiene_context: HygieneDecodeContext,
extern_crate: Option<ExternCrate>,
}
Fields§
§blob: MetadataBlob
The primary crate data - binary metadata blob.
root: CrateRoot
Data about the top-level items in a crate, as well as various crate-level metadata.
trait_impls: FxIndexMap<(u32, DefIndex), LazyArray<(DefIndex, Option<SimplifiedType>)>>
Trait impl data. FIXME: Used only from queries and can use query cache, so pre-decoding can probably be avoided.
incoherent_impls: FxIndexMap<SimplifiedType, LazyArray<DefIndex>>
Inherent impls which do not follow the normal coherence rules.
These can be introduced using either #![rustc_coherence_is_core]
or #[rustc_allow_incoherent_impl]
.
raw_proc_macros: Option<&'static [ProcMacro]>
Proc macro descriptions for this crate, if it’s a proc macro crate.
source_map_import_info: Lock<Vec<Option<ImportedSourceFile>>>
Source maps for code from the crate.
def_path_hash_map: DefPathHashMapRef<'static>
For every definition in this crate, maps its DefPathHash
to its DefIndex
.
expn_hash_map: OnceLock<UnhashMap<ExpnHash, ExpnIndex>>
Likewise for ExpnHash.
alloc_decoding_state: AllocDecodingState
Used for decoding interpret::AllocIds in a cached & thread-safe manner.
def_key_cache: Lock<FxHashMap<DefIndex, DefKey>>
Caches decoded DefKey
s.
cnum: CrateNum
ID of this crate, from the current compilation session’s point of view.
cnum_map: IndexVec<CrateNum, CrateNum>
Maps crate IDs as they are were seen from this crate’s compilation sessions into IDs as they are seen from the current compilation session.
dependencies: Vec<CrateNum>
Same ID set as cnum_map
plus maybe some injected crates like panic runtime.
dep_kind: CrateDepKind
How to link (or not link) this crate to the currently compiled crate.
source: Lrc<CrateSource>
Filesystem location of this crate.
private_dep: bool
Whether or not this crate should be consider a private dependency. Used by the ‘exported_private_dependencies’ lint, and for determining whether to emit suggestions that reference this crate.
host_hash: Option<Svh>
The hash for the host proc macro. Used to support -Z dual-proc-macro
.
used: bool
The crate was used non-speculatively.
hygiene_context: HygieneDecodeContext
Additional data used for decoding HygieneData
(e.g. SyntaxContext
and ExpnId
).
Note that we store a HygieneDecodeContext
for each CrateMetadata
. This is
because SyntaxContext
ids are not globally unique, so we need
to track which ids we’ve decoded on a per-crate basis.
extern_crate: Option<ExternCrate>
Information about the extern crate
item or path that caused this crate to be loaded.
If this is None
, then the crate was injected (e.g., by the allocator).
Implementations§
Source§impl CrateMetadata
impl CrateMetadata
pub(crate) fn new( sess: &Session, cstore: &CStore, blob: MetadataBlob, root: CrateRoot, raw_proc_macros: Option<&'static [ProcMacro]>, cnum: CrateNum, cnum_map: IndexVec<CrateNum, CrateNum>, dep_kind: CrateDepKind, source: CrateSource, private_dep: bool, host_hash: Option<Svh>, ) -> CrateMetadata
pub(crate) fn dependencies(&self) -> impl Iterator<Item = CrateNum> + '_
pub(crate) fn add_dependency(&mut self, cnum: CrateNum)
pub(crate) fn update_extern_crate( &mut self, new_extern_crate: ExternCrate, ) -> bool
pub(crate) fn source(&self) -> &CrateSource
pub(crate) fn dep_kind(&self) -> CrateDepKind
pub(crate) fn set_dep_kind(&mut self, dep_kind: CrateDepKind)
pub(crate) fn update_and_private_dep(&mut self, private_dep: bool)
pub(crate) fn used(&self) -> bool
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy>
pub(crate) fn needs_panic_runtime(&self) -> bool
pub(crate) fn is_panic_runtime(&self) -> bool
pub(crate) fn is_profiler_runtime(&self) -> bool
pub(crate) fn needs_allocator(&self) -> bool
pub(crate) fn has_global_allocator(&self) -> bool
pub(crate) fn has_alloc_error_handler(&self) -> bool
pub(crate) fn has_default_lib_allocator(&self) -> bool
pub(crate) fn is_proc_macro_crate(&self) -> bool
pub(crate) fn name(&self) -> Symbol
pub(crate) fn hash(&self) -> Svh
fn num_def_ids(&self) -> usize
fn local_def_id(&self, index: DefIndex) -> DefId
fn reverse_translate_def_id(&self, did: DefId) -> Option<DefId>
Auto Trait Implementations§
impl DynSend for CrateMetadata
impl DynSync for CrateMetadata
impl !Freeze for CrateMetadata
impl !RefUnwindSafe for CrateMetadata
impl !Send for CrateMetadata
impl !Sync for CrateMetadata
impl Unpin for CrateMetadata
impl !UnwindSafe for CrateMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 2880 bytes