## INTEGER_TO_PTR_TRANSMUTES

# Static INTEGER_TO_PTR_TRANSMUTES

Source

    pub static INTEGER_TO_PTR_TRANSMUTES: &Lint

Expand description

The `integer_to_ptr_transmutes` lint detects integer to pointer transmutes where the resulting pointers are undefined behavior to dereference.

#### §Example

    fn foo(a: usize) -> *const u8 {
       unsafe {
           std::mem::transmute::<usize, *const u8>(a)
       }
    }

{{produces}}

#### §Explanation

Any attempt to use the resulting pointers are undefined behavior as the resulting pointers won’t have any provenance.

Alternatively, `std::ptr::with_exposed_provenance` should be used, as they do not carry the provenance requirement. If wanting to create pointers without provenance `std::ptr::without_provenance` should be used instead.

See `std::mem::transmute` in the reference for more details.