@@ -37,50 +37,61 @@ crate struct ImportedSourceFile {
3737}
3838
3939pub struct CrateMetadata {
40- /// Information about the extern crate that caused this crate to
41- /// be loaded. If this is `None`, then the crate was injected
42- /// (e.g., by the allocator)
43- crate extern_crate : Lock < Option < ExternCrate > > ,
44-
40+ /// The primary crate data - binary metadata blob.
4541 crate blob : MetadataBlob ,
46- crate cnum_map : CrateNumMap ,
47- crate cnum : CrateNum ,
48- crate dependencies : Lock < Vec < CrateNum > > ,
49- crate source_map_import_info : RwLock < Vec < ImportedSourceFile > > ,
5042
51- /// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
52- crate alloc_decoding_state : AllocDecodingState ,
43+ // --- Some data pre-decoded from the metadata blob, usually for performance ---
5344
54- // NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
55- // lifetime is only used behind `Lazy`, and therefore acts like an
56- // universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
57- // is being used to decode those values.
45+ /// Properties of the whole crate.
46+ /// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
47+ /// lifetime is only used behind `Lazy`, and therefore acts like an
48+ /// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
49+ /// is being used to decode those values.
5850 crate root : schema:: CrateRoot < ' static > ,
59-
6051 /// For each definition in this crate, we encode a key. When the
6152 /// crate is loaded, we read all the keys and put them in this
6253 /// hashmap, which gives the reverse mapping. This allows us to
6354 /// quickly retrace a `DefPath`, which is needed for incremental
6455 /// compilation support.
6556 crate def_path_table : Lrc < DefPathTable > ,
66-
57+ /// Trait impl data.
58+ /// FIXME: Used only from queries and can use query cache,
59+ /// so pre-decoding can probably be avoided.
6760 crate trait_impls : FxHashMap < ( u32 , DefIndex ) , schema:: Lazy < [ DefIndex ] > > ,
61+ /// Proc macro descriptions for this crate, if it's a proc macro crate.
62+ crate raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
63+ /// Source maps for code from the crate.
64+ crate source_map_import_info : RwLock < Vec < ImportedSourceFile > > ,
65+ /// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
66+ crate alloc_decoding_state : AllocDecodingState ,
67+ /// The `DepNodeIndex` of the `DepNode` representing this upstream crate.
68+ /// It is initialized on the first access in `get_crate_dep_node_index()`.
69+ /// Do not access the value directly, as it might not have been initialized yet.
70+ /// The field must always be initialized to `DepNodeIndex::INVALID`.
71+ crate dep_node_index : AtomicCell < DepNodeIndex > ,
72+
73+ // --- Other significant crate properties ---
6874
75+ /// ID of this crate, from the current compilation session's point of view.
76+ crate cnum : CrateNum ,
77+ /// Maps crate IDs as they are were seen from this crate's compilation sessions into
78+ /// IDs as they are seen from the current compilation session.
79+ crate cnum_map : CrateNumMap ,
80+ /// Same ID set as `cnum_map` plus maybe some injected crates like panic runtime.
81+ crate dependencies : Lock < Vec < CrateNum > > ,
82+ /// How to link (or not link) this crate to the currently compiled crate.
6983 crate dep_kind : Lock < DepKind > ,
84+ /// Filesystem location of this crate.
7085 crate source : CrateSource ,
71-
7286 /// Whether or not this crate should be consider a private dependency
7387 /// for purposes of the 'exported_private_dependencies' lint
7488 crate private_dep : bool ,
7589
76- crate raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
90+ // --- Data used only for improving diagnostics ---
7791
78- /// The `DepNodeIndex` of the `DepNode` representing this upstream crate.
79- /// It is initialized on the first access in `get_crate_dep_node_index()`.
80- /// Do not access the value directly, as it might not have been initialized
81- /// yet.
82- /// The field must always be initialized to `DepNodeIndex::INVALID`.
83- crate dep_node_index : AtomicCell < DepNodeIndex > ,
92+ /// Information about the `extern crate` item or path that caused this crate to be loaded.
93+ /// If this is `None`, then the crate was injected (e.g., by the allocator).
94+ crate extern_crate : Lock < Option < ExternCrate > > ,
8495}
8596
8697pub struct CStore {
0 commit comments