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
|
@ -1062,8 +1062,8 @@ fn insert_switch<'tcx>(
|
|||
|
||||
fn elaborate_coroutine_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_mir_dataflow::elaborate_drops::{Unwind, elaborate_drop};
|
||||
|
||||
use crate::elaborate_drop::{Unwind, elaborate_drop};
|
||||
use crate::shim::DropShimElaborator;
|
||||
|
||||
// Note that `elaborate_drops` only drops the upvars of a coroutine, and
|
||||
|
|
1022
compiler/rustc_mir_transform/src/elaborate_drop.rs
Normal file
1022
compiler/rustc_mir_transform/src/elaborate_drop.rs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,18 +6,17 @@ use rustc_index::bit_set::DenseBitSet;
|
|||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_mir_dataflow::elaborate_drops::{
|
||||
DropElaborator, DropFlagMode, DropFlagState, DropStyle, Unwind, elaborate_drop,
|
||||
};
|
||||
use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
use rustc_mir_dataflow::{
|
||||
Analysis, MoveDataTypingEnv, ResultsCursor, on_all_children_bits, on_lookup_result_bits,
|
||||
Analysis, DropFlagState, MoveDataTypingEnv, ResultsCursor, on_all_children_bits,
|
||||
on_lookup_result_bits,
|
||||
};
|
||||
use rustc_span::Span;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::deref_separator::deref_finder;
|
||||
use crate::elaborate_drop::{DropElaborator, DropFlagMode, DropStyle, Unwind, elaborate_drop};
|
||||
|
||||
/// During MIR building, Drop terminators are inserted in every place where a drop may occur.
|
||||
/// However, in this phase, the presence of these terminators does not guarantee that a destructor
|
||||
|
|
|
@ -49,6 +49,7 @@ mod check_pointers;
|
|||
mod cost_checker;
|
||||
mod cross_crate_inline;
|
||||
mod deduce_param_attrs;
|
||||
mod elaborate_drop;
|
||||
mod errors;
|
||||
mod ffi_unwind_calls;
|
||||
mod lint;
|
||||
|
|
|
@ -14,11 +14,11 @@ use rustc_middle::ty::{
|
|||
self, CoroutineArgs, CoroutineArgsExt, EarlyBinder, GenericArgs, Ty, TyCtxt,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::elaborate_drop::{DropElaborator, DropFlagMode, DropStyle, Unwind, elaborate_drop};
|
||||
use crate::{
|
||||
abort_unwinding_calls, add_call_guards, add_moves_for_packed_drops, deref_separator, inline,
|
||||
instsimplify, mentioned_items, pass_manager as pm, remove_noop_landing_pads, simplify,
|
||||
|
@ -283,13 +283,13 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
|
|||
DropShimElaborator { body: &body, patch: MirPatch::new(&body), tcx, typing_env };
|
||||
let dropee = tcx.mk_place_deref(dropee_ptr);
|
||||
let resume_block = elaborator.patch.resume_block();
|
||||
elaborate_drops::elaborate_drop(
|
||||
elaborate_drop(
|
||||
&mut elaborator,
|
||||
source_info,
|
||||
dropee,
|
||||
(),
|
||||
return_block,
|
||||
elaborate_drops::Unwind::To(resume_block),
|
||||
Unwind::To(resume_block),
|
||||
START_BLOCK,
|
||||
);
|
||||
elaborator.patch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue