about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-05-08 23:13:49 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-05-17 11:06:35 +0200
commit3d7637e66de5dea270d729c4bbea1237b140e246 (patch)
tree4ae4e851f627b4f78c5cbd96343821990387ef63 /src
parent0f7bf5d9e11189dfbc10bc2acba653c4893c9b6c (diff)
downloadrust-3d7637e66de5dea270d729c4bbea1237b140e246.tar.gz
rust-3d7637e66de5dea270d729c4bbea1237b140e246.zip
correctly handle escaping bound variables
Diffstat (limited to 'src')
-rw-r--r--src/librustc_infer/infer/combine.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/librustc_infer/infer/combine.rs b/src/librustc_infer/infer/combine.rs
index 1d3ddd7e2de..e3e8e88993e 100644
--- a/src/librustc_infer/infer/combine.rs
+++ b/src/librustc_infer/infer/combine.rs
@@ -39,7 +39,7 @@ use rustc_hir::def_id::DefId;
 use rustc_middle::ty::error::TypeError;
 use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
 use rustc_middle::ty::subst::SubstsRef;
-use rustc_middle::ty::{self, InferConst, Ty, TyCtxt};
+use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeFoldable};
 use rustc_middle::ty::{IntType, UintType};
 use rustc_span::{Span, DUMMY_SP};
 
@@ -165,11 +165,19 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
                 return self.unify_const_variable(!a_is_expected, vid, a);
             }
             (ty::ConstKind::Unevaluated(..), _) if self.tcx.features().const_generics => {
-                relation.const_equate_obligation(a, b);
+                // FIXME(#59490): Need to remove the leak check to accomodate
+                // escaping bound variables here.
+                if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
+                    relation.const_equate_obligation(a, b);
+                }
                 return Ok(b);
             }
             (_, ty::ConstKind::Unevaluated(..)) if self.tcx.features().const_generics => {
-                relation.const_equate_obligation(a, b);
+                // FIXME(#59490): Need to remove the leak check to accomodate
+                // escaping bound variables here.
+                if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
+                    relation.const_equate_obligation(a, b);
+                }
                 return Ok(a);
             }
             _ => {}