diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2024-02-08 11:27:29 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2024-02-29 15:27:59 -0300 |
| commit | 4a2e3bc2b0b014b15e3c49d92379db130008dcad (patch) | |
| tree | 5fd48192150865741e77f48e3d719ca0dd4d93f5 | |
| parent | 0479287a38ccef11c84f694a9105de8120f6a6b4 (diff) | |
| download | rust-4a2e3bc2b0b014b15e3c49d92379db130008dcad.tar.gz rust-4a2e3bc2b0b014b15e3c49d92379db130008dcad.zip | |
Change condition in binders to one that is more readable
| -rw-r--r-- | compiler/rustc_infer/src/infer/relate/equate.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_infer/src/infer/relate/equate.rs b/compiler/rustc_infer/src/infer/relate/equate.rs index 1635695a588..1617a062ea0 100644 --- a/compiler/rustc_infer/src/infer/relate/equate.rs +++ b/compiler/rustc_infer/src/infer/relate/equate.rs @@ -7,7 +7,7 @@ use crate::traits::PredicateObligations; use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation}; use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::TyVar; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; +use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_hir::def_id::DefId; use rustc_span::Span; @@ -168,7 +168,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> { return Ok(a); } - if a.skip_binder().has_escaping_bound_vars() || b.skip_binder().has_escaping_bound_vars() { + if let (Some(a), Some(b)) = (a.no_bound_vars(), b.no_bound_vars()) { + // Fast path for the common case. + self.relate(a, b)?; + } else { // When equating binders, we check that there is a 1-to-1 // correspondence between the bound vars in both types. // @@ -193,9 +196,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> { let b = infcx.instantiate_binder_with_fresh_vars(span, HigherRankedType, b); self.relate(a, b) })?; - } else { - // Fast path for the common case. - self.relate(a.skip_binder(), b.skip_binder())?; } Ok(a) } |
