From ddbb8856b457d57c731dcb050875e1a0e4d75544 Mon Sep 17 00:00:00 2001 From: Bastian Kersting Date: Sat, 18 Jan 2025 17:40:15 +0000 Subject: [PATCH] Disable newly added CheckNull pass in clippy and miri --- src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs | 6 +++--- src/tools/clippy/src/driver.rs | 2 ++ src/tools/miri/src/lib.rs | 2 +- .../miri/tests/fail/dangling_pointers/null_pointer_deref.rs | 3 --- .../miri/tests/fail/dangling_pointers/null_pointer_write.rs | 3 --- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs index 75a6442aca142..4204ad513c267 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs @@ -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" }; diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 32ee668cda1cb..1472d77ef5e3a 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)]; // Disable flattening and inlining of format_args!(), so the HIR matches with the AST. config.opts.unstable_opts.flatten_format_args = false; diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 85c896563dabf..6a0966450f62c 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -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", diff --git a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref.rs b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref.rs index 0a2024ccb61bb..dee05952a9936 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref.rs @@ -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 diff --git a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write.rs b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write.rs index fffeb011c2045..61f5ef572cf3c 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write.rs @@ -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