RS.CLIPPY.TRANSMUTING_NULL

Transmutes from a null pointer to a reference, which is undefined behavior

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: transmuting_null. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for transmute calls which would receive a null pointer.

Why is this bad?

Transmuting a null pointer is undefined behavior.

Known problems

Not all cases can be detected at the moment of this writing. For example, variables which hold a null pointer and are then fed to a transmute call, aren't detectable yet.

Example

let null_ref: &u64 = unsafe { std::mem::transmute(0 as *const u64) };