summaryrefslogtreecommitdiffstats
path: root/tests/ui/transmute/transmute-imut-to-mut.rs
blob: 9f3f76c1ef3e0c91452c7d13f458703485e142cc (plain)
1
2
3
4
5
6
7
8
// Tests that transmuting from &T to &mut T is Undefined Behavior.

use std::mem::transmute;

fn main() {
    let _a: &mut u8 = unsafe { transmute(&1u8) };
    //~^ ERROR transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell
}