@@ -7,7 +7,7 @@ use crate::traits::PredicateObligations;
7
7
use rustc_middle:: ty:: relate:: { self , Relate , RelateResult , TypeRelation } ;
8
8
use rustc_middle:: ty:: GenericArgsRef ;
9
9
use rustc_middle:: ty:: TyVar ;
10
- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
10
+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
11
11
12
12
use rustc_hir:: def_id:: DefId ;
13
13
use rustc_span:: Span ;
@@ -168,7 +168,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
168
168
return Ok ( a) ;
169
169
}
170
170
171
- if a. skip_binder ( ) . has_escaping_bound_vars ( ) || b. skip_binder ( ) . has_escaping_bound_vars ( ) {
171
+ if let ( Some ( a) , Some ( b) ) = ( a. no_bound_vars ( ) , b. no_bound_vars ( ) ) {
172
+ // Fast path for the common case.
173
+ self . relate ( a, b) ?;
174
+ } else {
172
175
// When equating binders, we check that there is a 1-to-1
173
176
// correspondence between the bound vars in both types.
174
177
//
@@ -193,9 +196,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
193
196
let b = infcx. instantiate_binder_with_fresh_vars ( span, HigherRankedType , b) ;
194
197
self . relate ( a, b)
195
198
} ) ?;
196
- } else {
197
- // Fast path for the common case.
198
- self . relate ( a. skip_binder ( ) , b. skip_binder ( ) ) ?;
199
199
}
200
200
Ok ( a)
201
201
}
0 commit comments