Skip to content

Commit 4cc0b59

Browse files
committed
Refactor apply_effects_in_block.
Very minor changes that will make the next few commits easier to follow.
1 parent 6171d94 commit 4cc0b59

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

compiler/rustc_mir_dataflow/src/framework/direction.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,11 @@ impl Direction for Backward {
112112

113113
mir::TerminatorKind::SwitchInt { targets: _, ref discr } => {
114114
if let Some(mut data) = analysis.get_switch_int_data(block, discr) {
115-
let values = &body.basic_blocks.switch_sources()[&(block, pred)];
116-
let targets =
117-
values.iter().map(|&value| SwitchIntTarget { value, target: block });
118-
119115
let mut tmp = analysis.bottom_value(body);
120-
for target in targets {
121-
tmp.clone_from(&exit_state);
122-
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, target);
116+
for &value in &body.basic_blocks.switch_sources()[&(block, pred)] {
117+
tmp.clone_from(exit_state);
118+
let si_target = SwitchIntTarget { value, target: block };
119+
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, si_target);
123120
propagate(pred, &tmp);
124121
}
125122
} else {
@@ -292,12 +289,9 @@ impl Direction for Forward {
292289
if let Some(mut data) = analysis.get_switch_int_data(block, discr) {
293290
let mut tmp = analysis.bottom_value(body);
294291
for (value, target) in targets.iter() {
295-
tmp.clone_from(&exit_state);
296-
analysis.apply_switch_int_edge_effect(
297-
&mut data,
298-
&mut tmp,
299-
SwitchIntTarget { value: Some(value), target },
300-
);
292+
tmp.clone_from(exit_state);
293+
let si_target = SwitchIntTarget { value: Some(value), target };
294+
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, si_target);
301295
propagate(target, &tmp);
302296
}
303297

0 commit comments

Comments
 (0)