Skip to content

Commit efd54cc

Browse files
committed
interpret: use ConstPropNonsense for more const-prop induced issues
1 parent a339ed1 commit efd54cc

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,10 @@ where
826826
// predicate like `where Self: Sized` with `Self = dyn Trait`.
827827
// See #102553 for an example of such a predicate.
828828
if src.layout().is_unsized() {
829-
throw_inval!(SizeOfUnsizedType(src.layout().ty));
829+
throw_inval!(ConstPropNonsense);
830830
}
831831
if dest.layout().is_unsized() {
832-
throw_inval!(SizeOfUnsizedType(dest.layout().ty));
832+
throw_inval!(ConstPropNonsense);
833833
}
834834
assert_eq!(src.layout().size, dest.layout().size);
835835
// Yay, we got a value that we can write directly.

Diff for: compiler/rustc_const_eval/src/interpret/projection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ where
101101
let (meta, offset) = if field_layout.is_unsized() {
102102
if base.layout().is_sized() {
103103
// An unsized field of a sized type? Sure...
104-
// But const-prop actually feeds us such nonsense MIR!
104+
// But const-prop actually feeds us such nonsense MIR! (see test `const_prop/issue-86351.rs`)
105105
throw_inval!(ConstPropNonsense);
106106
}
107107
let base_meta = base.meta(self)?;

Diff for: compiler/rustc_const_eval/src/interpret/step.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
269269
let ty = self.subst_from_current_frame_and_normalize_erasing_regions(ty)?;
270270
let layout = self.layout_of(ty)?;
271271
if let mir::NullOp::SizeOf | mir::NullOp::AlignOf = null_op && layout.is_unsized() {
272-
// FIXME: This should be a span_bug (#80742)
272+
// FIXME: This should be a span_bug, but const generics can run MIR
273+
// that is not properly type-checked yet (#97477).
273274
self.tcx.sess.delay_span_bug(
274275
self.frame().current_span(),
275276
format!("{null_op:?} MIR operator called for unsized type {ty}"),

0 commit comments

Comments
 (0)