MUTABLE_TRANSMUTES in rustc_lint::builtin - Rust
Description: The `mutable_transmutes` lint catches transmuting from `&T` to `&mut T` because it is undefined behavior.

Skip to main content

## MUTABLE_TRANSMUTES

# Static 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.