about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-06 16:41:59 +0100
committerGitHub <noreply@github.com>2023-03-06 16:41:59 +0100
commitab7dd09fc2f75d7ab6b638725a5bde0cfa9fdf54 (patch)
tree2e03e85caa531a21c2bc8c8eba73db3ca1a0efda
parent3ae047b8f115692e4ed77f4ade37929f133de795 (diff)
parent8c0cbd87671c283707cbaf4f60db36a5184d8cef (diff)
downloadrust-ab7dd09fc2f75d7ab6b638725a5bde0cfa9fdf54.tar.gz
rust-ab7dd09fc2f75d7ab6b638725a5bde0cfa9fdf54.zip
Rollup merge of #108803 - cjgillot:const-prop-normalize, r=oli-obk
Do not ICE when failing to normalize in ConstProp.

There is no reason to delay a bug there, as we bubble up the failure as TooGeneric.

Fixes https://github.com/rust-lang/rust/issues/97728
-rw-r--r--compiler/rustc_const_eval/src/interpret/eval_context.rs11
-rw-r--r--tests/ui/associated-types/issue-67684.rs8
2 files changed, 9 insertions, 10 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs
index 3db102e484d..39c74191258 100644
--- a/compiler/rustc_const_eval/src/interpret/eval_context.rs
+++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs
@@ -7,7 +7,7 @@ use either::{Either, Left, Right};
 use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
 use rustc_index::vec::IndexVec;
 use rustc_middle::mir;
-use rustc_middle::mir::interpret::{ErrorHandled, InterpError, InvalidProgramInfo};
+use rustc_middle::mir::interpret::{ErrorHandled, InterpError};
 use rustc_middle::ty::layout::{
     self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers,
     TyAndLayout,
@@ -508,14 +508,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         frame
             .instance
             .try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value)
-            .map_err(|e| {
-                self.tcx.sess.delay_span_bug(
-                    self.cur_span(),
-                    format!("failed to normalize {}", e.get_type_for_failure()).as_str(),
-                );
-
-                InterpError::InvalidProgram(InvalidProgramInfo::TooGeneric)
-            })
+            .map_err(|_| err_inval!(TooGeneric))
     }
 
     /// The `substs` are assumed to already be in our interpreter "universe" (param_env).
diff --git a/tests/ui/associated-types/issue-67684.rs b/tests/ui/associated-types/issue-67684.rs
index 49efe8a1bda..c6920cf8d40 100644
--- a/tests/ui/associated-types/issue-67684.rs
+++ b/tests/ui/associated-types/issue-67684.rs
@@ -1,4 +1,10 @@
-// check-pass
+// revisions: check build
+// [check]check-pass
+//
+// This second configuration aims to verify that we do not ICE in ConstProp because of
+// normalization failure.
+// [build]build-pass
+// [build]compile-flags: -Zmir-opt-level=3 --emit=mir
 
 #![allow(dead_code)]