@@ -55,7 +55,7 @@ pub trait Direction {
5555 body : & mir:: Body < ' tcx > ,
5656 exit_state : & mut A :: Domain ,
5757 block : ( BasicBlock , & ' _ mir:: BasicBlockData < ' tcx > ) ,
58- propagate : impl FnMut ( BasicBlock , & A :: Domain ) ,
58+ propagate : impl FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
5959 ) where
6060 A : Analysis < ' tcx > ;
6161}
@@ -221,7 +221,7 @@ impl Direction for Backward {
221221 body : & mir:: Body < ' tcx > ,
222222 exit_state : & mut A :: Domain ,
223223 ( bb, _bb_data) : ( BasicBlock , & ' _ mir:: BasicBlockData < ' tcx > ) ,
224- mut propagate : impl FnMut ( BasicBlock , & A :: Domain ) ,
224+ mut propagate : impl FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
225225 ) where
226226 A : Analysis < ' tcx > ,
227227 {
@@ -237,7 +237,7 @@ impl Direction for Backward {
237237 pred,
238238 CallReturnPlaces :: Call ( destination) ,
239239 ) ;
240- propagate ( pred, & tmp) ;
240+ propagate ( analysis , pred, & tmp) ;
241241 }
242242
243243 mir:: TerminatorKind :: InlineAsm {
@@ -249,13 +249,13 @@ impl Direction for Backward {
249249 pred,
250250 CallReturnPlaces :: InlineAsm ( operands) ,
251251 ) ;
252- propagate ( pred, & tmp) ;
252+ propagate ( analysis , pred, & tmp) ;
253253 }
254254
255255 mir:: TerminatorKind :: Yield { resume, resume_arg, .. } if resume == bb => {
256256 let mut tmp = exit_state. clone ( ) ;
257257 analysis. apply_yield_resume_effect ( & mut tmp, resume, resume_arg) ;
258- propagate ( pred, & tmp) ;
258+ propagate ( analysis , pred, & tmp) ;
259259 }
260260
261261 mir:: TerminatorKind :: SwitchInt { targets : _, ref discr } => {
@@ -271,11 +271,11 @@ impl Direction for Backward {
271271 analysis. apply_switch_int_edge_effects ( pred, discr, & mut applier) ;
272272
273273 if !applier. effects_applied {
274- propagate ( pred, exit_state)
274+ propagate ( analysis , pred, exit_state)
275275 }
276276 }
277277
278- _ => propagate ( pred, exit_state) ,
278+ _ => propagate ( analysis , pred, exit_state) ,
279279 }
280280 }
281281 }
@@ -290,12 +290,17 @@ struct BackwardSwitchIntEdgeEffectsApplier<'a, 'tcx, D, F> {
290290 effects_applied : bool ,
291291}
292292
293- impl < D , F > super :: SwitchIntEdgeEffects < D > for BackwardSwitchIntEdgeEffectsApplier < ' _ , ' _ , D , F >
293+ impl < ' tcx , A , F > super :: SwitchIntEdgeEffects < ' tcx , A >
294+ for BackwardSwitchIntEdgeEffectsApplier < ' _ , ' _ , A :: Domain , F >
294295where
295- D : Clone ,
296- F : FnMut ( BasicBlock , & D ) ,
296+ A : Analysis < ' tcx > ,
297+ F : FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
297298{
298- fn apply ( & mut self , mut apply_edge_effect : impl FnMut ( & mut D , SwitchIntTarget ) ) {
299+ fn apply (
300+ & mut self ,
301+ analysis : & mut A ,
302+ mut apply_edge_effect : impl FnMut ( & mut A , & mut A :: Domain , SwitchIntTarget ) ,
303+ ) {
299304 assert ! ( !self . effects_applied) ;
300305
301306 let values = & self . body . basic_blocks . switch_sources ( ) [ & ( self . bb , self . pred ) ] ;
@@ -304,8 +309,8 @@ where
304309 let mut tmp = None ;
305310 for target in targets {
306311 let tmp = opt_clone_from_or_clone ( & mut tmp, self . exit_state ) ;
307- apply_edge_effect ( tmp, target) ;
308- ( self . propagate ) ( self . pred , tmp) ;
312+ apply_edge_effect ( analysis , tmp, target) ;
313+ ( self . propagate ) ( analysis , self . pred , tmp) ;
309314 }
310315
311316 self . effects_applied = true ;
@@ -468,43 +473,43 @@ impl Direction for Forward {
468473 _body : & mir:: Body < ' tcx > ,
469474 exit_state : & mut A :: Domain ,
470475 ( bb, bb_data) : ( BasicBlock , & ' _ mir:: BasicBlockData < ' tcx > ) ,
471- mut propagate : impl FnMut ( BasicBlock , & A :: Domain ) ,
476+ mut propagate : impl FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
472477 ) where
473478 A : Analysis < ' tcx > ,
474479 {
475480 use mir:: TerminatorKind :: * ;
476481 match bb_data. terminator ( ) . kind {
477482 Return | Resume | Terminate | GeneratorDrop | Unreachable => { }
478483
479- Goto { target } => propagate ( target, exit_state) ,
484+ Goto { target } => propagate ( analysis , target, exit_state) ,
480485
481486 Assert { target, unwind, expected : _, msg : _, cond : _ }
482487 | Drop { target, unwind, place : _, replace : _ }
483488 | FalseUnwind { real_target : target, unwind } => {
484489 if let UnwindAction :: Cleanup ( unwind) = unwind {
485- propagate ( unwind, exit_state) ;
490+ propagate ( analysis , unwind, exit_state) ;
486491 }
487492
488- propagate ( target, exit_state) ;
493+ propagate ( analysis , target, exit_state) ;
489494 }
490495
491496 FalseEdge { real_target, imaginary_target } => {
492- propagate ( real_target, exit_state) ;
493- propagate ( imaginary_target, exit_state) ;
497+ propagate ( analysis , real_target, exit_state) ;
498+ propagate ( analysis , imaginary_target, exit_state) ;
494499 }
495500
496501 Yield { resume : target, drop, resume_arg, value : _ } => {
497502 if let Some ( drop) = drop {
498- propagate ( drop, exit_state) ;
503+ propagate ( analysis , drop, exit_state) ;
499504 }
500505
501506 analysis. apply_yield_resume_effect ( exit_state, target, resume_arg) ;
502- propagate ( target, exit_state) ;
507+ propagate ( analysis , target, exit_state) ;
503508 }
504509
505510 Call { unwind, destination, target, func : _, args : _, call_source : _, fn_span : _ } => {
506511 if let UnwindAction :: Cleanup ( unwind) = unwind {
507- propagate ( unwind, exit_state) ;
512+ propagate ( analysis , unwind, exit_state) ;
508513 }
509514
510515 if let Some ( target) = target {
@@ -515,7 +520,7 @@ impl Direction for Forward {
515520 bb,
516521 CallReturnPlaces :: Call ( destination) ,
517522 ) ;
518- propagate ( target, exit_state) ;
523+ propagate ( analysis , target, exit_state) ;
519524 }
520525 }
521526
@@ -528,7 +533,7 @@ impl Direction for Forward {
528533 unwind,
529534 } => {
530535 if let UnwindAction :: Cleanup ( unwind) = unwind {
531- propagate ( unwind, exit_state) ;
536+ propagate ( analysis , unwind, exit_state) ;
532537 }
533538
534539 if let Some ( target) = destination {
@@ -539,7 +544,7 @@ impl Direction for Forward {
539544 bb,
540545 CallReturnPlaces :: InlineAsm ( operands) ,
541546 ) ;
542- propagate ( target, exit_state) ;
547+ propagate ( analysis , target, exit_state) ;
543548 }
544549 }
545550
@@ -562,7 +567,7 @@ impl Direction for Forward {
562567
563568 if !effects_applied {
564569 for target in targets. all_targets ( ) {
565- propagate ( * target, exit_state) ;
570+ propagate ( analysis , * target, exit_state) ;
566571 }
567572 }
568573 }
@@ -578,26 +583,35 @@ struct ForwardSwitchIntEdgeEffectsApplier<'a, D, F> {
578583 effects_applied : bool ,
579584}
580585
581- impl < D , F > super :: SwitchIntEdgeEffects < D > for ForwardSwitchIntEdgeEffectsApplier < ' _ , D , F >
586+ impl < ' tcx , A , F > super :: SwitchIntEdgeEffects < ' tcx , A >
587+ for ForwardSwitchIntEdgeEffectsApplier < ' _ , A :: Domain , F >
582588where
583- D : Clone ,
584- F : FnMut ( BasicBlock , & D ) ,
589+ A : Analysis < ' tcx > ,
590+ F : FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
585591{
586- fn apply ( & mut self , mut apply_edge_effect : impl FnMut ( & mut D , SwitchIntTarget ) ) {
592+ fn apply (
593+ & mut self ,
594+ analysis : & mut A ,
595+ mut apply_edge_effect : impl FnMut ( & mut A , & mut A :: Domain , SwitchIntTarget ) ,
596+ ) {
587597 assert ! ( !self . effects_applied) ;
588598
589599 let mut tmp = None ;
590600 for ( value, target) in self . targets . iter ( ) {
591601 let tmp = opt_clone_from_or_clone ( & mut tmp, self . exit_state ) ;
592- apply_edge_effect ( tmp, SwitchIntTarget { value : Some ( value) , target } ) ;
593- ( self . propagate ) ( target, tmp) ;
602+ apply_edge_effect ( analysis , tmp, SwitchIntTarget { value : Some ( value) , target } ) ;
603+ ( self . propagate ) ( analysis , target, tmp) ;
594604 }
595605
596606 // Once we get to the final, "otherwise" branch, there is no need to preserve `exit_state`,
597607 // so pass it directly to `apply_edge_effect` to save a clone of the dataflow state.
598608 let otherwise = self . targets . otherwise ( ) ;
599- apply_edge_effect ( self . exit_state , SwitchIntTarget { value : None , target : otherwise } ) ;
600- ( self . propagate ) ( otherwise, self . exit_state ) ;
609+ apply_edge_effect (
610+ analysis,
611+ self . exit_state ,
612+ SwitchIntTarget { value : None , target : otherwise } ,
613+ ) ;
614+ ( self . propagate ) ( analysis, otherwise, self . exit_state ) ;
601615
602616 self . effects_applied = true ;
603617 }
0 commit comments