@@ -1612,47 +1612,27 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16121612 TerminatorKind :: Drop { target, unwind, .. }
16131613 | TerminatorKind :: Assert { target, unwind, .. } => {
16141614 self . assert_iscleanup ( body, block_data, target, is_cleanup) ;
1615- if let UnwindAction :: Cleanup ( 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 }
16221617 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 UnwindAction :: Cleanup ( cleanup) = unwind {
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 UnwindAction :: Cleanup ( 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 }
16461631 TerminatorKind :: InlineAsm { destination, unwind, .. } => {
16471632 if let Some ( target) = destination {
16481633 self . assert_iscleanup ( body, block_data, target, is_cleanup) ;
16491634 }
1650- if let UnwindAction :: Cleanup ( cleanup) = unwind {
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,25 @@ 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+ UnwindAction :: Unreachable => ( ) ,
1668+ }
1669+ }
1670+
16721671 fn check_local ( & mut self , body : & Body < ' tcx > , local : Local , local_decl : & LocalDecl < ' tcx > ) {
16731672 match body. local_kind ( local) {
16741673 LocalKind :: ReturnPointer | LocalKind :: Arg => {
0 commit comments