@@ -7,7 +7,7 @@ use crate::traits::PredicateObligations;
77use rustc_middle:: ty:: relate:: { self , Relate , RelateResult , TypeRelation } ;
88use rustc_middle:: ty:: GenericArgsRef ;
99use rustc_middle:: ty:: TyVar ;
10- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
10+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
1111
1212use rustc_hir:: def_id:: DefId ;
1313use rustc_span:: Span ;
@@ -168,7 +168,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
168168 return Ok ( a) ;
169169 }
170170
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 {
172175 // When equating binders, we check that there is a 1-to-1
173176 // correspondence between the bound vars in both types.
174177 //
@@ -193,9 +196,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
193196 let b = infcx. instantiate_binder_with_fresh_vars ( span, HigherRankedType , b) ;
194197 self . relate ( a, b)
195198 } ) ?;
196- } else {
197- // Fast path for the common case.
198- self . relate ( a. skip_binder ( ) , b. skip_binder ( ) ) ?;
199199 }
200200 Ok ( a)
201201 }
0 commit comments