@@ -377,9 +377,6 @@ pub struct Terminator<'tcx> {
377
377
pub kind : TerminatorKind < ' tcx > ,
378
378
}
379
379
380
- pub type Successors < ' a > = impl DoubleEndedIterator < Item = BasicBlock > + ' a ;
381
- pub type SuccessorsMut < ' a > = impl DoubleEndedIterator < Item = & ' a mut BasicBlock > + ' a ;
382
-
383
380
impl < ' tcx > Terminator < ' tcx > {
384
381
#[ inline]
385
382
pub fn successors ( & self ) -> Successors < ' _ > {
@@ -407,81 +404,95 @@ impl<'tcx> TerminatorKind<'tcx> {
407
404
pub fn if_ ( cond : Operand < ' tcx > , t : BasicBlock , f : BasicBlock ) -> TerminatorKind < ' tcx > {
408
405
TerminatorKind :: SwitchInt { discr : cond, targets : SwitchTargets :: static_if ( 0 , f, t) }
409
406
}
407
+ }
410
408
411
- #[ inline]
412
- pub fn successors ( & self ) -> Successors < ' _ > {
413
- use self :: TerminatorKind :: * ;
414
- match * self {
415
- Call { target : Some ( ref t) , unwind : UnwindAction :: Cleanup ( u) , .. }
416
- | Yield { resume : ref t, drop : Some ( u) , .. }
417
- | Drop { target : ref t, unwind : UnwindAction :: Cleanup ( u) , .. }
418
- | Assert { target : ref t, unwind : UnwindAction :: Cleanup ( u) , .. }
419
- | FalseUnwind { real_target : ref t, unwind : UnwindAction :: Cleanup ( u) } => {
420
- slice:: from_ref ( t) . into_iter ( ) . copied ( ) . chain ( Some ( u) )
421
- }
422
- Goto { target : ref t }
423
- | Call { target : None , unwind : UnwindAction :: Cleanup ( ref t) , .. }
424
- | Call { target : Some ( ref t) , unwind : _, .. }
425
- | Yield { resume : ref t, drop : None , .. }
426
- | Drop { target : ref t, unwind : _, .. }
427
- | Assert { target : ref t, unwind : _, .. }
428
- | FalseUnwind { real_target : ref t, unwind : _ } => {
429
- slice:: from_ref ( t) . into_iter ( ) . copied ( ) . chain ( None )
430
- }
431
- UnwindResume
432
- | UnwindTerminate ( _)
433
- | CoroutineDrop
434
- | Return
435
- | Unreachable
436
- | Call { target : None , unwind : _, .. } => ( & [ ] ) . into_iter ( ) . copied ( ) . chain ( None ) ,
437
- InlineAsm { ref targets, unwind : UnwindAction :: Cleanup ( u) , .. } => {
438
- targets. iter ( ) . copied ( ) . chain ( Some ( u) )
439
- }
440
- InlineAsm { ref targets, unwind : _, .. } => targets. iter ( ) . copied ( ) . chain ( None ) ,
441
- SwitchInt { ref targets, .. } => targets. targets . iter ( ) . copied ( ) . chain ( None ) ,
442
- FalseEdge { ref real_target, imaginary_target } => {
443
- slice:: from_ref ( real_target) . into_iter ( ) . copied ( ) . chain ( Some ( imaginary_target) )
409
+ pub use helper:: * ;
410
+
411
+ mod helper {
412
+ use super :: * ;
413
+ pub type Successors < ' a > = impl DoubleEndedIterator < Item = BasicBlock > + ' a ;
414
+ pub type SuccessorsMut < ' a > = impl DoubleEndedIterator < Item = & ' a mut BasicBlock > + ' a ;
415
+ impl < ' tcx > TerminatorKind < ' tcx > {
416
+ #[ inline]
417
+ pub fn successors ( & self ) -> Successors < ' _ > {
418
+ use self :: TerminatorKind :: * ;
419
+ match * self {
420
+ Call { target : Some ( ref t) , unwind : UnwindAction :: Cleanup ( u) , .. }
421
+ | Yield { resume : ref t, drop : Some ( u) , .. }
422
+ | Drop { target : ref t, unwind : UnwindAction :: Cleanup ( u) , .. }
423
+ | Assert { target : ref t, unwind : UnwindAction :: Cleanup ( u) , .. }
424
+ | FalseUnwind { real_target : ref t, unwind : UnwindAction :: Cleanup ( u) } => {
425
+ slice:: from_ref ( t) . into_iter ( ) . copied ( ) . chain ( Some ( u) )
426
+ }
427
+ Goto { target : ref t }
428
+ | Call { target : None , unwind : UnwindAction :: Cleanup ( ref t) , .. }
429
+ | Call { target : Some ( ref t) , unwind : _, .. }
430
+ | Yield { resume : ref t, drop : None , .. }
431
+ | Drop { target : ref t, unwind : _, .. }
432
+ | Assert { target : ref t, unwind : _, .. }
433
+ | FalseUnwind { real_target : ref t, unwind : _ } => {
434
+ slice:: from_ref ( t) . into_iter ( ) . copied ( ) . chain ( None )
435
+ }
436
+ UnwindResume
437
+ | UnwindTerminate ( _)
438
+ | CoroutineDrop
439
+ | Return
440
+ | Unreachable
441
+ | Call { target : None , unwind : _, .. } => ( & [ ] ) . into_iter ( ) . copied ( ) . chain ( None ) ,
442
+ InlineAsm { ref targets, unwind : UnwindAction :: Cleanup ( u) , .. } => {
443
+ targets. iter ( ) . copied ( ) . chain ( Some ( u) )
444
+ }
445
+ InlineAsm { ref targets, unwind : _, .. } => targets. iter ( ) . copied ( ) . chain ( None ) ,
446
+ SwitchInt { ref targets, .. } => targets. targets . iter ( ) . copied ( ) . chain ( None ) ,
447
+ FalseEdge { ref real_target, imaginary_target } => {
448
+ slice:: from_ref ( real_target) . into_iter ( ) . copied ( ) . chain ( Some ( imaginary_target) )
449
+ }
444
450
}
445
451
}
446
- }
447
452
448
- #[ inline]
449
- pub fn successors_mut ( & mut self ) -> SuccessorsMut < ' _ > {
450
- use self :: TerminatorKind :: * ;
451
- match * self {
452
- Call { target : Some ( ref mut t) , unwind : UnwindAction :: Cleanup ( ref mut u) , .. }
453
- | Yield { resume : ref mut t, drop : Some ( ref mut u) , .. }
454
- | Drop { target : ref mut t, unwind : UnwindAction :: Cleanup ( ref mut u) , .. }
455
- | Assert { target : ref mut t, unwind : UnwindAction :: Cleanup ( ref mut u) , .. }
456
- | FalseUnwind { real_target : ref mut t, unwind : UnwindAction :: Cleanup ( ref mut u) } => {
457
- slice:: from_mut ( t) . into_iter ( ) . chain ( Some ( u) )
458
- }
459
- Goto { target : ref mut t }
460
- | Call { target : None , unwind : UnwindAction :: Cleanup ( ref mut t) , .. }
461
- | Call { target : Some ( ref mut t) , unwind : _, .. }
462
- | Yield { resume : ref mut t, drop : None , .. }
463
- | Drop { target : ref mut t, unwind : _, .. }
464
- | Assert { target : ref mut t, unwind : _, .. }
465
- | FalseUnwind { real_target : ref mut t, unwind : _ } => {
466
- slice:: from_mut ( t) . into_iter ( ) . chain ( None )
467
- }
468
- UnwindResume
469
- | UnwindTerminate ( _)
470
- | CoroutineDrop
471
- | Return
472
- | Unreachable
473
- | Call { target : None , unwind : _, .. } => ( & mut [ ] ) . into_iter ( ) . chain ( None ) ,
474
- InlineAsm { ref mut targets, unwind : UnwindAction :: Cleanup ( ref mut u) , .. } => {
475
- targets. iter_mut ( ) . chain ( Some ( u) )
476
- }
477
- InlineAsm { ref mut targets, unwind : _, .. } => targets. iter_mut ( ) . chain ( None ) ,
478
- SwitchInt { ref mut targets, .. } => targets. targets . iter_mut ( ) . chain ( None ) ,
479
- FalseEdge { ref mut real_target, ref mut imaginary_target } => {
480
- slice:: from_mut ( real_target) . into_iter ( ) . chain ( Some ( imaginary_target) )
453
+ #[ inline]
454
+ pub fn successors_mut ( & mut self ) -> SuccessorsMut < ' _ > {
455
+ use self :: TerminatorKind :: * ;
456
+ match * self {
457
+ Call {
458
+ target : Some ( ref mut t) , unwind : UnwindAction :: Cleanup ( ref mut u) , ..
459
+ }
460
+ | Yield { resume : ref mut t, drop : Some ( ref mut u) , .. }
461
+ | Drop { target : ref mut t, unwind : UnwindAction :: Cleanup ( ref mut u) , .. }
462
+ | Assert { target : ref mut t, unwind : UnwindAction :: Cleanup ( ref mut u) , .. }
463
+ | FalseUnwind {
464
+ real_target : ref mut t,
465
+ unwind : UnwindAction :: Cleanup ( ref mut u) ,
466
+ } => slice:: from_mut ( t) . into_iter ( ) . chain ( Some ( u) ) ,
467
+ Goto { target : ref mut t }
468
+ | Call { target : None , unwind : UnwindAction :: Cleanup ( ref mut t) , .. }
469
+ | Call { target : Some ( ref mut t) , unwind : _, .. }
470
+ | Yield { resume : ref mut t, drop : None , .. }
471
+ | Drop { target : ref mut t, unwind : _, .. }
472
+ | Assert { target : ref mut t, unwind : _, .. }
473
+ | FalseUnwind { real_target : ref mut t, unwind : _ } => {
474
+ slice:: from_mut ( t) . into_iter ( ) . chain ( None )
475
+ }
476
+ UnwindResume
477
+ | UnwindTerminate ( _)
478
+ | CoroutineDrop
479
+ | Return
480
+ | Unreachable
481
+ | Call { target : None , unwind : _, .. } => ( & mut [ ] ) . into_iter ( ) . chain ( None ) ,
482
+ InlineAsm { ref mut targets, unwind : UnwindAction :: Cleanup ( ref mut u) , .. } => {
483
+ targets. iter_mut ( ) . chain ( Some ( u) )
484
+ }
485
+ InlineAsm { ref mut targets, unwind : _, .. } => targets. iter_mut ( ) . chain ( None ) ,
486
+ SwitchInt { ref mut targets, .. } => targets. targets . iter_mut ( ) . chain ( None ) ,
487
+ FalseEdge { ref mut real_target, ref mut imaginary_target } => {
488
+ slice:: from_mut ( real_target) . into_iter ( ) . chain ( Some ( imaginary_target) )
489
+ }
481
490
}
482
491
}
483
492
}
493
+ }
484
494
495
+ impl < ' tcx > TerminatorKind < ' tcx > {
485
496
#[ inline]
486
497
pub fn unwind ( & self ) -> Option < & UnwindAction > {
487
498
match * self {
0 commit comments