about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-08-06 14:29:58 +0200
committerRalf Jung <post@ralfj.de>2023-08-06 15:20:03 +0200
commitefd54ccf5af607f687640a4a7fbbe7958b19bb3e (patch)
tree1f3fa62572df6851d3c109fd8346a8a835f2ed13 /compiler/rustc_const_eval/src/interpret
parenta339ed184f6824c88b9e1f4ea524e09f72908ebf (diff)
downloadrust-efd54ccf5af607f687640a4a7fbbe7958b19bb3e.tar.gz
rust-efd54ccf5af607f687640a4a7fbbe7958b19bb3e.zip
interpret: use ConstPropNonsense for more const-prop induced issues
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
-rw-r--r--compiler/rustc_const_eval/src/interpret/place.rs4
-rw-r--r--compiler/rustc_const_eval/src/interpret/projection.rs2
-rw-r--r--compiler/rustc_const_eval/src/interpret/step.rs3
3 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs
index 2dc856528f5..ec226808f1b 100644
--- a/compiler/rustc_const_eval/src/interpret/place.rs
+++ b/compiler/rustc_const_eval/src/interpret/place.rs
@@ -826,10 +826,10 @@ where
                 // predicate like `where Self: Sized` with `Self = dyn Trait`.
                 // See #102553 for an example of such a predicate.
                 if src.layout().is_unsized() {
-                    throw_inval!(SizeOfUnsizedType(src.layout().ty));
+                    throw_inval!(ConstPropNonsense);
                 }
                 if dest.layout().is_unsized() {
-                    throw_inval!(SizeOfUnsizedType(dest.layout().ty));
+                    throw_inval!(ConstPropNonsense);
                 }
                 assert_eq!(src.layout().size, dest.layout().size);
                 // Yay, we got a value that we can write directly.
diff --git a/compiler/rustc_const_eval/src/interpret/projection.rs b/compiler/rustc_const_eval/src/interpret/projection.rs
index 539b58b7e9b..882097ad2c3 100644
--- a/compiler/rustc_const_eval/src/interpret/projection.rs
+++ b/compiler/rustc_const_eval/src/interpret/projection.rs
@@ -101,7 +101,7 @@ where
         let (meta, offset) = if field_layout.is_unsized() {
             if base.layout().is_sized() {
                 // An unsized field of a sized type? Sure...
-                // But const-prop actually feeds us such nonsense MIR!
+                // But const-prop actually feeds us such nonsense MIR! (see test `const_prop/issue-86351.rs`)
                 throw_inval!(ConstPropNonsense);
             }
             let base_meta = base.meta(self)?;
diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs
index 0ef5522729a..fa5313add65 100644
--- a/compiler/rustc_const_eval/src/interpret/step.rs
+++ b/compiler/rustc_const_eval/src/interpret/step.rs
@@ -269,7 +269,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                 let ty = self.subst_from_current_frame_and_normalize_erasing_regions(ty)?;
                 let layout = self.layout_of(ty)?;
                 if let mir::NullOp::SizeOf | mir::NullOp::AlignOf = null_op && layout.is_unsized() {
-                    // FIXME: This should be a span_bug (#80742)
+                    // FIXME: This should be a span_bug, but const generics can run MIR
+                    // that is not properly type-checked yet (#97477).
                     self.tcx.sess.delay_span_bug(
                         self.frame().current_span(),
                         format!("{null_op:?} MIR operator called for unsized type {ty}"),