@@ -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,14 +154,8 @@ impl<'hir> Map<'hir> {
154
154
self . tcx . hir_crate ( ( ) )
155
155
}
156
156
157
- #[ inline]
158
- pub fn definitions ( & self ) -> & ' hir Definitions {
159
- // Accessing the definitions is ok, since all its contents are tracked by the query system.
160
- & self . tcx . untracked_resolutions . definitions
161
- }
162
-
163
157
pub fn def_key ( & self , def_id : LocalDefId ) -> DefKey {
164
- // Accessing the definitions is ok, since all its contents are tracked by the query system .
158
+ // Accessing the DefKey is ok, since it is part of DefPathHash .
165
159
self . tcx . untracked_resolutions . definitions . def_key ( def_id)
166
160
}
167
161
@@ -170,10 +164,16 @@ impl<'hir> Map<'hir> {
170
164
}
171
165
172
166
pub fn def_path ( & self , def_id : LocalDefId ) -> DefPath {
173
- // Accessing the definitions is ok, since all its contents are tracked by the query system .
167
+ // Accessing the DefPath is ok, since it is part of DefPathHash .
174
168
self . tcx . untracked_resolutions . definitions . def_path ( def_id)
175
169
}
176
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)
175
+ }
176
+
177
177
#[ inline]
178
178
pub fn local_def_id ( & self , hir_id : HirId ) -> LocalDefId {
179
179
self . opt_local_def_id ( hir_id) . unwrap_or_else ( || {
@@ -187,18 +187,20 @@ impl<'hir> Map<'hir> {
187
187
188
188
#[ inline]
189
189
pub fn opt_local_def_id ( & self , hir_id : HirId ) -> Option < LocalDefId > {
190
- // Accessing the definitions is ok, since all its contents are tracked by the query system.
190
+ // FIXME(#85914) is this access safe for incr. comp.?
191
191
self . tcx . untracked_resolutions . definitions . opt_hir_id_to_local_def_id ( hir_id)
192
192
}
193
193
194
194
#[ inline]
195
195
pub fn local_def_id_to_hir_id ( & self , def_id : LocalDefId ) -> HirId {
196
- // Accessing the definitions is ok, since all its contents are tracked by the query system.
196
+ // FIXME(#85914) is this access safe for incr. comp.?
197
197
self . tcx . untracked_resolutions . definitions . local_def_id_to_hir_id ( def_id)
198
198
}
199
199
200
200
pub fn iter_local_def_id ( & self ) -> impl Iterator < Item = LocalDefId > + ' _ {
201
- // Accessing the definitions is ok, since all its contents are tracked by the query system.
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 ( ( ) ) ;
202
204
self . tcx . untracked_resolutions . definitions . iter_local_def_id ( )
203
205
}
204
206
0 commit comments