@@ -83,6 +83,15 @@ pub(crate) fn handle_opaque_type_uses<'tcx>(
83
83
let placeholder_indices = Default :: default ( ) ;
84
84
let mut scc_values =
85
85
RegionValues :: new ( location_map, universal_regions. len ( ) , placeholder_indices) ;
86
+ for variable in definitions. indices ( ) {
87
+ let scc = constraint_sccs. scc ( variable) ;
88
+ match definitions[ variable] . origin {
89
+ NllRegionVariableOrigin :: FreeRegion => {
90
+ scc_values. add_element ( scc, variable) ;
91
+ }
92
+ _ => { }
93
+ }
94
+ }
86
95
scc_values. propagate_constraints ( & constraint_sccs) ;
87
96
for entry in & mut opaque_types {
88
97
// Map all opaque types to their SCC representatives.
@@ -274,7 +283,8 @@ impl<'tcx> OpaqueHiddenTypeFolder<'_, 'tcx> {
274
283
#[ instrument( level = "debug" , skip( self ) ) ]
275
284
fn apply_member_constraint ( & mut self , member_vid : RegionVid ) -> Option < Region < ' tcx > > {
276
285
let member = self . constraint_sccs . scc ( member_vid) ;
277
- if let Some ( ( _, reg) ) = self . arg_regions . iter ( ) . copied ( ) . find ( |& ( vid, _) | vid == member_vid) {
286
+ if let Some ( ( _, reg) ) = self . arg_regions . iter ( ) . copied ( ) . find ( |& ( vid, _) | vid == member_vid)
287
+ {
278
288
debug ! ( "member equal to arg" ) ;
279
289
return Some ( reg) ;
280
290
}
@@ -305,8 +315,14 @@ impl<'tcx> OpaqueHiddenTypeFolder<'_, 'tcx> {
305
315
// free region that must outlive the member region `R0` (`UB:
306
316
// R0`). Therefore, we need only keep an option `O` if `UB: O`
307
317
// for all UB.
318
+ //
319
+ // If we have a requirement `'upper_bound: 'member`, equating `'member`
320
+ // with some region `'choice` means we now also require `'upper_bound: 'choice`.
321
+ // Avoid choice regions for which this does not hold.
308
322
for ub in self . rev_scc_graph . upper_bounds ( member) {
309
- choice_regions. retain ( |& ( o_r, _) | self . universal_region_relations . outlives ( ub, o_r) ) ;
323
+ choice_regions. retain ( |& ( choice_region, _) | {
324
+ self . universal_region_relations . outlives ( ub, choice_region)
325
+ } ) ;
310
326
}
311
327
312
328
debug ! ( ?choice_regions, "after enforcing upper-bound" ) ;
0 commit comments