File tree Expand file tree Collapse file tree 2 files changed +16
-30
lines changed
Expand file tree Collapse file tree 2 files changed +16
-30
lines changed Original file line number Diff line number Diff line change @@ -448,30 +448,6 @@ macro_rules! define_callbacks {
448448 ) *
449449 }
450450 }
451-
452- pub fn def_kind( & self , tcx: TyCtxt <' tcx>) -> Option <DefKind > {
453- // This is used to reduce code generation as it
454- // can be reused for queries with the same key type.
455- fn inner<' tcx>( key: & impl $crate:: query:: QueryKey , tcx: TyCtxt <' tcx>)
456- -> Option <DefKind >
457- {
458- key
459- . key_as_def_id( )
460- . and_then( |def_id| def_id. as_local( ) )
461- . map( |def_id| tcx. def_kind( def_id) )
462- }
463-
464- if let TaggedQueryKey :: def_kind( ..) = self {
465- // Try to avoid infinite recursion.
466- return None
467- }
468-
469- match self {
470- $(
471- TaggedQueryKey :: $name( key) => inner( key, tcx) ,
472- ) *
473- }
474- }
475451 }
476452
477453 /// Holds a `QueryVTable` for each query.
Original file line number Diff line number Diff line change @@ -481,13 +481,23 @@ pub(crate) fn create_cycle_error<'tcx>(
481481 usage : usage. tagged_key . description ( tcx) ,
482482 } ) ;
483483
484- let alias = if frames
485- . iter ( )
486- . all ( |frame| frame. tagged_key . def_kind ( tcx) == Some ( DefKind :: TyAlias ) )
487- {
484+ let is_all_def_kind = |def_kind| {
485+ // Trivial type alias and trait alias cycles consists of `type_of` and
486+ // `explicit_implied_predicates_of` queries, so we just check just these here.
487+ frames. iter ( ) . all ( |frame| match frame. tagged_key {
488+ TaggedQueryKey :: type_of( def_id)
489+ | TaggedQueryKey :: explicit_implied_predicates_of( def_id)
490+ if tcx. def_kind ( def_id) == def_kind =>
491+ {
492+ true
493+ }
494+ _ => false ,
495+ } )
496+ } ;
497+
498+ let alias = if is_all_def_kind ( DefKind :: TyAlias ) {
488499 Some ( crate :: error:: Alias :: Ty )
489- } else if frames. iter ( ) . all ( |frame| frame. tagged_key . def_kind ( tcx) == Some ( DefKind :: TraitAlias ) )
490- {
500+ } else if is_all_def_kind ( DefKind :: TraitAlias ) {
491501 Some ( crate :: error:: Alias :: Trait )
492502 } else {
493503 None
You can’t perform that action at this time.
0 commit comments