Skip to content

Commit 27454db

Browse files
committed
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: rust-lang/rust-project-goals#177.
1 parent 7eefa76 commit 27454db

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/driver.rs

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
166166
// MIR passes can be enabled / disabled separately, we should figure out, what passes to
167167
// use for Clippy.
168168
config.opts.unstable_opts.mir_opt_level = Some(0);
169+
config.opts.unstable_opts.mir_enable_passes =
170+
vec![("CheckNull".to_owned(), false), ("CheckAlignment".to_owned(), false)];
169171

170172
// Disable flattening and inlining of format_args!(), so the HIR matches with the AST.
171173
config.opts.unstable_opts.flatten_format_args = false;

0 commit comments

Comments
 (0)