@@ -56,7 +56,7 @@ pub trait Direction {
5656 exit_state : & mut A :: Domain ,
5757 block : BasicBlock ,
5858 edges : TerminatorEdges < ' _ , ' tcx > ,
59- propagate : impl FnMut ( BasicBlock , & A :: Domain ) ,
59+ propagate : impl FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
6060 ) where
6161 A : Analysis < ' tcx > ;
6262}
@@ -223,7 +223,7 @@ impl Direction for Backward {
223223 exit_state : & mut A :: Domain ,
224224 bb : BasicBlock ,
225225 _edges : TerminatorEdges < ' _ , ' tcx > ,
226- mut propagate : impl FnMut ( BasicBlock , & A :: Domain ) ,
226+ mut propagate : impl FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
227227 ) where
228228 A : Analysis < ' tcx > ,
229229 {
@@ -239,7 +239,7 @@ impl Direction for Backward {
239239 pred,
240240 CallReturnPlaces :: Call ( destination) ,
241241 ) ;
242- propagate ( pred, & tmp) ;
242+ propagate ( analysis , pred, & tmp) ;
243243 }
244244
245245 mir:: TerminatorKind :: InlineAsm {
@@ -251,7 +251,7 @@ impl Direction for Backward {
251251 pred,
252252 CallReturnPlaces :: InlineAsm ( operands) ,
253253 ) ;
254- propagate ( pred, & tmp) ;
254+ propagate ( analysis , pred, & tmp) ;
255255 }
256256
257257 mir:: TerminatorKind :: Yield { resume, resume_arg, .. } if resume == bb => {
@@ -261,7 +261,7 @@ impl Direction for Backward {
261261 resume,
262262 CallReturnPlaces :: Yield ( resume_arg) ,
263263 ) ;
264- propagate ( pred, & tmp) ;
264+ propagate ( analysis , pred, & tmp) ;
265265 }
266266
267267 mir:: TerminatorKind :: SwitchInt { targets : _, ref discr } => {
@@ -277,11 +277,11 @@ impl Direction for Backward {
277277 analysis. apply_switch_int_edge_effects ( pred, discr, & mut applier) ;
278278
279279 if !applier. effects_applied {
280- propagate ( pred, exit_state)
280+ propagate ( analysis , pred, exit_state)
281281 }
282282 }
283283
284- _ => propagate ( pred, exit_state) ,
284+ _ => propagate ( analysis , pred, exit_state) ,
285285 }
286286 }
287287 }
@@ -296,12 +296,17 @@ struct BackwardSwitchIntEdgeEffectsApplier<'mir, 'tcx, D, F> {
296296 effects_applied : bool ,
297297}
298298
299- impl < D , F > super :: SwitchIntEdgeEffects < D > for BackwardSwitchIntEdgeEffectsApplier < ' _ , ' _ , D , F >
299+ impl < ' tcx , A , F > super :: SwitchIntEdgeEffects < ' tcx , A >
300+ for BackwardSwitchIntEdgeEffectsApplier < ' _ , ' _ , A :: Domain , F >
300301where
301- D : Clone ,
302- F : FnMut ( BasicBlock , & D ) ,
302+ A : Analysis < ' tcx > ,
303+ F : FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
303304{
304- fn apply ( & mut self , mut apply_edge_effect : impl FnMut ( & mut D , SwitchIntTarget ) ) {
305+ fn apply (
306+ & mut self ,
307+ analysis : & mut A ,
308+ mut apply_edge_effect : impl FnMut ( & mut A , & mut A :: Domain , SwitchIntTarget ) ,
309+ ) {
305310 assert ! ( !self . effects_applied) ;
306311
307312 let values = & self . body . basic_blocks . switch_sources ( ) [ & ( self . bb , self . pred ) ] ;
@@ -310,8 +315,8 @@ where
310315 let mut tmp = None ;
311316 for target in targets {
312317 let tmp = opt_clone_from_or_clone ( & mut tmp, self . exit_state ) ;
313- apply_edge_effect ( tmp, target) ;
314- ( self . propagate ) ( self . pred , tmp) ;
318+ apply_edge_effect ( analysis , tmp, target) ;
319+ ( self . propagate ) ( analysis , self . pred , tmp) ;
315320 }
316321
317322 self . effects_applied = true ;
@@ -475,25 +480,25 @@ impl Direction for Forward {
475480 exit_state : & mut A :: Domain ,
476481 bb : BasicBlock ,
477482 edges : TerminatorEdges < ' _ , ' tcx > ,
478- mut propagate : impl FnMut ( BasicBlock , & A :: Domain ) ,
483+ mut propagate : impl FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
479484 ) where
480485 A : Analysis < ' tcx > ,
481486 {
482487 match edges {
483488 TerminatorEdges :: None => { }
484- TerminatorEdges :: Single ( target) => propagate ( target, exit_state) ,
489+ TerminatorEdges :: Single ( target) => propagate ( analysis , target, exit_state) ,
485490 TerminatorEdges :: Double ( target, unwind) => {
486- propagate ( target, exit_state) ;
487- propagate ( unwind, exit_state) ;
491+ propagate ( analysis , target, exit_state) ;
492+ propagate ( analysis , unwind, exit_state) ;
488493 }
489494 TerminatorEdges :: AssignOnReturn { return_, cleanup, place } => {
490495 // This must be done *first*, otherwise the unwind path will see the assignments.
491496 if let Some ( cleanup) = cleanup {
492- propagate ( cleanup, exit_state) ;
497+ propagate ( analysis , cleanup, exit_state) ;
493498 }
494499 if let Some ( return_) = return_ {
495500 analysis. apply_call_return_effect ( exit_state, bb, place) ;
496- propagate ( return_, exit_state) ;
501+ propagate ( analysis , return_, exit_state) ;
497502 }
498503 }
499504 TerminatorEdges :: SwitchInt { targets, discr } => {
@@ -515,7 +520,7 @@ impl Direction for Forward {
515520
516521 if !effects_applied {
517522 for target in targets. all_targets ( ) {
518- propagate ( * target, exit_state) ;
523+ propagate ( analysis , * target, exit_state) ;
519524 }
520525 }
521526 }
@@ -531,26 +536,35 @@ struct ForwardSwitchIntEdgeEffectsApplier<'mir, D, F> {
531536 effects_applied : bool ,
532537}
533538
534- impl < D , F > super :: SwitchIntEdgeEffects < D > for ForwardSwitchIntEdgeEffectsApplier < ' _ , D , F >
539+ impl < ' tcx , A , F > super :: SwitchIntEdgeEffects < ' tcx , A >
540+ for ForwardSwitchIntEdgeEffectsApplier < ' _ , A :: Domain , F >
535541where
536- D : Clone ,
537- F : FnMut ( BasicBlock , & D ) ,
542+ A : Analysis < ' tcx > ,
543+ F : FnMut ( & mut A , BasicBlock , & A :: Domain ) ,
538544{
539- fn apply ( & mut self , mut apply_edge_effect : impl FnMut ( & mut D , SwitchIntTarget ) ) {
545+ fn apply (
546+ & mut self ,
547+ analysis : & mut A ,
548+ mut apply_edge_effect : impl FnMut ( & mut A , & mut A :: Domain , SwitchIntTarget ) ,
549+ ) {
540550 assert ! ( !self . effects_applied) ;
541551
542552 let mut tmp = None ;
543553 for ( value, target) in self . targets . iter ( ) {
544554 let tmp = opt_clone_from_or_clone ( & mut tmp, self . exit_state ) ;
545- apply_edge_effect ( tmp, SwitchIntTarget { value : Some ( value) , target } ) ;
546- ( self . propagate ) ( target, tmp) ;
555+ apply_edge_effect ( analysis , tmp, SwitchIntTarget { value : Some ( value) , target } ) ;
556+ ( self . propagate ) ( analysis , target, tmp) ;
547557 }
548558
549559 // Once we get to the final, "otherwise" branch, there is no need to preserve `exit_state`,
550560 // so pass it directly to `apply_edge_effect` to save a clone of the dataflow state.
551561 let otherwise = self . targets . otherwise ( ) ;
552- apply_edge_effect ( self . exit_state , SwitchIntTarget { value : None , target : otherwise } ) ;
553- ( self . propagate ) ( otherwise, self . exit_state ) ;
562+ apply_edge_effect (
563+ analysis,
564+ self . exit_state ,
565+ SwitchIntTarget { value : None , target : otherwise } ,
566+ ) ;
567+ ( self . propagate ) ( analysis, otherwise, self . exit_state ) ;
554568
555569 self . effects_applied = true ;
556570 }
0 commit comments