Skip to content

Commit ddbb885

Browse files
committed
Disable newly added CheckNull pass in clippy and miri
1 parent 5a87074 commit ddbb885

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
154154
return;
155155
}
156156

157-
let mir = cx.tcx.mir_drops_elaborated_and_const_checked(def_id);
157+
let mir = cx.tcx.optimized_mir(def_id);
158158

159-
if let Ok(()) = is_min_const_fn(cx.tcx,& mir.borrow(), &self.msrv)
160-
&& let hir::Node::Item(hir::Item { vis_span, .. }) | hir::Node::ImplItem(hir::ImplItem { vis_span, .. }) =
159+
if let Ok(()) = is_min_const_fn(cx.tcx, &mir, &self.msrv)
160+
&& let hir::Node::Item(hir::Item { vis_span, .. }) | hir::Node::ImplItem(hir::ImplItem { vis_span, .. }) =
161161
cx.tcx.hir_node_by_def_id(def_id)
162162
{
163163
let suggestion = if vis_span.is_empty() { "const " } else { " const" };

src/tools/clippy/src/driver.rs

Lines changed: 2 additions & 0 deletions
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)];
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;

src/tools/miri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
166166
"-Zmir-emit-retag",
167167
"-Zmir-keep-place-mention",
168168
"-Zmir-opt-level=0",
169-
"-Zmir-enable-passes=-CheckAlignment",
169+
"-Zmir-enable-passes=-CheckAlignment,-CheckNull",
170170
// Deduplicating diagnostics means we miss events when tracking what happens during an
171171
// execution. Let's not do that.
172172
"-Zdeduplicate-diagnostics=no",

src/tools/miri/tests/fail/dangling_pointers/null_pointer_deref.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Enable the UB checks for the sake of this test.
2-
//@compile-flags: -Zub-checks=no
3-
41
#[allow(deref_nullptr)]
52
fn main() {
63
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: null pointer

src/tools/miri/tests/fail/dangling_pointers/null_pointer_write.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Enable the UB checks for the sake of this test.
2-
//@compile-flags: -Zub-checks=no
3-
41
#[allow(deref_nullptr)]
52
fn main() {
63
unsafe { *std::ptr::null_mut() = 0i32 }; //~ ERROR: null pointer

0 commit comments

Comments
 (0)