2020-02-24 09:22:02 -06:00
|
|
|
// Stacked Borrows detects that we are casting & to &mut and so it changes why we fail
|
2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-disable-stacked-borrows
|
2017-08-02 17:35:44 -05:00
|
|
|
|
2016-09-19 05:10:18 -05:00
|
|
|
use std::mem::transmute;
|
|
|
|
|
|
|
|
#[allow(mutable_transmutes)]
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
let s = "this is a test";
|
2022-07-11 06:44:55 -05:00
|
|
|
transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR: read-only
|
2016-09-19 05:10:18 -05:00
|
|
|
}
|
|
|
|
}
|