Skip to content

Commit d78622e

Browse files
authored
Make missing_const_for_fn operate on non-optimized MIR (#14003)
The main reason for this is that 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 (`mir_for_ctfe`). 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. changelog: none
2 parents c2922d1 + 3e960c1 commit d78622e

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
@@ -155,9 +155,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
155155
return;
156156
}
157157

158-
let mir = cx.tcx.optimized_mir(def_id);
158+
let mir = cx.tcx.mir_drops_elaborated_and_const_checked(def_id);
159159

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

0 commit comments

Comments
 (0)