mirror of
https://github.com/rust-lang/rust.git
synced 2026-07-08 00:38:40 -04:00
91fc16bab6
Distinguish null reference production from null pointer dereference in UB checks Closes rust-lang/rust#154044 This change distinguishes null reference production from actual null pointer dereferences in the UB checks. Producing a reference from a null pointer (for example, `&*ptr`) is undefined behavior even if no memory is dereferenced. This change introduces a dedicated `AssertKind::NullReferenceConstructed` and runtime panic so these cases produce a more accurate diagnostic while preserving the existing panic for actual null pointer dereferences. Summary - Add `AssertKind::NullReferenceConstructed`. - Emit it for null reference production in the MIR null check pass. - Add `panic_null_reference_constructed` and its lang item. - Keep `NullPointerDereference` for actual dereferences. - Update the affected UI tests.
Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.