Skip to content

Commit 3b77583

Browse files
committed
Simplify can_unwind.
1 parent d332a12 commit 3b77583

1 file changed

Lines changed: 1 addition & 33 deletions

File tree

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,40 +1173,8 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
11731173
}
11741174

11751175
// Unwinds can only start at certain terminators.
1176-
for block in body.basic_blocks.iter() {
1177-
match block.terminator().kind {
1178-
// These never unwind.
1179-
TerminatorKind::Goto { .. }
1180-
| TerminatorKind::SwitchInt { .. }
1181-
| TerminatorKind::UnwindTerminate(_)
1182-
| TerminatorKind::Return
1183-
| TerminatorKind::Unreachable
1184-
| TerminatorKind::CoroutineDrop
1185-
| TerminatorKind::FalseEdge { .. }
1186-
| TerminatorKind::FalseUnwind { .. } => {}
1187-
1188-
// Resume will *continue* unwinding, but if there's no other unwinding terminator it
1189-
// will never be reached.
1190-
TerminatorKind::UnwindResume => {}
1191-
1192-
TerminatorKind::Yield { .. } => {
1193-
unreachable!("`can_unwind` called before coroutine transform")
1194-
}
1195-
1196-
// These may unwind.
1197-
TerminatorKind::Drop { .. }
1198-
| TerminatorKind::Call { .. }
1199-
| TerminatorKind::InlineAsm { .. }
1200-
| TerminatorKind::Assert { .. } => return true,
1201-
1202-
TerminatorKind::TailCall { .. } => {
1203-
unreachable!("tail calls can't be present in generators")
1204-
}
1205-
}
1206-
}
1207-
1176+
body.basic_blocks.iter().any(|block| block.terminator().unwind().is_some())
12081177
// If we didn't find an unwinding terminator, the function cannot unwind.
1209-
false
12101178
}
12111179

12121180
// Poison the coroutine when it unwinds

0 commit comments

Comments
 (0)