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
|
2018-10-19 09:07:40 -05:00
|
|
|
|
2016-09-13 21:17:52 -05:00
|
|
|
static X: usize = 5;
|
|
|
|
|
|
|
|
#[allow(mutable_transmutes)]
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
2022-07-11 06:44:55 -05:00
|
|
|
*std::mem::transmute::<&usize, &mut usize>(&X) = 6; //~ ERROR: read-only
|
2016-09-13 21:17:52 -05:00
|
|
|
assert_eq!(X, 6);
|
|
|
|
}
|
|
|
|
}
|