@@ -4,12 +4,13 @@ use std::ops::ControlFlow;
44
55use crate :: ty:: {
66 visit:: TypeVisitable , AliasTy , Const , ConstKind , DefIdTree , InferConst , InferTy , Opaque ,
7- PolyTraitPredicate , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor ,
7+ PolyTraitPredicate , Projection , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor ,
88} ;
99
1010use rustc_data_structures:: fx:: FxHashMap ;
1111use rustc_errors:: { Applicability , Diagnostic , DiagnosticArgValue , IntoDiagnosticArg } ;
1212use rustc_hir as hir;
13+ use rustc_hir:: def:: DefKind ;
1314use rustc_hir:: def_id:: DefId ;
1415use rustc_hir:: WherePredicate ;
1516use rustc_span:: Span ;
@@ -443,7 +444,7 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
443444 type BreakTy = ( ) ;
444445
445446 fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
446- match t. kind ( ) {
447+ match * t. kind ( ) {
447448 Infer ( InferTy :: TyVar ( _) ) if self . infer_suggestable => { }
448449
449450 FnDef ( ..)
@@ -458,9 +459,9 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
458459 }
459460
460461 Alias ( Opaque , AliasTy { def_id, .. } ) => {
461- let parent = self . tcx . parent ( * def_id) ;
462- if let hir :: def :: DefKind :: TyAlias | hir :: def :: DefKind :: AssocTy = self . tcx . def_kind ( parent)
463- && let Alias ( Opaque , AliasTy { def_id : parent_opaque_def_id, .. } ) = self . tcx . type_of ( parent) . kind ( )
462+ let parent = self . tcx . parent ( def_id) ;
463+ if let DefKind :: TyAlias | DefKind :: AssocTy = self . tcx . def_kind ( parent)
464+ && let Alias ( Opaque , AliasTy { def_id : parent_opaque_def_id, .. } ) = * self . tcx . type_of ( parent) . kind ( )
464465 && parent_opaque_def_id == def_id
465466 {
466467 // Okay
@@ -469,6 +470,12 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
469470 }
470471 }
471472
473+ Alias ( Projection , AliasTy { def_id, .. } ) => {
474+ if self . tcx . def_kind ( def_id) != DefKind :: AssocTy {
475+ return ControlFlow :: Break ( ( ) ) ;
476+ }
477+ }
478+
472479 Param ( param) => {
473480 // FIXME: It would be nice to make this not use string manipulation,
474481 // but it's pretty hard to do this, since `ty::ParamTy` is missing
0 commit comments