about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-06-13 21:35:53 +0200
committerGitHub <noreply@github.com>2022-06-13 21:35:53 +0200
commite13eeedefc1429b15af6320aa69de2c64e9c3afc (patch)
tree47033dadb7c65eb4a380c7d4ab7e64fd5b7e99a1 /compiler
parent083721a1a7365d3afe1521cd2661b2201aac0450 (diff)
parent27af8e45852536fd14817464610866c84ad838b0 (diff)
Rollup merge of #97709 - compiler-errors:normalize-const-param-ty, r=oli-obk
Normalize consts' tys when relating with `adt_const_params`

Fixes #97007
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/ty/relate.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs
index 8677405eebe..9712d66b30a 100644
--- a/compiler/rustc_middle/src/ty/relate.rs
+++ b/compiler/rustc_middle/src/ty/relate.rs
@@ -579,10 +579,15 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
     debug!("{}.super_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
     let tcx = relation.tcx();
 
-    // FIXME(oli-obk): once const generics can have generic types, this assertion
-    // will likely get triggered. Move to `normalize_erasing_regions` at that point.
-    let a_ty = tcx.erase_regions(a.ty());
-    let b_ty = tcx.erase_regions(b.ty());
+    let a_ty;
+    let b_ty;
+    if relation.tcx().features().adt_const_params {
+        a_ty = tcx.normalize_erasing_regions(relation.param_env(), a.ty());
+        b_ty = tcx.normalize_erasing_regions(relation.param_env(), b.ty());
+    } else {
+        a_ty = tcx.erase_regions(a.ty());
+        b_ty = tcx.erase_regions(b.ty());
+    }
     if a_ty != b_ty {
         relation.tcx().sess.delay_span_bug(
             DUMMY_SP,