diff options
| author | Bastian Kersting <bkersting@google.com> | 2024-12-17 13:00:22 +0000 |
|---|---|---|
| committer | Bastian Kersting <bkersting@google.com> | 2025-01-31 11:13:34 +0000 |
| commit | b151b513ba2b65c7506ec1a80f2712bbd09154d1 (patch) | |
| tree | fc1505e76399304e8da3aca3808ad1b494dfe4e8 /src/tools/clippy | |
| parent | 851322b74db9ac91a1b9d206c5f80fc51a97f7c1 (diff) | |
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 is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
Diffstat (limited to 'src/tools/clippy')
| -rw-r--r-- | src/tools/clippy/src/driver.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 8201f332d33..c548f262a92 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -166,6 +166,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks { // MIR passes can be enabled / disabled separately, we should figure out, what passes to // use for Clippy. config.opts.unstable_opts.mir_opt_level = Some(0); + config.opts.unstable_opts.mir_enable_passes = + vec![("CheckNull".to_owned(), false), ("CheckAlignment".to_owned(), false)]; // Disable flattening and inlining of format_args!(), so the HIR matches with the AST. config.opts.unstable_opts.flatten_format_args = false; |
