Skip to content

Commit bd094fb

Browse files
authored
Rollup merge of rust-lang#137008 - nnethercote:mv-code-into-rustc_mir_transform, r=oli-obk
Move code into `rustc_mir_transform` I found two modules in other crates that are better placed in `rustc_mir_transform`, because that's the only crate that uses them. r? ``@matthewjasper``
2 parents 8bf77a4 + 28b75a3 commit bd094fb

20 files changed

+77
-78
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub mod generic_graphviz;
4949
pub mod graphviz;
5050
pub mod interpret;
5151
pub mod mono;
52-
pub mod patch;
5352
pub mod pretty;
5453
mod query;
5554
mod statement;

compiler/rustc_mir_dataflow/src/drop_flag_effects.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@ use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind};
33
use tracing::debug;
44

55
use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
6-
use crate::elaborate_drops::DropFlagState;
6+
7+
/// The value of an inserted drop flag.
8+
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
9+
pub enum DropFlagState {
10+
/// The tracked value is initialized and needs to be dropped when leaving its scope.
11+
Present,
12+
13+
/// The tracked value is uninitialized or was moved out of and does not need to be dropped when
14+
/// leaving its scope.
15+
Absent,
16+
}
17+
18+
impl DropFlagState {
19+
pub fn value(self) -> bool {
20+
match self {
21+
DropFlagState::Present => true,
22+
DropFlagState::Absent => false,
23+
}
24+
}
25+
}
726

827
pub fn move_path_children_matching<'tcx, F>(
928
move_data: &MoveData<'tcx>,

compiler/rustc_mir_dataflow/src/impls/initialized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::util::Discr;
99
use rustc_middle::ty::{self, TyCtxt};
1010
use tracing::{debug, instrument};
1111

12-
use crate::elaborate_drops::DropFlagState;
12+
use crate::drop_flag_effects::DropFlagState;
1313
use crate::framework::SwitchIntTarget;
1414
use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
1515
use crate::{

compiler/rustc_mir_dataflow/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty;
1515
// Please change the public `use` directives cautiously, as they might be used by external tools.
1616
// See issue #120130.
1717
pub use self::drop_flag_effects::{
18-
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
18+
DropFlagState, drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
1919
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
2020
};
2121
pub use self::framework::{
@@ -26,7 +26,6 @@ use self::move_paths::MoveData;
2626

2727
pub mod debuginfo;
2828
mod drop_flag_effects;
29-
pub mod elaborate_drops;
3029
mod errors;
3130
mod framework;
3231
pub mod impls;

compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use rustc_middle::mir::patch::MirPatch;
21
use rustc_middle::mir::*;
32
use rustc_middle::ty::{self, TyCtxt};
43
use tracing::debug;
54

5+
use crate::patch::MirPatch;
66
use crate::util;
77

88
/// This pass moves values being dropped that are within a packed

compiler/rustc_mir_transform/src/add_subtyping_projections.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use rustc_middle::mir::patch::MirPatch;
21
use rustc_middle::mir::visit::MutVisitor;
32
use rustc_middle::mir::*;
43
use rustc_middle::ty::TyCtxt;
54

5+
use crate::patch::MirPatch;
6+
67
pub(super) struct Subtyper;
78

89
struct SubTypeChecker<'a, 'tcx> {

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,8 @@ fn insert_switch<'tcx>(
10611061
}
10621062

10631063
fn elaborate_coroutine_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
1064-
use rustc_middle::mir::patch::MirPatch;
1065-
use rustc_mir_dataflow::elaborate_drops::{Unwind, elaborate_drop};
1066-
1064+
use crate::elaborate_drop::{Unwind, elaborate_drop};
1065+
use crate::patch::MirPatch;
10671066
use crate::shim::DropShimElaborator;
10681067

10691068
// Note that `elaborate_drops` only drops the upvars of a coroutine, and

compiler/rustc_mir_transform/src/deref_separator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use rustc_middle::mir::patch::MirPatch;
21
use rustc_middle::mir::visit::NonUseContext::VarDebugInfo;
32
use rustc_middle::mir::visit::{MutVisitor, PlaceContext};
43
use rustc_middle::mir::*;
54
use rustc_middle::ty::TyCtxt;
65

6+
use crate::patch::MirPatch;
7+
78
pub(super) struct Derefer;
89

910
struct DerefChecker<'a, 'tcx> {

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::fmt::Debug;
22

3-
use rustc_middle::mir::patch::MirPatch;
43
use rustc_middle::mir::*;
54
use rustc_middle::ty::{Ty, TyCtxt};
65
use tracing::trace;
76

87
use super::simplify::simplify_cfg;
8+
use crate::patch::MirPatch;
99

1010
/// This pass optimizes something like
1111
/// ```ignore (syntax-highlighting-only)

compiler/rustc_mir_transform/src/elaborate_box_derefs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
55
use rustc_abi::FieldIdx;
66
use rustc_hir::def_id::DefId;
7-
use rustc_middle::mir::patch::MirPatch;
87
use rustc_middle::mir::visit::MutVisitor;
98
use rustc_middle::mir::*;
109
use rustc_middle::span_bug;
1110
use rustc_middle::ty::{Ty, TyCtxt};
1211

12+
use crate::patch::MirPatch;
13+
1314
/// Constructs the types used when accessing a Box's pointer
1415
fn build_ptr_tys<'tcx>(
1516
tcx: TyCtxt<'tcx>,

0 commit comments

Comments
 (0)