Move drop elaboration infrastructure.
`rustc_mir_dataflow/src/elaborate_drops.rs` contains some infrastructure used by a few MIR passes: the `elaborate_drop` function, the `DropElaborator` trait, etc. `rustc_mir_transform/src/elaborate_drops.rs` (same file name, different crate) contains the `ElaborateDrops` pass. It relies on a lot of the infrastructure from `rustc_mir_dataflow/src/elaborate_drops.rs`. It turns out that the drop infrastructure is only used in `rustc_mir_transform`, so this commit moves it there. (The only exception is the small `DropFlagState` type, which is moved to the existing `rustc_mir_dataflow/src/drop_flag_effects.rs`.) The file is renamed from `rustc_mir_dataflow/src/elaborate_drops.rs` to `rustc_mir_transform/src/elaborate_drop.rs` (with no trailing `s`) because (a) the `elaborate_drop` function is the most important export, and (b) `rustc_mir_transform/src/elaborate_drops.rs` already exists. All the infrastructure pieces that used to be `pub` are now `pub(crate)`, because they are now only used within `rustc_mir_transform`.
This commit is contained in:
parent
a567209daa
commit
46c72362bc
8 changed files with 35 additions and 37 deletions
|
@ -3,7 +3,26 @@ use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind};
|
|||
use tracing::debug;
|
||||
|
||||
use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
|
||||
use crate::elaborate_drops::DropFlagState;
|
||||
|
||||
/// The value of an inserted drop flag.
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
pub enum DropFlagState {
|
||||
/// The tracked value is initialized and needs to be dropped when leaving its scope.
|
||||
Present,
|
||||
|
||||
/// The tracked value is uninitialized or was moved out of and does not need to be dropped when
|
||||
/// leaving its scope.
|
||||
Absent,
|
||||
}
|
||||
|
||||
impl DropFlagState {
|
||||
pub fn value(self) -> bool {
|
||||
match self {
|
||||
DropFlagState::Present => true,
|
||||
DropFlagState::Absent => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn move_path_children_matching<'tcx, F>(
|
||||
move_data: &MoveData<'tcx>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue