@@ -37,50 +37,61 @@ crate struct ImportedSourceFile {
37
37
}
38
38
39
39
pub 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.
45
41
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 > > ,
50
42
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 ---
53
44
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.
58
50
crate root : schema:: CrateRoot < ' static > ,
59
-
60
51
/// For each definition in this crate, we encode a key. When the
61
52
/// crate is loaded, we read all the keys and put them in this
62
53
/// hashmap, which gives the reverse mapping. This allows us to
63
54
/// quickly retrace a `DefPath`, which is needed for incremental
64
55
/// compilation support.
65
56
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.
67
60
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 ---
68
74
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.
69
83
crate dep_kind : Lock < DepKind > ,
84
+ /// Filesystem location of this crate.
70
85
crate source : CrateSource ,
71
-
72
86
/// Whether or not this crate should be consider a private dependency
73
87
/// for purposes of the 'exported_private_dependencies' lint
74
88
crate private_dep : bool ,
75
89
76
- crate raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
90
+ // --- Data used only for improving diagnostics ---
77
91
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 > > ,
84
95
}
85
96
86
97
pub struct CStore {
0 commit comments