Skip to content

Commit bba4be6

Browse files
committed
Move rustc_mir::transform to rustc_mir_transform.
1 parent 31a61cc commit bba4be6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+775
-698
lines changed

Cargo.lock

+24-2
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,7 @@ dependencies = [
39283928
"rustc_middle",
39293929
"rustc_mir",
39303930
"rustc_mir_build",
3931+
"rustc_mir_transform",
39313932
"rustc_parse",
39323933
"rustc_passes",
39333934
"rustc_plugin_impl",
@@ -4071,10 +4072,8 @@ dependencies = [
40714072
name = "rustc_mir"
40724073
version = "0.0.0"
40734074
dependencies = [
4074-
"coverage_test_macros",
40754075
"either",
40764076
"gsgdt",
4077-
"itertools 0.9.0",
40784077
"polonius-engine",
40794078
"regex",
40804079
"rustc_apfloat",
@@ -4120,6 +4119,29 @@ dependencies = [
41204119
"tracing",
41214120
]
41224121

4122+
[[package]]
4123+
name = "rustc_mir_transform"
4124+
version = "0.0.0"
4125+
dependencies = [
4126+
"coverage_test_macros",
4127+
"itertools 0.9.0",
4128+
"rustc_ast",
4129+
"rustc_attr",
4130+
"rustc_data_structures",
4131+
"rustc_errors",
4132+
"rustc_hir",
4133+
"rustc_index",
4134+
"rustc_middle",
4135+
"rustc_mir",
4136+
"rustc_serialize",
4137+
"rustc_session",
4138+
"rustc_span",
4139+
"rustc_target",
4140+
"rustc_trait_selection",
4141+
"smallvec",
4142+
"tracing",
4143+
]
4144+
41234145
[[package]]
41244146
name = "rustc_parse"
41254147
version = "0.0.0"

compiler/rustc_interface/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ rustc_hir = { path = "../rustc_hir" }
3434
rustc_metadata = { path = "../rustc_metadata" }
3535
rustc_mir = { path = "../rustc_mir" }
3636
rustc_mir_build = { path = "../rustc_mir_build" }
37+
rustc_mir_transform = { path = "../rustc_mir_transform" }
3738
rustc_passes = { path = "../rustc_passes" }
3839
rustc_typeck = { path = "../rustc_typeck" }
3940
rustc_lint = { path = "../rustc_lint" }

compiler/rustc_interface/src/passes.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ pub static DEFAULT_QUERY_PROVIDERS: SyncLazy<Providers> = SyncLazy::new(|| {
742742
mir::provide(providers);
743743
mir_borrowck::provide(providers);
744744
mir_build::provide(providers);
745+
rustc_mir_transform::provide(providers);
745746
rustc_privacy::provide(providers);
746747
typeck::provide(providers);
747748
ty::provide(providers);
@@ -913,7 +914,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
913914
for def_id in tcx.body_owners() {
914915
tcx.ensure().thir_check_unsafety(def_id);
915916
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
916-
mir::transform::check_unsafety::check_unsafety(tcx, def_id);
917+
rustc_mir_transform::check_unsafety::check_unsafety(tcx, def_id);
917918
}
918919

919920
if tcx.hir().body_const_context(def_id).is_some() {
@@ -1061,7 +1062,7 @@ pub fn start_codegen<'tcx>(
10611062
info!("Post-codegen\n{:?}", tcx.debug_stats());
10621063

10631064
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
1064-
if let Err(e) = mir::transform::dump_mir::emit_mir(tcx, outputs) {
1065+
if let Err(e) = rustc_mir_transform::dump_mir::emit_mir(tcx, outputs) {
10651066
tcx.sess.err(&format!("could not emit MIR: {}", e));
10661067
tcx.sess.abort_if_errors();
10671068
}

compiler/rustc_mir/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ doctest = false
99
[dependencies]
1010
either = "1.5.0"
1111
gsgdt = "0.1.2"
12-
itertools = "0.9"
1312
polonius-engine = "0.13.0"
1413
regex = "1"
1514
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
@@ -30,6 +29,3 @@ rustc_session = { path = "../rustc_session" }
3029
rustc_target = { path = "../rustc_target" }
3130
rustc_trait_selection = { path = "../rustc_trait_selection" }
3231
rustc_span = { path = "../rustc_span" }
33-
34-
[dev-dependencies]
35-
coverage_test_macros = { path = "src/transform/coverage/test_macros" }

compiler/rustc_mir/src/dataflow/drop_flag_effects.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn place_contents_drop_state_cannot_differ<'tcx>(
7979
}
8080
}
8181

82-
pub(crate) fn on_lookup_result_bits<'tcx, F>(
82+
pub fn on_lookup_result_bits<'tcx, F>(
8383
tcx: TyCtxt<'tcx>,
8484
body: &Body<'tcx>,
8585
move_data: &MoveData<'tcx>,
@@ -96,7 +96,7 @@ pub(crate) fn on_lookup_result_bits<'tcx, F>(
9696
}
9797
}
9898

99-
pub(crate) fn on_all_children_bits<'tcx, F>(
99+
pub fn on_all_children_bits<'tcx, F>(
100100
tcx: TyCtxt<'tcx>,
101101
body: &Body<'tcx>,
102102
move_data: &MoveData<'tcx>,
@@ -138,7 +138,7 @@ pub(crate) fn on_all_children_bits<'tcx, F>(
138138
on_all_children_bits(tcx, body, move_data, move_path_index, &mut each_child);
139139
}
140140

141-
pub(crate) fn on_all_drop_children_bits<'tcx, F>(
141+
pub fn on_all_drop_children_bits<'tcx, F>(
142142
tcx: TyCtxt<'tcx>,
143143
body: &Body<'tcx>,
144144
ctxt: &MoveDataParamEnv<'tcx>,
@@ -161,7 +161,7 @@ pub(crate) fn on_all_drop_children_bits<'tcx, F>(
161161
})
162162
}
163163

164-
pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F>(
164+
pub fn drop_flag_effects_for_function_entry<'tcx, F>(
165165
tcx: TyCtxt<'tcx>,
166166
body: &Body<'tcx>,
167167
ctxt: &MoveDataParamEnv<'tcx>,
@@ -179,7 +179,7 @@ pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F>(
179179
}
180180
}
181181

182-
pub(crate) fn drop_flag_effects_for_location<'tcx, F>(
182+
pub fn drop_flag_effects_for_location<'tcx, F>(
183183
tcx: TyCtxt<'tcx>,
184184
body: &Body<'tcx>,
185185
ctxt: &MoveDataParamEnv<'tcx>,

compiler/rustc_mir/src/dataflow/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ use rustc_middle::ty;
33
use rustc_session::Session;
44
use rustc_span::symbol::{sym, Symbol};
55

6-
pub(crate) use self::drop_flag_effects::*;
6+
pub use self::drop_flag_effects::{
7+
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
8+
move_path_children_matching, on_all_children_bits, on_all_drop_children_bits,
9+
on_lookup_result_bits,
10+
};
711
pub use self::framework::{
812
fmt, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine, Forward,
913
GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
@@ -26,7 +30,7 @@ pub struct MoveDataParamEnv<'tcx> {
2630
pub param_env: ty::ParamEnv<'tcx>,
2731
}
2832

29-
pub(crate) fn has_rustc_mir_with(
33+
pub fn has_rustc_mir_with(
3034
_sess: &Session,
3135
attrs: &[ast::Attribute],
3236
name: Symbol,

compiler/rustc_mir/src/interpret/intern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx, !>>
420420
/// A helper function that allocates memory for the layout given and gives you access to mutate
421421
/// it. Once your own mutation code is done, the backing `Allocation` is removed from the
422422
/// current `Memory` and returned.
423-
pub(crate) fn intern_with_temp_alloc(
423+
pub fn intern_with_temp_alloc(
424424
&mut self,
425425
layout: TyAndLayout<'tcx>,
426426
f: impl FnOnce(

compiler/rustc_mir/src/interpret/operand.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
296296
/// Note that for a given layout, this operation will either always fail or always
297297
/// succeed! Whether it succeeds depends on whether the layout can be represented
298298
/// in an `Immediate`, not on which data is stored there currently.
299-
pub(crate) fn try_read_immediate(
299+
pub fn try_read_immediate(
300300
&self,
301301
src: &OpTy<'tcx, M::PointerTag>,
302302
) -> InterpResult<'tcx, Result<ImmTy<'tcx, M::PointerTag>, MPlaceTy<'tcx, M::PointerTag>>> {
@@ -547,7 +547,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
547547
// in patterns via the `const_eval` module
548548
/// The `val` and `layout` are assumed to already be in our interpreter
549549
/// "universe" (param_env).
550-
crate fn const_to_op(
550+
pub fn const_to_op(
551551
&self,
552552
val: &ty::Const<'tcx>,
553553
layout: Option<TyAndLayout<'tcx>>,
@@ -566,7 +566,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
566566
}
567567
}
568568

569-
crate fn mir_const_to_op(
569+
pub fn mir_const_to_op(
570570
&self,
571571
val: &mir::ConstantKind<'tcx>,
572572
layout: Option<TyAndLayout<'tcx>>,

compiler/rustc_mir/src/interpret/step.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
7676

7777
/// Runs the interpretation logic for the given `mir::Statement` at the current frame and
7878
/// statement counter. This also moves the statement counter forward.
79-
crate fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
79+
pub fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
8080
info!("{:?}", stmt);
8181

8282
use rustc_middle::mir::StatementKind::*;

compiler/rustc_mir/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,18 @@ pub mod const_eval;
3737
pub mod dataflow;
3838
pub mod interpret;
3939
pub mod monomorphize;
40-
mod shim;
4140
pub mod transform;
4241
pub mod util;
4342

4443
use rustc_middle::ty::query::Providers;
4544

4645
pub fn provide(providers: &mut Providers) {
4746
const_eval::provide(providers);
48-
shim::provide(providers);
49-
transform::provide(providers);
5047
monomorphize::partitioning::provide(providers);
5148
monomorphize::polymorphize::provide(providers);
5249
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
5350
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
5451
providers.const_caller_location = const_eval::const_caller_location;
55-
providers.mir_callgraph_reachable = transform::inline::cycle::mir_callgraph_reachable;
56-
providers.mir_inliner_callees = transform::inline::cycle::mir_inliner_callees;
5752
providers.destructure_const = |tcx, param_env_and_value| {
5853
let (param_env, value) = param_env_and_value.into_parts();
5954
const_eval::destructure_const(tcx, param_env, value)

0 commit comments

Comments
 (0)