@@ -9,7 +9,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
9
9
use rustc_data_structures:: svh:: Svh ;
10
10
use rustc_hir:: def:: { DefKind , Res } ;
11
11
use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
12
- use rustc_hir:: definitions:: { DefKey , DefPath , Definitions } ;
12
+ use rustc_hir:: definitions:: { DefKey , DefPath , DefPathHash } ;
13
13
use rustc_hir:: intravisit;
14
14
use rustc_hir:: intravisit:: Visitor ;
15
15
use rustc_hir:: itemlikevisit:: ItemLikeVisitor ;
@@ -154,21 +154,24 @@ impl<'hir> Map<'hir> {
154
154
self . tcx . hir_crate ( ( ) )
155
155
}
156
156
157
- #[ inline]
158
- pub fn definitions ( & self ) -> & ' hir Definitions {
159
- & self . tcx . definitions
160
- }
161
-
162
157
pub fn def_key ( & self , def_id : LocalDefId ) -> DefKey {
163
- self . tcx . definitions . def_key ( def_id)
158
+ // Accessing the DefKey is ok, since it is part of DefPathHash.
159
+ self . tcx . untracked_resolutions . definitions . def_key ( def_id)
164
160
}
165
161
166
162
pub fn def_path_from_hir_id ( & self , id : HirId ) -> Option < DefPath > {
167
163
self . opt_local_def_id ( id) . map ( |def_id| self . def_path ( def_id) )
168
164
}
169
165
170
166
pub fn def_path ( & self , def_id : LocalDefId ) -> DefPath {
171
- self . tcx . definitions . def_path ( def_id)
167
+ // Accessing the DefPath is ok, since it is part of DefPathHash.
168
+ self . tcx . untracked_resolutions . definitions . def_path ( def_id)
169
+ }
170
+
171
+ #[ inline]
172
+ pub fn def_path_hash ( self , def_id : LocalDefId ) -> DefPathHash {
173
+ // Accessing the DefPathHash is ok, it is incr. comp. stable.
174
+ self . tcx . untracked_resolutions . definitions . def_path_hash ( def_id)
172
175
}
173
176
174
177
#[ inline]
@@ -184,16 +187,21 @@ impl<'hir> Map<'hir> {
184
187
185
188
#[ inline]
186
189
pub fn opt_local_def_id ( & self , hir_id : HirId ) -> Option < LocalDefId > {
187
- self . tcx . definitions . opt_hir_id_to_local_def_id ( hir_id)
190
+ // FIXME(#85914) is this access safe for incr. comp.?
191
+ self . tcx . untracked_resolutions . definitions . opt_hir_id_to_local_def_id ( hir_id)
188
192
}
189
193
190
194
#[ inline]
191
195
pub fn local_def_id_to_hir_id ( & self , def_id : LocalDefId ) -> HirId {
192
- self . tcx . definitions . local_def_id_to_hir_id ( def_id)
196
+ // FIXME(#85914) is this access safe for incr. comp.?
197
+ self . tcx . untracked_resolutions . definitions . local_def_id_to_hir_id ( def_id)
193
198
}
194
199
195
200
pub fn iter_local_def_id ( & self ) -> impl Iterator < Item = LocalDefId > + ' _ {
196
- self . tcx . definitions . iter_local_def_id ( )
201
+ // Create a dependency to the crate to be sure we reexcute this when the amount of
202
+ // definitions change.
203
+ self . tcx . ensure ( ) . hir_crate ( ( ) ) ;
204
+ self . tcx . untracked_resolutions . definitions . iter_local_def_id ( )
197
205
}
198
206
199
207
pub fn opt_def_kind ( & self , local_def_id : LocalDefId ) -> Option < DefKind > {
@@ -932,9 +940,15 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> {
932
940
pub ( super ) fn index_hir < ' tcx > ( tcx : TyCtxt < ' tcx > , ( ) : ( ) ) -> & ' tcx IndexedHir < ' tcx > {
933
941
let _prof_timer = tcx. sess . prof . generic_activity ( "build_hir_map" ) ;
934
942
943
+ // We can access untracked state since we are an eval_always query.
935
944
let hcx = tcx. create_stable_hashing_context ( ) ;
936
- let mut collector =
937
- NodeCollector :: root ( tcx. sess , & * * tcx. arena , tcx. untracked_crate , & tcx. definitions , hcx) ;
945
+ let mut collector = NodeCollector :: root (
946
+ tcx. sess ,
947
+ & * * tcx. arena ,
948
+ tcx. untracked_crate ,
949
+ & tcx. untracked_resolutions . definitions ,
950
+ hcx,
951
+ ) ;
938
952
intravisit:: walk_crate ( & mut collector, tcx. untracked_crate ) ;
939
953
940
954
let map = collector. finalize_and_compute_crate_hash ( ) ;
@@ -944,14 +958,15 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> &'tcx IndexedHir<'tc
944
958
pub ( super ) fn crate_hash ( tcx : TyCtxt < ' _ > , crate_num : CrateNum ) -> Svh {
945
959
assert_eq ! ( crate_num, LOCAL_CRATE ) ;
946
960
961
+ // We can access untracked state since we are an eval_always query.
947
962
let mut hcx = tcx. create_stable_hashing_context ( ) ;
948
963
949
964
let mut hir_body_nodes: Vec < _ > = tcx
950
965
. index_hir ( ( ) )
951
966
. map
952
967
. iter_enumerated ( )
953
968
. filter_map ( |( def_id, hod) | {
954
- let def_path_hash = tcx. definitions . def_path_hash ( def_id) ;
969
+ let def_path_hash = tcx. untracked_resolutions . definitions . def_path_hash ( def_id) ;
955
970
let mut hasher = StableHasher :: new ( ) ;
956
971
hod. as_ref ( ) ?. hash_stable ( & mut hcx, & mut hasher) ;
957
972
AttributeMap { map : & tcx. untracked_crate . attrs , prefix : def_id }
@@ -968,7 +983,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
968
983
} ,
969
984
) ;
970
985
971
- let upstream_crates = upstream_crates ( & * tcx. cstore ) ;
986
+ let upstream_crates = upstream_crates ( & * tcx. untracked_resolutions . cstore ) ;
972
987
973
988
// We hash the final, remapped names of all local source files so we
974
989
// don't have to include the path prefix remapping commandline args.
0 commit comments