about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-09-05 10:39:11 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-09-10 09:11:17 +1000
commit8949b443d5d0415c0c95fc931b1e4ee54de2f301 (patch)
tree07e965f59957d6327ac9c3c497fd16761de9393c
parent702340269136b9818359a82c5f7fc659ec26a0bf (diff)
downloadrust-8949b443d5d0415c0c95fc931b1e4ee54de2f301.tar.gz
rust-8949b443d5d0415c0c95fc931b1e4ee54de2f301.zip
Make `check_live_drops` into a `MirLint`.
It's a thin wrapper around `check_live_drops`, but it's enough to fix
the FIXME comment.
-rw-r--r--compiler/rustc_mir_transform/src/lib.rs9
-rw-r--r--compiler/rustc_mir_transform/src/post_drop_elaboration.rs13
2 files changed, 19 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs
index 6c9b46d8b6f..84d07d38330 100644
--- a/compiler/rustc_mir_transform/src/lib.rs
+++ b/compiler/rustc_mir_transform/src/lib.rs
@@ -87,6 +87,7 @@ mod match_branches;
 mod mentioned_items;
 mod multiple_return_terminators;
 mod nrvo;
+mod post_drop_elaboration;
 mod prettify;
 mod promote_consts;
 mod ref_prop;
@@ -480,11 +481,13 @@ pub fn run_analysis_to_runtime_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
         pm::run_passes(
             tcx,
             body,
-            &[&remove_uninit_drops::RemoveUninitDrops, &simplify::SimplifyCfg::RemoveFalseEdges],
+            &[
+                &remove_uninit_drops::RemoveUninitDrops,
+                &simplify::SimplifyCfg::RemoveFalseEdges,
+                &Lint(post_drop_elaboration::CheckLiveDrops),
+            ],
             None,
         );
-        // FIXME: make this a MIR lint
-        check_consts::post_drop_elaboration::check_live_drops(tcx, body);
     }
 
     debug!("runtime_mir_lowering({:?})", did);
diff --git a/compiler/rustc_mir_transform/src/post_drop_elaboration.rs b/compiler/rustc_mir_transform/src/post_drop_elaboration.rs
new file mode 100644
index 00000000000..75721d46076
--- /dev/null
+++ b/compiler/rustc_mir_transform/src/post_drop_elaboration.rs
@@ -0,0 +1,13 @@
+use rustc_const_eval::check_consts;
+use rustc_middle::mir::*;
+use rustc_middle::ty::TyCtxt;
+
+use crate::MirLint;
+
+pub(super) struct CheckLiveDrops;
+
+impl<'tcx> MirLint<'tcx> for CheckLiveDrops {
+    fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
+        check_consts::post_drop_elaboration::check_live_drops(tcx, body);
+    }
+}