Skip to content

Commit 3b81d9d

Browse files
committed
Remove SwitchIntTarget.
It's only passed to `Analysis::apply_switch_int_edge_effect`, and the existing impls of that method only use the `value` field. So pass that instead.
1 parent db1ca60 commit 3b81d9d

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

compiler/rustc_mir_dataflow/src/framework/direction.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::mir::{
55
};
66

77
use super::visitor::ResultsVisitor;
8-
use super::{Analysis, Effect, EffectIndex, Results, SwitchIntTarget};
8+
use super::{Analysis, Effect, EffectIndex, Results};
99

1010
pub trait Direction {
1111
const IS_FORWARD: bool;
@@ -117,8 +117,7 @@ impl Direction for Backward {
117117
let mut tmp = analysis.bottom_value(body);
118118
for &value in &body.basic_blocks.switch_sources()[&(block, pred)] {
119119
tmp.clone_from(exit_state);
120-
let si_target = SwitchIntTarget { value, target: block };
121-
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, si_target);
120+
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, value);
122121
propagate(pred, &tmp);
123122
}
124123
} else {
@@ -292,9 +291,8 @@ impl Direction for Forward {
292291
let mut tmp = analysis.bottom_value(body);
293292
for (value, target) in targets.iter() {
294293
tmp.clone_from(exit_state);
295-
let si_target =
296-
SwitchIntTarget { value: SwitchTargetValue::Normal(value), target };
297-
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, si_target);
294+
let value = SwitchTargetValue::Normal(value);
295+
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, value);
298296
propagate(target, &tmp);
299297
}
300298

@@ -305,7 +303,7 @@ impl Direction for Forward {
305303
analysis.apply_switch_int_edge_effect(
306304
&mut data,
307305
exit_state,
308-
SwitchIntTarget { value: SwitchTargetValue::Otherwise, target: otherwise },
306+
SwitchTargetValue::Otherwise,
309307
);
310308
propagate(otherwise, exit_state);
311309
} else {

compiler/rustc_mir_dataflow/src/framework/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub trait Analysis<'tcx> {
222222
&mut self,
223223
_data: &mut Self::SwitchIntData,
224224
_state: &mut Self::Domain,
225-
_edge: SwitchIntTarget,
225+
_value: SwitchTargetValue,
226226
) {
227227
unreachable!();
228228
}
@@ -432,10 +432,5 @@ impl EffectIndex {
432432
}
433433
}
434434

435-
pub struct SwitchIntTarget {
436-
pub value: SwitchTargetValue,
437-
pub target: BasicBlock,
438-
}
439-
440435
#[cfg(test)]
441436
mod tests;

compiler/rustc_mir_dataflow/src/impls/initialized.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_middle::ty::{self, TyCtxt};
1212
use tracing::{debug, instrument};
1313

1414
use crate::drop_flag_effects::DropFlagState;
15-
use crate::framework::SwitchIntTarget;
1615
use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
1716
use crate::{
1817
Analysis, GenKill, MaybeReachable, drop_flag_effects, drop_flag_effects_for_function_entry,
@@ -424,9 +423,9 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
424423
&mut self,
425424
data: &mut Self::SwitchIntData,
426425
state: &mut Self::Domain,
427-
edge: SwitchIntTarget,
426+
value: SwitchTargetValue,
428427
) {
429-
if let SwitchTargetValue::Normal(value) = edge.value {
428+
if let SwitchTargetValue::Normal(value) = value {
430429
// Kill all move paths that correspond to variants we know to be inactive along this
431430
// particular outgoing edge of a `SwitchInt`.
432431
drop_flag_effects::on_all_inactive_variants(
@@ -537,9 +536,9 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
537536
&mut self,
538537
data: &mut Self::SwitchIntData,
539538
state: &mut Self::Domain,
540-
edge: SwitchIntTarget,
539+
value: SwitchTargetValue,
541540
) {
542-
if let SwitchTargetValue::Normal(value) = edge.value {
541+
if let SwitchTargetValue::Normal(value) = value {
543542
// Mark all move paths that correspond to variants other than this one as maybe
544543
// uninitialized (in reality, they are *definitely* uninitialized).
545544
drop_flag_effects::on_all_inactive_variants(

0 commit comments

Comments
 (0)