@@ -18,7 +18,7 @@ use crate::consumers::OutlivesConstraint;
18
18
use crate :: diagnostics:: UniverseInfo ;
19
19
use crate :: member_constraints:: MemberConstraintSet ;
20
20
use crate :: region_infer:: values:: { LivenessValues , PlaceholderIndices } ;
21
- use crate :: region_infer:: { ConstraintSccs , RegionDefinition , TypeTest } ;
21
+ use crate :: region_infer:: { ConstraintSccs , RegionDefinition , Representative , TypeTest } ;
22
22
use crate :: ty:: VarianceDiagInfo ;
23
23
use crate :: type_check:: free_region_relations:: UniversalRegionRelations ;
24
24
use crate :: type_check:: { Locations , MirTypeckRegionConstraints } ;
@@ -76,36 +76,23 @@ pub(crate) struct RegionTracker {
76
76
/// The smallest universe index reachable form the nodes of this SCC.
77
77
min_reachable_universe : UniverseIndex ,
78
78
79
- /// The representative Region Variable Id for this SCC. We prefer
80
- /// placeholders over existentially quantified variables, otherwise
81
- /// it's the one with the smallest Region Variable ID.
82
- pub ( crate ) representative : RegionVid ,
83
-
84
- /// Is the current representative a placeholder?
85
- representative_is_placeholder : bool ,
86
-
87
- /// Is the current representative existentially quantified?
88
- representative_is_existential : bool ,
79
+ /// The representative Region Variable Id for this SCC.
80
+ pub ( crate ) representative : Representative ,
89
81
}
90
82
91
83
impl RegionTracker {
92
84
pub ( crate ) fn new ( rvid : RegionVid , definition : & RegionDefinition < ' _ > ) -> Self {
93
- let ( representative_is_placeholder, representative_is_existential) = match definition. origin
94
- {
95
- NllRegionVariableOrigin :: FreeRegion => ( false , false ) ,
96
- NllRegionVariableOrigin :: Placeholder ( _) => ( true , false ) ,
97
- NllRegionVariableOrigin :: Existential { .. } => ( false , true ) ,
98
- } ;
99
-
100
85
let placeholder_universe =
101
- if representative_is_placeholder { definition. universe } else { UniverseIndex :: ROOT } ;
86
+ if matches ! ( definition. origin, NllRegionVariableOrigin :: Placeholder ( _) ) {
87
+ definition. universe
88
+ } else {
89
+ UniverseIndex :: ROOT
90
+ } ;
102
91
103
92
Self {
104
93
max_placeholder_universe_reached : placeholder_universe,
105
94
min_reachable_universe : definition. universe ,
106
- representative : rvid,
107
- representative_is_placeholder,
108
- representative_is_existential,
95
+ representative : Representative :: new ( rvid, definition) ,
109
96
}
110
97
}
111
98
@@ -139,21 +126,10 @@ impl RegionTracker {
139
126
}
140
127
141
128
impl scc:: Annotation for RegionTracker {
142
- fn merge_scc ( mut self , mut other : Self ) -> Self {
143
- // Prefer any placeholder over any existential
144
- if other. representative_is_placeholder && self . representative_is_existential {
145
- other. merge_min_max_seen ( & self ) ;
146
- return other;
147
- }
148
-
149
- if self . representative_is_placeholder && other. representative_is_existential
150
- || ( self . representative <= other. representative )
151
- {
152
- self . merge_min_max_seen ( & other) ;
153
- return self ;
154
- }
155
- other. merge_min_max_seen ( & self ) ;
156
- other
129
+ fn merge_scc ( mut self , other : Self ) -> Self {
130
+ self . representative = self . representative . merge_scc ( other. representative ) ;
131
+ self . merge_min_max_seen ( & other) ;
132
+ self
157
133
}
158
134
159
135
fn merge_reached ( mut self , other : Self ) -> Self {
@@ -356,7 +332,7 @@ fn rewrite_outlives<'tcx>(
356
332
// outlive static.
357
333
outlives_static. insert ( scc) ;
358
334
let scc_representative_outlives_static = OutlivesConstraint {
359
- sup : annotation. representative ,
335
+ sup : annotation. representative . rvid ( ) ,
360
336
sub : fr_static,
361
337
category : ConstraintCategory :: IllegalUniverse ,
362
338
locations : Locations :: All ( rustc_span:: DUMMY_SP ) ,
0 commit comments