diff options
| author | Alejandra González <blyxyas@gmail.com> | 2025-03-28 11:01:32 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-28 11:01:32 +0000 |
| commit | d78622eeb82975e51d72111fd4ccb7d8a67ec2f1 (patch) | |
| tree | df4108776230d2c8d27876bf7cfb173d1f74df15 | |
| parent | c2922d1213800157f013645d3dba6e8ed584b3a4 (diff) | |
| parent | 3e960c12d8004135a2c864a6d54753df806aeff6 (diff) | |
| download | rust-d78622eeb82975e51d72111fd4ccb7d8a67ec2f1.tar.gz rust-d78622eeb82975e51d72111fd4ccb7d8a67ec2f1.zip | |
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 (https://github.com/rust-lang/rust/pull/134424), which is added as part of an optimization pass. changelog: none
| -rw-r--r-- | clippy_lints/src/missing_const_for_fn.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 5ac66b4c7e8..67537a251da 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -155,9 +155,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn { return; } - let mir = cx.tcx.optimized_mir(def_id); + let mir = cx.tcx.mir_drops_elaborated_and_const_checked(def_id); - if let Ok(()) = is_min_const_fn(cx, mir, self.msrv) + if let Ok(()) = is_min_const_fn(cx, &mir.borrow(), 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) { |
