From bdd5855b8e127f4a258b0bd90cd5d2dbade1b3cc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 4 Aug 2023 21:42:35 +0200 Subject: interpret: fix projecting into an unsized field of a local new invariant: Place::Local never refers to something unsized --- src/tools/miri/tests/pass/unsized.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/tools/miri/tests/pass/unsized.rs b/src/tools/miri/tests/pass/unsized.rs index c9046dc3c76..5c6929882f6 100644 --- a/src/tools/miri/tests/pass/unsized.rs +++ b/src/tools/miri/tests/pass/unsized.rs @@ -2,6 +2,7 @@ //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(unsized_tuple_coercion)] #![feature(unsized_fn_params)] +#![feature(custom_mir, core_intrinsics)] use std::mem; @@ -32,7 +33,30 @@ fn unsized_params() { f3(*p); } +fn unsized_field_projection() { + use std::intrinsics::mir::*; + + pub struct S(T); + + #[custom_mir(dialect = "runtime", phase = "optimized")] + fn f(x: S<[u8]>) { + mir! { + { + let idx = 0; + // Project to an unsized field of an unsized local. + x.0[idx] = 0; + let _val = x.0[idx]; + Return() + } + } + } + + let x: Box> = Box::new(S([0])); + f(*x); +} + fn main() { unsized_tuple(); unsized_params(); + unsized_field_projection(); } -- cgit 1.4.1-3-g733a5