2017-08-02 15:35:44 -07:00
|
|
|
// Validation detects that we are casting & to &mut and so it changes why we fail
|
|
|
|
// compile-flags: -Zmir-emit-validate=0
|
|
|
|
|
2016-09-19 04:10:18 -06:00
|
|
|
use std::mem::transmute;
|
|
|
|
|
|
|
|
#[allow(mutable_transmutes)]
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
let s = "this is a test";
|
2018-07-15 11:21:56 +02:00
|
|
|
transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR constant evaluation error
|
2018-05-09 17:45:16 +02:00
|
|
|
//~^ NOTE tried to modify constant memory
|
2016-09-19 04:10:18 -06:00
|
|
|
}
|
|
|
|
}
|