[−][src]Static rustc_lint::builtin::MUTABLE_TRANSMUTES

pub(in builtin) static MUTABLE_TRANSMUTES: &Lint

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

Example

ⓘThis example deliberately fails to compile
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.