From 4a2e3bc2b0b014b15e3c49d92379db130008dcad Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 8 Feb 2024 11:27:29 -0300 Subject: [PATCH] Change condition in binders to one that is more readable --- compiler/rustc_infer/src/infer/relate/equate.rs | 10 +++++----- 1 file 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 1635695a588b2..1617a062ea0cc 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) }