@@ -284,7 +284,6 @@ pub struct Terminator<'tcx> {
284
284
pub kind : TerminatorKind < ' tcx > ,
285
285
}
286
286
287
- pub type Successors < ' a > = impl DoubleEndedIterator < Item = BasicBlock > + ' a ;
288
287
pub type SuccessorsMut < ' a > =
289
288
iter:: Chain < std:: option:: IntoIter < & ' a mut BasicBlock > , slice:: IterMut < ' a , BasicBlock > > ;
290
289
@@ -310,47 +309,57 @@ impl<'tcx> TerminatorKind<'tcx> {
310
309
pub fn if_ ( cond : Operand < ' tcx > , t : BasicBlock , f : BasicBlock ) -> TerminatorKind < ' tcx > {
311
310
TerminatorKind :: SwitchInt { discr : cond, targets : SwitchTargets :: static_if ( 0 , f, t) }
312
311
}
312
+ }
313
313
314
- pub fn successors ( & self ) -> Successors < ' _ > {
315
- use self :: TerminatorKind :: * ;
316
- match * self {
317
- Call { target : Some ( t) , unwind : UnwindAction :: Cleanup ( ref u) , .. }
318
- | Yield { resume : t, drop : Some ( ref u) , .. }
319
- | Drop { target : t, unwind : UnwindAction :: Cleanup ( ref u) , .. }
320
- | Assert { target : t, unwind : UnwindAction :: Cleanup ( ref u) , .. }
321
- | FalseUnwind { real_target : t, unwind : UnwindAction :: Cleanup ( ref u) }
322
- | InlineAsm { destination : Some ( t) , unwind : UnwindAction :: Cleanup ( ref u) , .. } => {
323
- Some ( t) . into_iter ( ) . chain ( slice:: from_ref ( u) . into_iter ( ) . copied ( ) )
324
- }
325
- Goto { target : t }
326
- | Call { target : None , unwind : UnwindAction :: Cleanup ( t) , .. }
327
- | Call { target : Some ( t) , unwind : _, .. }
328
- | Yield { resume : t, drop : None , .. }
329
- | Drop { target : t, unwind : _, .. }
330
- | Assert { target : t, unwind : _, .. }
331
- | FalseUnwind { real_target : t, unwind : _ }
332
- | InlineAsm { destination : None , unwind : UnwindAction :: Cleanup ( t) , .. }
333
- | InlineAsm { destination : Some ( t) , unwind : _, .. } => {
334
- Some ( t) . into_iter ( ) . chain ( ( & [ ] ) . into_iter ( ) . copied ( ) )
335
- }
336
- UnwindResume
337
- | UnwindTerminate ( _)
338
- | CoroutineDrop
339
- | Return
340
- | Unreachable
341
- | Call { target : None , unwind : _, .. }
342
- | InlineAsm { destination : None , unwind : _, .. } => {
343
- None . into_iter ( ) . chain ( ( & [ ] ) . into_iter ( ) . copied ( ) )
344
- }
345
- SwitchInt { ref targets, .. } => {
346
- None . into_iter ( ) . chain ( targets. targets . iter ( ) . copied ( ) )
314
+ pub use helper:: * ;
315
+
316
+ mod helper {
317
+ use super :: * ;
318
+ pub type Successors < ' a > = impl DoubleEndedIterator < Item = BasicBlock > + ' a ;
319
+ impl < ' tcx > TerminatorKind < ' tcx > {
320
+ pub fn successors ( & self ) -> Successors < ' _ > {
321
+ use self :: TerminatorKind :: * ;
322
+ match * self {
323
+ Call { target : Some ( t) , unwind : UnwindAction :: Cleanup ( ref u) , .. }
324
+ | Yield { resume : t, drop : Some ( ref u) , .. }
325
+ | Drop { target : t, unwind : UnwindAction :: Cleanup ( ref u) , .. }
326
+ | Assert { target : t, unwind : UnwindAction :: Cleanup ( ref u) , .. }
327
+ | FalseUnwind { real_target : t, unwind : UnwindAction :: Cleanup ( ref u) }
328
+ | InlineAsm {
329
+ destination : Some ( t) , unwind : UnwindAction :: Cleanup ( ref u) , ..
330
+ } => Some ( t) . into_iter ( ) . chain ( slice:: from_ref ( u) . into_iter ( ) . copied ( ) ) ,
331
+ Goto { target : t }
332
+ | Call { target : None , unwind : UnwindAction :: Cleanup ( t) , .. }
333
+ | Call { target : Some ( t) , unwind : _, .. }
334
+ | Yield { resume : t, drop : None , .. }
335
+ | Drop { target : t, unwind : _, .. }
336
+ | Assert { target : t, unwind : _, .. }
337
+ | FalseUnwind { real_target : t, unwind : _ }
338
+ | InlineAsm { destination : None , unwind : UnwindAction :: Cleanup ( t) , .. }
339
+ | InlineAsm { destination : Some ( t) , unwind : _, .. } => {
340
+ Some ( t) . into_iter ( ) . chain ( ( & [ ] ) . into_iter ( ) . copied ( ) )
341
+ }
342
+ UnwindResume
343
+ | UnwindTerminate ( _)
344
+ | CoroutineDrop
345
+ | Return
346
+ | Unreachable
347
+ | Call { target : None , unwind : _, .. }
348
+ | InlineAsm { destination : None , unwind : _, .. } => {
349
+ None . into_iter ( ) . chain ( ( & [ ] ) . into_iter ( ) . copied ( ) )
350
+ }
351
+ SwitchInt { ref targets, .. } => {
352
+ None . into_iter ( ) . chain ( targets. targets . iter ( ) . copied ( ) )
353
+ }
354
+ FalseEdge { real_target, ref imaginary_target } => Some ( real_target)
355
+ . into_iter ( )
356
+ . chain ( slice:: from_ref ( imaginary_target) . into_iter ( ) . copied ( ) ) ,
347
357
}
348
- FalseEdge { real_target, ref imaginary_target } => Some ( real_target)
349
- . into_iter ( )
350
- . chain ( slice:: from_ref ( imaginary_target) . into_iter ( ) . copied ( ) ) ,
351
358
}
352
359
}
360
+ }
353
361
362
+ impl < ' tcx > TerminatorKind < ' tcx > {
354
363
pub fn successors_mut ( & mut self ) -> SuccessorsMut < ' _ > {
355
364
use self :: TerminatorKind :: * ;
356
365
match * self {
0 commit comments