Skip to content

Commit 1d89aee

Browse files
Auto merge of #148086 - Zalathar:revert-successors, r=<try>
Revert "Streamline iterator chaining when computing successors."
2 parents f435972 + e598c38 commit 1d89aee

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,6 @@ pub use helper::*;
501501

502502
mod helper {
503503
use super::*;
504-
// Note: the methods below use a `slice.chain(Option).chain(Option)` pattern so that all paths
505-
// produce an iterator with the same concrete type.
506504
pub type Successors<'a> = impl DoubleEndedIterator<Item = BasicBlock> + 'a;
507505

508506
impl SwitchTargets {
@@ -512,7 +510,7 @@ mod helper {
512510
#[define_opaque(Successors)]
513511
pub fn successors_for_value(&self, value: u128) -> Successors<'_> {
514512
let target = self.target_for_value(value);
515-
(&[]).into_iter().copied().chain(Some(target)).chain(None)
513+
(&[]).into_iter().copied().chain(Some(target).into_iter().chain(None))
516514
}
517515
}
518516

@@ -524,7 +522,10 @@ mod helper {
524522
match *self {
525523
// 3-successors for async drop: target, unwind, dropline (parent coroutine drop)
526524
Drop { target: ref t, unwind: UnwindAction::Cleanup(u), drop: Some(d), .. } => {
527-
slice::from_ref(t).into_iter().copied().chain(Some(u)).chain(Some(d))
525+
slice::from_ref(t)
526+
.into_iter()
527+
.copied()
528+
.chain(Some(u).into_iter().chain(Some(d)))
528529
}
529530
// 2-successors
530531
Call { target: Some(ref t), unwind: UnwindAction::Cleanup(u), .. }
@@ -533,7 +534,7 @@ mod helper {
533534
| Drop { target: ref t, unwind: _, drop: Some(u), .. }
534535
| Assert { target: ref t, unwind: UnwindAction::Cleanup(u), .. }
535536
| FalseUnwind { real_target: ref t, unwind: UnwindAction::Cleanup(u) } => {
536-
slice::from_ref(t).into_iter().copied().chain(Some(u)).chain(None)
537+
slice::from_ref(t).into_iter().copied().chain(Some(u).into_iter().chain(None))
537538
}
538539
// single successor
539540
Goto { target: ref t }
@@ -543,7 +544,7 @@ mod helper {
543544
| Drop { target: ref t, unwind: _, .. }
544545
| Assert { target: ref t, unwind: _, .. }
545546
| FalseUnwind { real_target: ref t, unwind: _ } => {
546-
slice::from_ref(t).into_iter().copied().chain(None).chain(None)
547+
slice::from_ref(t).into_iter().copied().chain(None.into_iter().chain(None))
547548
}
548549
// No successors
549550
UnwindResume
@@ -553,24 +554,23 @@ mod helper {
553554
| Unreachable
554555
| TailCall { .. }
555556
| Call { target: None, unwind: _, .. } => {
556-
(&[]).into_iter().copied().chain(None).chain(None)
557+
(&[]).into_iter().copied().chain(None.into_iter().chain(None))
557558
}
558559
// Multiple successors
559560
InlineAsm { ref targets, unwind: UnwindAction::Cleanup(u), .. } => {
560-
targets.iter().copied().chain(Some(u)).chain(None)
561+
targets.iter().copied().chain(Some(u).into_iter().chain(None))
561562
}
562563
InlineAsm { ref targets, unwind: _, .. } => {
563-
targets.iter().copied().chain(None).chain(None)
564+
targets.iter().copied().chain(None.into_iter().chain(None))
564565
}
565566
SwitchInt { ref targets, .. } => {
566-
targets.targets.iter().copied().chain(None).chain(None)
567+
targets.targets.iter().copied().chain(None.into_iter().chain(None))
567568
}
568569
// FalseEdge
569570
FalseEdge { ref real_target, imaginary_target } => slice::from_ref(real_target)
570571
.into_iter()
571572
.copied()
572-
.chain(Some(imaginary_target))
573-
.chain(None),
573+
.chain(Some(imaginary_target).into_iter().chain(None)),
574574
}
575575
}
576576

0 commit comments

Comments
 (0)