@@ -93,37 +93,42 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
93
93
} ;
94
94
95
95
// Guard against `<T as Trait<?0>>::Assoc = ?0>`.
96
- struct ContainsTerm < ' tcx > {
96
+ struct ContainsTerm < ' a , ' tcx > {
97
97
term : ty:: Term < ' tcx > ,
98
+ infcx : & ' a InferCtxt < ' tcx > ,
98
99
}
99
- impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for ContainsTerm < ' tcx > {
100
+ impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for ContainsTerm < ' _ , ' tcx > {
100
101
type BreakTy = ( ) ;
101
102
fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
102
- if t. needs_infer ( ) {
103
- if ty:: Term :: from ( t) == self . term {
104
- ControlFlow :: Break ( ( ) )
105
- } else {
106
- t. super_visit_with ( self )
107
- }
103
+ if let Some ( vid) = t. ty_vid ( )
104
+ && let ty:: TermKind :: Ty ( term) = self . term . unpack ( )
105
+ && let Some ( term_vid) = term. ty_vid ( )
106
+ && self . infcx . root_var ( vid) == self . infcx . root_var ( term_vid)
107
+ {
108
+ ControlFlow :: Break ( ( ) )
109
+ } else if t. has_non_region_infer ( ) {
110
+ t. super_visit_with ( self )
108
111
} else {
109
112
ControlFlow :: Continue ( ( ) )
110
113
}
111
114
}
112
115
113
116
fn visit_const ( & mut self , c : ty:: Const < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
114
- if c. needs_infer ( ) {
115
- if ty:: Term :: from ( c) == self . term {
116
- ControlFlow :: Break ( ( ) )
117
- } else {
118
- c. super_visit_with ( self )
119
- }
117
+ if let ty:: ConstKind :: Infer ( ty:: InferConst :: Var ( vid) ) = c. kind ( )
118
+ && let ty:: TermKind :: Const ( term) = self . term . unpack ( )
119
+ && let ty:: ConstKind :: Infer ( ty:: InferConst :: Var ( term_vid) ) = term. kind ( )
120
+ && self . infcx . root_const_var ( vid) == self . infcx . root_const_var ( term_vid)
121
+ {
122
+ ControlFlow :: Break ( ( ) )
123
+ } else if c. has_non_region_infer ( ) {
124
+ c. super_visit_with ( self )
120
125
} else {
121
126
ControlFlow :: Continue ( ( ) )
122
127
}
123
128
}
124
129
}
125
130
126
- let mut visitor = ContainsTerm { term : goal. predicate . term } ;
131
+ let mut visitor = ContainsTerm { infcx : self . infcx , term : goal. predicate . term } ;
127
132
128
133
term_is_infer
129
134
&& goal. predicate . projection_ty . visit_with ( & mut visitor) . is_continue ( )
0 commit comments