File tree 3 files changed +11
-7
lines changed
3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,8 @@ impl<'hir> Map<'hir> {
225
225
self . tcx . definitions_untracked ( ) . iter_local_def_id ( )
226
226
}
227
227
228
- pub fn opt_def_kind ( self , local_def_id : LocalDefId ) -> Option < DefKind > {
228
+ /// Do not call this function directly. The query should be called.
229
+ pub ( super ) fn opt_def_kind ( self , local_def_id : LocalDefId ) -> Option < DefKind > {
229
230
let hir_id = self . local_def_id_to_hir_id ( local_def_id) ;
230
231
let def_kind = match self . find ( hir_id) ? {
231
232
Node :: Item ( item) => match item. kind {
Original file line number Diff line number Diff line change @@ -467,7 +467,7 @@ impl<'tcx> EmbargoVisitor<'tcx> {
467
467
}
468
468
469
469
let macro_module_def_id = self . tcx . local_parent ( local_def_id) ;
470
- if self . tcx . hir ( ) . opt_def_kind ( macro_module_def_id) != Some ( DefKind :: Mod ) {
470
+ if self . tcx . opt_def_kind ( macro_module_def_id) != Some ( DefKind :: Mod ) {
471
471
// The macro's parent doesn't correspond to a `mod`, return early (#63164, #65252).
472
472
return ;
473
473
}
Original file line number Diff line number Diff line change @@ -282,11 +282,14 @@ macro_rules! define_queries {
282
282
} else {
283
283
Some ( key. default_span( * tcx) )
284
284
} ;
285
- // Use `tcx.hir().opt_def_kind()` to reduce the chance of
286
- // accidentally triggering an infinite query loop.
287
- let def_kind = key. key_as_def_id( )
288
- . and_then( |def_id| def_id. as_local( ) )
289
- . and_then( |def_id| tcx. hir( ) . opt_def_kind( def_id) ) ;
285
+ let def_kind = if kind == dep_graph:: DepKind :: opt_def_kind {
286
+ // Try to avoid infinite recursion.
287
+ None
288
+ } else {
289
+ key. key_as_def_id( )
290
+ . and_then( |def_id| def_id. as_local( ) )
291
+ . and_then( |def_id| tcx. opt_def_kind( def_id) )
292
+ } ;
290
293
let hash = || {
291
294
let mut hcx = tcx. create_stable_hashing_context( ) ;
292
295
let mut hasher = StableHasher :: new( ) ;
You can’t perform that action at this time.
0 commit comments