Skip to content

Commit ca79ead

Browse files
committed
Make missing_const_for_fn operate on non-optimized MIR
This has two reasons: First of all we don't need the optimized MIR for evaluating the checks of this lint, as const-eval anyways operates on `mir_for_ctf` which is derived from `mir_drops_elaborated_and_const_checked`. Second of all we might transform MIR in the optimization passes in a way that doesn't work with const-eval, but it is irrelevant since const-eval uses another MIR. Specifically this came up when adding a new check in debug builds (rust-lang/rust#134424), which is added as part of an optimization pass.
1 parent 25d319d commit ca79ead

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/missing_const_for_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
157157
return;
158158
}
159159

160-
let mir = cx.tcx.optimized_mir(def_id);
160+
let mir = cx.tcx.mir_drops_elaborated_and_const_checked(def_id);
161161

162-
if let Ok(()) = is_min_const_fn(cx.tcx, mir, &self.msrv)
162+
if let Ok(()) = is_min_const_fn(cx.tcx, &mir.borrow(), &self.msrv)
163163
&& let hir::Node::Item(hir::Item { vis_span, .. }) | hir::Node::ImplItem(hir::ImplItem { vis_span, .. }) =
164164
cx.tcx.hir_node_by_def_id(def_id)
165165
{

0 commit comments

Comments
 (0)