]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_mir_transform/src/remove_storage_markers.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / compiler / rustc_mir_transform / src / remove_storage_markers.rs
1 //! This pass removes storage markers if they won't be emitted during codegen.
2
3 use crate::MirPass;
4 use rustc_middle::mir::*;
5 use rustc_middle::ty::TyCtxt;
6
7 pub struct RemoveStorageMarkers;
8
9 impl<'tcx> MirPass<'tcx> for RemoveStorageMarkers {
10 fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
11 if tcx.sess.emit_lifetime_markers() {
12 return;
13 }
14
15 trace!("Running RemoveStorageMarkers on {:?}", body.source);
16 for data in body.basic_blocks_mut() {
17 data.statements.retain(|statement| match statement.kind {
18 StatementKind::StorageLive(..)
19 | StatementKind::StorageDead(..)
20 | StatementKind::Nop => false,
21 _ => true,
22 })
23 }
24 }
25 }