Skip to content

Commit 3d7637e

Browse files
committed
correctly handle escaping bound variables
1 parent 0f7bf5d commit 3d7637e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/librustc_infer/infer/combine.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use rustc_hir::def_id::DefId;
3939
use rustc_middle::ty::error::TypeError;
4040
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
4141
use rustc_middle::ty::subst::SubstsRef;
42-
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt};
42+
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeFoldable};
4343
use rustc_middle::ty::{IntType, UintType};
4444
use rustc_span::{Span, DUMMY_SP};
4545

@@ -165,11 +165,19 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
165165
return self.unify_const_variable(!a_is_expected, vid, a);
166166
}
167167
(ty::ConstKind::Unevaluated(..), _) if self.tcx.features().const_generics => {
168-
relation.const_equate_obligation(a, b);
168+
// FIXME(#59490): Need to remove the leak check to accomodate
169+
// escaping bound variables here.
170+
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
171+
relation.const_equate_obligation(a, b);
172+
}
169173
return Ok(b);
170174
}
171175
(_, ty::ConstKind::Unevaluated(..)) if self.tcx.features().const_generics => {
172-
relation.const_equate_obligation(a, b);
176+
// FIXME(#59490): Need to remove the leak check to accomodate
177+
// escaping bound variables here.
178+
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
179+
relation.const_equate_obligation(a, b);
180+
}
173181
return Ok(a);
174182
}
175183
_ => {}

0 commit comments

Comments
 (0)