Skip to content

Commit 4a2e3bc

Browse files
committed
Change condition in binders to one that is more readable
1 parent 0479287 commit 4a2e3bc

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_infer/src/infer/relate

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::traits::PredicateObligations;
77
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
88
use rustc_middle::ty::GenericArgsRef;
99
use rustc_middle::ty::TyVar;
10-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
10+
use rustc_middle::ty::{self, Ty, TyCtxt};
1111

1212
use rustc_hir::def_id::DefId;
1313
use 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

Comments
 (0)