Skip to content

Commit

Permalink
Make check_live_drops into a MirLint.
Browse files Browse the repository at this point in the history
It's a thin wrapper around `check_live_drops`, but it's enough to fix
the FIXME comment.
  • Loading branch information
nnethercote committed Sep 9, 2024
1 parent 7023402 commit 8949b44
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_mir_transform/src/post_drop_elaboration.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 8949b44

Please sign in to comment.