Skip to content

Commit

Permalink
Disable newly added CheckNull pass in clippy and miri
Browse files Browse the repository at this point in the history
  • Loading branch information
1c3t3a committed Jan 18, 2025
1 parent 5a87074 commit ddbb885
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
return;
}

let mir = cx.tcx.mir_drops_elaborated_and_const_checked(def_id);
let mir = cx.tcx.optimized_mir(def_id);

if let Ok(()) = is_min_const_fn(cx.tcx,& mir.borrow(), &self.msrv)
&& let hir::Node::Item(hir::Item { vis_span, .. }) | hir::Node::ImplItem(hir::ImplItem { vis_span, .. }) =
if let Ok(()) = is_min_const_fn(cx.tcx, &mir, &self.msrv)
&& let hir::Node::Item(hir::Item { vis_span, .. }) | hir::Node::ImplItem(hir::ImplItem { vis_span, .. }) =
cx.tcx.hir_node_by_def_id(def_id)
{
let suggestion = if vis_span.is_empty() { "const " } else { " const" };
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)];

// Disable flattening and inlining of format_args!(), so the HIR matches with the AST.
config.opts.unstable_opts.flatten_format_args = false;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
"-Zmir-emit-retag",
"-Zmir-keep-place-mention",
"-Zmir-opt-level=0",
"-Zmir-enable-passes=-CheckAlignment",
"-Zmir-enable-passes=-CheckAlignment,-CheckNull",
// Deduplicating diagnostics means we miss events when tracking what happens during an
// execution. Let's not do that.
"-Zdeduplicate-diagnostics=no",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Enable the UB checks for the sake of this test.
//@compile-flags: -Zub-checks=no

#[allow(deref_nullptr)]
fn main() {
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: null pointer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Enable the UB checks for the sake of this test.
//@compile-flags: -Zub-checks=no

#[allow(deref_nullptr)]
fn main() {
unsafe { *std::ptr::null_mut() = 0i32 }; //~ ERROR: null pointer
Expand Down

0 comments on commit ddbb885

Please sign in to comment.