interpret: fix projecting into an unsized field of a local
new invariant: Place::Local never refers to something unsized
This commit is contained in:
parent
61efe9d298
commit
bdd5855b8e
6 changed files with 124 additions and 97 deletions
|
|
@ -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: ?Sized>(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<S<[u8]>> = Box::new(S([0]));
|
||||
f(*x);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsized_tuple();
|
||||
unsized_params();
|
||||
unsized_field_projection();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue