Static rustc_lint::builtin::MUTABLE_TRANSMUTES

source ·
static MUTABLE_TRANSMUTES: &Lint
Expand description

The mutable_transmutes lint catches transmuting from &T to &mut T because it is undefined behavior.

§Example

unsafe {
    let y = std::mem::transmute::<&i32, &mut i32>(&5);
}

{{produces}}

§Explanation

Certain assumptions are made about aliasing of data, and this transmute violates those assumptions. Consider using UnsafeCell instead.