@@ -1300,7 +1300,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13001300 match & term. kind {
13011301 TerminatorKind :: Goto { .. }
13021302 | TerminatorKind :: Resume
1303- | TerminatorKind :: Abort
1303+ | TerminatorKind :: Terminate
13041304 | TerminatorKind :: Return
13051305 | TerminatorKind :: GeneratorDrop
13061306 | TerminatorKind :: Unreachable
@@ -1584,7 +1584,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15841584 span_mirbug ! ( self , block_data, "resume on non-cleanup block!" )
15851585 }
15861586 }
1587- TerminatorKind :: Abort => {
1587+ TerminatorKind :: Terminate => {
15881588 if !is_cleanup {
15891589 span_mirbug ! ( self , block_data, "abort on non-cleanup block!" )
15901590 }
@@ -1610,49 +1610,29 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16101610 }
16111611 TerminatorKind :: Unreachable => { }
16121612 TerminatorKind :: Drop { target, unwind, .. }
1613- | TerminatorKind :: Assert { target, cleanup : unwind, .. } => {
1613+ | TerminatorKind :: Assert { target, unwind, .. } => {
16141614 self . assert_iscleanup ( body, block_data, target, is_cleanup) ;
1615- if let Some ( unwind) = unwind {
1616- if is_cleanup {
1617- span_mirbug ! ( self , block_data, "unwind on cleanup block" )
1618- }
1619- self . assert_iscleanup ( body, block_data, unwind, true ) ;
1620- }
1615+ self . assert_iscleanup_unwind ( body, block_data, unwind, is_cleanup) ;
16211616 }
1622- TerminatorKind :: Call { ref target, cleanup , .. } => {
1617+ TerminatorKind :: Call { ref target, unwind , .. } => {
16231618 if let & Some ( target) = target {
16241619 self . assert_iscleanup ( body, block_data, target, is_cleanup) ;
16251620 }
1626- if let Some ( cleanup) = cleanup {
1627- if is_cleanup {
1628- span_mirbug ! ( self , block_data, "cleanup on cleanup block" )
1629- }
1630- self . assert_iscleanup ( body, block_data, cleanup, true ) ;
1631- }
1621+ self . assert_iscleanup_unwind ( body, block_data, unwind, is_cleanup) ;
16321622 }
16331623 TerminatorKind :: FalseEdge { real_target, imaginary_target } => {
16341624 self . assert_iscleanup ( body, block_data, real_target, is_cleanup) ;
16351625 self . assert_iscleanup ( body, block_data, imaginary_target, is_cleanup) ;
16361626 }
16371627 TerminatorKind :: FalseUnwind { real_target, unwind } => {
16381628 self . assert_iscleanup ( body, block_data, real_target, is_cleanup) ;
1639- if let Some ( unwind) = unwind {
1640- if is_cleanup {
1641- span_mirbug ! ( self , block_data, "cleanup in cleanup block via false unwind" ) ;
1642- }
1643- self . assert_iscleanup ( body, block_data, unwind, true ) ;
1644- }
1629+ self . assert_iscleanup_unwind ( body, block_data, unwind, is_cleanup) ;
16451630 }
1646- TerminatorKind :: InlineAsm { destination, cleanup , .. } => {
1631+ TerminatorKind :: InlineAsm { destination, unwind , .. } => {
16471632 if let Some ( target) = destination {
16481633 self . assert_iscleanup ( body, block_data, target, is_cleanup) ;
16491634 }
1650- if let Some ( cleanup) = cleanup {
1651- if is_cleanup {
1652- span_mirbug ! ( self , block_data, "cleanup on cleanup block" )
1653- }
1654- self . assert_iscleanup ( body, block_data, cleanup, true ) ;
1655- }
1635+ self . assert_iscleanup_unwind ( body, block_data, unwind, is_cleanup) ;
16561636 }
16571637 }
16581638 }
@@ -1669,6 +1649,29 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16691649 }
16701650 }
16711651
1652+ fn assert_iscleanup_unwind (
1653+ & mut self ,
1654+ body : & Body < ' tcx > ,
1655+ ctxt : & dyn fmt:: Debug ,
1656+ unwind : UnwindAction ,
1657+ is_cleanup : bool ,
1658+ ) {
1659+ match unwind {
1660+ UnwindAction :: Cleanup ( unwind) => {
1661+ if is_cleanup {
1662+ span_mirbug ! ( self , ctxt, "unwind on cleanup block" )
1663+ }
1664+ self . assert_iscleanup ( body, ctxt, unwind, true ) ;
1665+ }
1666+ UnwindAction :: Continue => {
1667+ if is_cleanup {
1668+ span_mirbug ! ( self , ctxt, "unwind on cleanup block" )
1669+ }
1670+ }
1671+ UnwindAction :: Unreachable | UnwindAction :: Terminate => ( ) ,
1672+ }
1673+ }
1674+
16721675 fn check_local ( & mut self , body : & Body < ' tcx > , local : Local , local_decl : & LocalDecl < ' tcx > ) {
16731676 match body. local_kind ( local) {
16741677 LocalKind :: ReturnPointer | LocalKind :: Arg => {
0 commit comments