@@ -4,12 +4,13 @@ use std::ops::ControlFlow;
4
4
5
5
use crate :: ty:: {
6
6
visit:: TypeVisitable , AliasTy , Const , ConstKind , DefIdTree , InferConst , InferTy , Opaque ,
7
- PolyTraitPredicate , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor ,
7
+ PolyTraitPredicate , Projection , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor ,
8
8
} ;
9
9
10
10
use rustc_data_structures:: fx:: FxHashMap ;
11
11
use rustc_errors:: { Applicability , Diagnostic , DiagnosticArgValue , IntoDiagnosticArg } ;
12
12
use rustc_hir as hir;
13
+ use rustc_hir:: def:: DefKind ;
13
14
use rustc_hir:: def_id:: DefId ;
14
15
use rustc_hir:: WherePredicate ;
15
16
use rustc_span:: Span ;
@@ -443,7 +444,7 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
443
444
type BreakTy = ( ) ;
444
445
445
446
fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
446
- match t. kind ( ) {
447
+ match * t. kind ( ) {
447
448
Infer ( InferTy :: TyVar ( _) ) if self . infer_suggestable => { }
448
449
449
450
FnDef ( ..)
@@ -458,9 +459,9 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
458
459
}
459
460
460
461
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 ( )
464
465
&& parent_opaque_def_id == def_id
465
466
{
466
467
// Okay
@@ -469,6 +470,12 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
469
470
}
470
471
}
471
472
473
+ Alias ( Projection , AliasTy { def_id, .. } ) => {
474
+ if self . tcx . def_kind ( def_id) != DefKind :: AssocTy {
475
+ return ControlFlow :: Break ( ( ) ) ;
476
+ }
477
+ }
478
+
472
479
Param ( param) => {
473
480
// FIXME: It would be nice to make this not use string manipulation,
474
481
// but it's pretty hard to do this, since `ty::ParamTy` is missing
0 commit comments