coverage: Clean up marker statements that aren't needed later
Some of the marker statements used by coverage are added during MIR building for use by the InstrumentCoverage pass (during analysis), and are not needed afterwards.
This commit is contained in:
parent
cdb683f6e4
commit
91aae58568
8 changed files with 159 additions and 14 deletions
|
@ -5,15 +5,20 @@
|
|||
//! - [`AscribeUserType`]
|
||||
//! - [`FakeRead`]
|
||||
//! - [`Assign`] statements with a [`Fake`] borrow
|
||||
//! - [`Coverage`] statements of kind [`BlockMarker`] or [`SpanMarker`]
|
||||
//!
|
||||
//! [`AscribeUserType`]: rustc_middle::mir::StatementKind::AscribeUserType
|
||||
//! [`Assign`]: rustc_middle::mir::StatementKind::Assign
|
||||
//! [`FakeRead`]: rustc_middle::mir::StatementKind::FakeRead
|
||||
//! [`Nop`]: rustc_middle::mir::StatementKind::Nop
|
||||
//! [`Fake`]: rustc_middle::mir::BorrowKind::Fake
|
||||
//! [`Coverage`]: rustc_middle::mir::StatementKind::Coverage
|
||||
//! [`BlockMarker`]: rustc_middle::mir::coverage::CoverageKind::BlockMarker
|
||||
//! [`SpanMarker`]: rustc_middle::mir::coverage::CoverageKind::SpanMarker
|
||||
|
||||
use crate::MirPass;
|
||||
use rustc_middle::mir::{Body, BorrowKind, Rvalue, StatementKind, TerminatorKind};
|
||||
use rustc_middle::mir::coverage::CoverageKind;
|
||||
use rustc_middle::mir::{Body, BorrowKind, Coverage, Rvalue, StatementKind, TerminatorKind};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
pub struct CleanupPostBorrowck;
|
||||
|
@ -25,6 +30,12 @@ impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck {
|
|||
match statement.kind {
|
||||
StatementKind::AscribeUserType(..)
|
||||
| StatementKind::Assign(box (_, Rvalue::Ref(_, BorrowKind::Fake, _)))
|
||||
| StatementKind::Coverage(box Coverage {
|
||||
// These kinds of coverage statements are markers inserted during
|
||||
// MIR building, and are not needed after InstrumentCoverage.
|
||||
kind: CoverageKind::BlockMarker { .. } | CoverageKind::SpanMarker { .. },
|
||||
..
|
||||
})
|
||||
| StatementKind::FakeRead(..) => statement.make_nop(),
|
||||
_ => (),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue