about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-22 18:00:22 +0000
committerbors <bors@rust-lang.org>2021-08-22 18:00:22 +0000
commit91f9806208834de3fb5f62712356b0d84ec388fd (patch)
treea8e3112c95c8eeb5f2ae8623fec436b12e99c973 /compiler/rustc_infer/src
parent7481e6d1a415853a96dcec11a052caaa02859b5a (diff)
parentc2b61fbafe53d655ec010471d8f4a3bf34c724bd (diff)
downloadrust-91f9806208834de3fb5f62712356b0d84ec388fd.tar.gz
rust-91f9806208834de3fb5f62712356b0d84ec388fd.zip
Auto merge of #88166 - BoxyUwU:const-equate-canon, r=lcnr
canonicalize consts before calling try_unify_abstract_consts query

Fixes #88022
Fixes #86953
Fixes #77708
Fixes #82034
Fixes #85031

these ICEs were all caused by calling the `try_unify_abstract_consts` query with inference vars in substs

r? `@lcnr`
Diffstat (limited to 'compiler/rustc_infer/src')
-rw-r--r--compiler/rustc_infer/src/infer/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
index 80f1a0d3254..9013bea749a 100644
--- a/compiler/rustc_infer/src/infer/mod.rs
+++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -671,6 +671,22 @@ pub struct CombinedSnapshot<'a, 'tcx> {
 }
 
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
+    /// calls `tcx.try_unify_abstract_consts` after
+    /// canonicalizing the consts.
+    pub fn try_unify_abstract_consts(
+        &self,
+        a: ty::Unevaluated<'tcx>,
+        b: ty::Unevaluated<'tcx>,
+    ) -> bool {
+        let canonical = self.canonicalize_query(
+            ((a.def, a.substs), (b.def, b.substs)),
+            &mut OriginalQueryValues::default(),
+        );
+        debug!("canonical consts: {:?}", &canonical.value);
+
+        self.tcx.try_unify_abstract_consts(canonical.value)
+    }
+
     pub fn is_in_snapshot(&self) -> bool {
         self.in_snapshot.get()
     }