@@ -6,7 +6,7 @@ use crate::traits::PredicateObligations;
66use rustc_middle:: ty:: relate:: { self , Relate , RelateResult , TypeRelation } ;
77use rustc_middle:: ty:: GenericArgsRef ;
88use rustc_middle:: ty:: TyVar ;
9- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
9+ use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
1010
1111use rustc_hir:: def_id:: DefId ;
1212
@@ -166,7 +166,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
166166 return Ok ( a) ;
167167 }
168168
169- if a. skip_binder ( ) . has_escaping_bound_vars ( ) || b. skip_binder ( ) . has_escaping_bound_vars ( ) {
169+ if let ( Some ( a) , Some ( b) ) = ( a. no_bound_vars ( ) , b. no_bound_vars ( ) ) {
170+ // Fast path for the common case.
171+ self . relate ( a, b) ?;
172+ } else {
170173 // When equating binders, we check that there is a 1-to-1
171174 // correspondence between the bound vars in both types.
172175 //
@@ -188,9 +191,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
188191 let b = infcx. instantiate_binder_with_fresh_vars ( span, HigherRankedType , b) ;
189192 self . with_expected_switched ( |this| this. relate ( b, a) )
190193 } ) ?;
191- } else {
192- // Fast path for the common case.
193- self . relate ( a. skip_binder ( ) , b. skip_binder ( ) ) ?;
194194 }
195195 Ok ( a)
196196 }
0 commit comments