rust/compiler/rustc_span/src
bors aa4cfd0809 Auto merge of #134424 - 1c3t3a:null-checks, r=saethlin
Insert null checks for pointer dereferences when debug assertions are enabled

Similar to how the alignment is already checked, this adds a check
for null pointer dereferences in debug mode. It is implemented similarly
to the alignment check as a `MirPass`.

This inserts checks in the same places as the `CheckAlignment` pass and additionally
also inserts checks for `Borrows`, so code like
```rust
let ptr: *const u32 = std::ptr::null();
let val: &u32 = unsafe { &*ptr };
```
will have a check inserted on dereference. This is done because null references
are UB. The alignment check doesn't cover these places, because in `&(*ptr).field`,
the exact requirement is that the final reference must be aligned. This is something to
consider further enhancements of the alignment check.

For now this is implemented as a separate `MirPass`, to make it easy to disable
this check if necessary.

This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.

r? `@saethlin`
2025-01-31 15:56:53 +00:00
..
analyze_source_file Be more accurate about calculating display_col from a BytePos 2024-07-18 20:08:38 +00:00
edit_distance update cfg(bootstrap) 2025-01-08 21:26:39 +01:00
source_map Avoid another &Lrc<..> in a return value. 2024-10-07 13:59:50 +11:00
symbol Reformat use declarations. 2024-07-29 08:26:52 +10:00
analyze_source_file.rs Adjust syntax 2024-12-22 17:12:42 -03:00
caching_source_map_view.rs fix clippy::clone_on_ref_ptr for compiler 2024-10-28 18:05:08 +03:00
def_id.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
edit_distance.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
edition.rs Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
fatal_error.rs Auto merge of #117557 - Zoxc:panic-prio, r=petrochenkov 2023-11-09 00:39:02 +00:00
hygiene.rs Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, r=davidtwco,RalfJung" 2025-01-18 22:09:35 +00:00
lib.rs Auto merge of #134478 - compiler-errors:attr-span, r=oli-obk 2025-01-22 14:46:41 +00:00
profiling.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
source_map.rs Auto merge of #132791 - tyilo:big-file-fail-fast, r=compiler-errors 2024-11-24 07:37:32 +00:00
span_encoding.rs Rollup merge of #128197 - Alexendoo:span-ctxt, r=davidtwco 2024-11-14 20:45:12 +01:00
symbol.rs Auto merge of #134424 - 1c3t3a:null-checks, r=saethlin 2025-01-31 15:56:53 +00:00
tests.rs add unstable support for outputting file checksums for use in cargo 2024-10-01 21:23:20 -06:00