Skip to content

Commit ae2fdfa

Browse files
committed
Change condition in binders to one that is more readable
1 parent f8eb71f commit ae2fdfa

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • compiler/rustc_infer/src/infer/relate

compiler/rustc_infer/src/infer/relate/equate.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::traits::PredicateObligations;
66
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
77
use rustc_middle::ty::GenericArgsRef;
88
use rustc_middle::ty::TyVar;
9-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
9+
use rustc_middle::ty::{self, Ty, TyCtxt};
1010

1111
use 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

Comments
 (0)