@@ -76,12 +76,10 @@ pub(crate) struct PlaceholderReachability {
7676
7777impl PlaceholderReachability {
7878 /// Merge the reachable placeholders of two graph components.
79- fn merge ( self , other : PlaceholderReachability ) -> PlaceholderReachability {
80- PlaceholderReachability {
81- max_universe : self . max_universe . max ( other. max_universe ) ,
82- min_placeholder : self . min_placeholder . min ( other. min_placeholder ) ,
83- max_placeholder : self . max_placeholder . max ( other. max_placeholder ) ,
84- }
79+ fn merge ( & mut self , other : & PlaceholderReachability ) {
80+ self . max_universe = self . max_universe . max ( other. max_universe ) ;
81+ self . min_placeholder = self . min_placeholder . min ( other. min_placeholder ) ;
82+ self . max_placeholder = self . max_placeholder . max ( other. max_placeholder ) ;
8583 }
8684}
8785
@@ -192,34 +190,26 @@ impl RegionTracker {
192190}
193191
194192impl scc:: Annotation for RegionTracker {
195- fn merge_scc ( self , other : Self ) -> Self {
193+ fn update_scc ( & mut self , other : & Self ) {
196194 trace ! ( "{:?} << {:?}" , self . representative, other. representative) ;
197- Self {
198- representative : self . representative . min ( other. representative ) ,
199- is_placeholder : self . is_placeholder . max ( other. is_placeholder ) ,
200- ..self . merge_reached ( other)
201- }
195+ self . representative = self . representative . min ( other. representative ) ;
196+ self . is_placeholder = self . is_placeholder . max ( other. is_placeholder ) ;
197+ self . update_reachable ( other) ; // SCC membership implies reachability.
202198 }
203199
204200 #[ inline( always) ]
205- fn merge_reached ( self , other : Self ) -> Self {
206- Self {
207- worst_existential : self
208- . worst_existential
209- . xor ( other. worst_existential )
210- . or_else ( || self . worst_existential . min ( other. worst_existential ) ) ,
211- min_max_nameable_universe : self
212- . min_max_nameable_universe
213- . min ( other. min_max_nameable_universe ) ,
214- reachable_placeholders : match (
215- self . reachable_placeholders ,
216- other. reachable_placeholders ,
217- ) {
218- ( None , x) | ( x, None ) => x,
219- ( Some ( ours) , Some ( theirs) ) => Some ( ours. merge ( theirs) ) ,
220- } ,
221- ..self
222- }
201+ fn update_reachable ( & mut self , other : & Self ) {
202+ self . worst_existential = self
203+ . worst_existential
204+ . xor ( other. worst_existential )
205+ . or_else ( || self . worst_existential . min ( other. worst_existential ) ) ;
206+ self . min_max_nameable_universe =
207+ self . min_max_nameable_universe . min ( other. min_max_nameable_universe ) ;
208+ match ( self . reachable_placeholders . as_mut ( ) , other. reachable_placeholders . as_ref ( ) ) {
209+ ( None , None ) | ( Some ( _) , None ) => ( ) ,
210+ ( None , Some ( theirs) ) => self . reachable_placeholders = Some ( * theirs) ,
211+ ( Some ( ours) , Some ( theirs) ) => ours. merge ( theirs) ,
212+ } ;
223213 }
224214}
225215
@@ -461,13 +451,12 @@ pub(crate) fn rewrite_placeholder_outlives<'tcx>(
461451 // inference since `p` isn't empty)
462452 // - another placeholder (will flag an error above, but will reach here).
463453 //
464- // To avoid adding the invalid constraint "'p: 'static` due to `'p` being
454+ // To avoid adding the invalid constraint "` 'p: 'static` due to `'p` being
465455 // unnameable from the SCC represented by `'p`", we nope out early here
466456 // at no risk of soundness issues since at this point all paths lead
467457 // to an error.
468458 continue ;
469459 }
470-
471460 // This SCC outlives a placeholder it can't name and must outlive 'static.
472461
473462 // FIXME: if we can extract a useful blame span here, future error
0 commit comments