@@ -71,7 +71,7 @@ pub struct RegionInferenceContext<'tcx> {
71
71
/// The SCC computed from `constraints` and the constraint
72
72
/// graph. We have an edge from SCC A to SCC B if `A: B`. Used to
73
73
/// compute the values of each region.
74
- constraint_sccs : Rc < Sccs < RegionVid , ConstraintSccIndex > > ,
74
+ constraint_sccs : Sccs < RegionVid , ConstraintSccIndex > ,
75
75
76
76
/// Reverse of the SCC constraint graph -- i.e., an edge `A -> B` exists if
77
77
/// `B: A`. This is used to compute the universal regions that are required
@@ -121,11 +121,6 @@ pub struct RegionInferenceContext<'tcx> {
121
121
/// Information about how the universally quantified regions in
122
122
/// scope on this function relate to one another.
123
123
universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
124
-
125
- /// Whether we are operating with polonius=next or not. False
126
- /// means the regular NLL machinery is in use, true means use the
127
- /// new Polonius constraint propagation.
128
- polonius_next_enabled : bool ,
129
124
}
130
125
131
126
/// Each time that `apply_member_constraint` is successful, it appends
@@ -256,7 +251,7 @@ pub enum ExtraConstraintInfo {
256
251
#[ instrument( skip( infcx, sccs) , level = "debug" ) ]
257
252
fn sccs_info < ' cx , ' tcx > (
258
253
infcx : & ' cx BorrowckInferCtxt < ' cx , ' tcx > ,
259
- sccs : Rc < Sccs < RegionVid , ConstraintSccIndex > > ,
254
+ sccs : & Sccs < RegionVid , ConstraintSccIndex > ,
260
255
) {
261
256
use crate :: renumber:: RegionCtxt ;
262
257
@@ -332,7 +327,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
332
327
universal_regions : Rc < UniversalRegions < ' tcx > > ,
333
328
placeholder_indices : Rc < PlaceholderIndices > ,
334
329
universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
335
- outlives_constraints : OutlivesConstraintSet < ' tcx > ,
330
+ mut outlives_constraints : OutlivesConstraintSet < ' tcx > ,
336
331
member_constraints_in : MemberConstraintSet < ' tcx , RegionVid > ,
337
332
universe_causes : FxIndexMap < ty:: UniverseIndex , UniverseInfo < ' tcx > > ,
338
333
type_tests : Vec < TypeTest < ' tcx > > ,
@@ -350,21 +345,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
350
345
. map ( |info| RegionDefinition :: new ( info. universe , info. origin ) )
351
346
. collect ( ) ;
352
347
353
- let polonius_next_enabled = infcx . tcx . sess . opts . unstable_opts . polonius . is_next_enabled ( ) ;
348
+ outlives_constraints . placeholders_to_static ( & universal_regions , & definitions ) ;
354
349
355
- let constraints = if polonius_next_enabled {
356
- Frozen :: freeze (
357
- outlives_constraints. placeholders_to_static ( & universal_regions, & definitions) ,
358
- )
359
- } else {
360
- Frozen :: freeze ( outlives_constraints)
361
- } ;
350
+ let constraints = Frozen :: freeze ( outlives_constraints) ;
362
351
let constraint_graph = Frozen :: freeze ( constraints. graph ( definitions. len ( ) ) ) ;
363
352
let fr_static = universal_regions. fr_static ;
364
- let constraint_sccs = Rc :: new ( constraints. compute_sccs ( & constraint_graph, fr_static) ) ;
353
+ let constraint_sccs = constraints. compute_sccs ( & constraint_graph, fr_static) ;
365
354
366
355
if cfg ! ( debug_assertions) {
367
- sccs_info ( infcx, constraint_sccs. clone ( ) ) ;
356
+ sccs_info ( infcx, & constraint_sccs) ;
368
357
}
369
358
370
359
let mut scc_values =
@@ -399,7 +388,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
399
388
type_tests,
400
389
universal_regions,
401
390
universal_region_relations,
402
- polonius_next_enabled,
403
391
} ;
404
392
405
393
result. init_free_and_bound_regions ( ) ;
@@ -571,23 +559,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
571
559
}
572
560
573
561
NllRegionVariableOrigin :: Placeholder ( placeholder) => {
574
- // Each placeholder region is only visible from
575
- // its universe `ui` and its extensions. So we
576
- // can't just add it into `scc` unless the
577
- // universe of the scc can name this region.
578
- // This case is handled separately when Polonius
579
- // is enabled.
580
- let scc_universe = self . scc_universes [ scc] ;
581
- if self . polonius_next_enabled || scc_universe. can_name ( placeholder. universe ) {
582
- self . scc_values . add_element ( scc, placeholder) ;
583
- } else {
584
- debug ! (
585
- "init_free_and_bound_regions: placeholder {:?} is \
586
- not compatible with universe {:?} of its SCC {:?}",
587
- placeholder, scc_universe, scc,
588
- ) ;
589
- self . add_incompatible_universe ( scc) ;
590
- }
562
+ self . scc_values . add_element ( scc, placeholder) ;
591
563
}
592
564
593
565
NllRegionVariableOrigin :: Existential { .. } => {
@@ -755,8 +727,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
755
727
// SCC. For each SCC, we visit its successors and compute
756
728
// their values, then we union all those values to get our
757
729
// own.
758
- let constraint_sccs = self . constraint_sccs . clone ( ) ;
759
- for scc in constraint_sccs. all_sccs ( ) {
730
+ for scc in self . constraint_sccs . all_sccs ( ) {
760
731
self . compute_value_for_scc ( scc) ;
761
732
}
762
733
@@ -771,22 +742,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
771
742
/// (which is assured by iterating over SCCs in dependency order).
772
743
#[ instrument( skip( self ) , level = "debug" ) ]
773
744
fn compute_value_for_scc ( & mut self , scc_a : ConstraintSccIndex ) {
774
- let constraint_sccs = self . constraint_sccs . clone ( ) ;
775
-
776
745
// Walk each SCC `B` such that `A: B`...
777
- for & scc_b in constraint_sccs. successors ( scc_a) {
746
+ for & scc_b in self . constraint_sccs . successors ( scc_a) {
778
747
debug ! ( ?scc_b) ;
779
- // ...and add elements from `B` into `A`. One complication
780
- // arises because of universes: If `B` contains something
781
- // that `A` cannot name, then `A` can only contain `B` if
782
- // it outlives static.
783
- if self . polonius_next_enabled || self . universe_compatible ( scc_b, scc_a) {
784
- // `A` can name everything that is in `B`, so just
785
- // merge the bits.
786
- self . scc_values . add_region ( scc_a, scc_b) ;
787
- } else {
788
- self . add_incompatible_universe ( scc_a) ;
789
- }
748
+ self . scc_values . add_region ( scc_a, scc_b) ;
790
749
}
791
750
792
751
// Now take member constraints into account.
@@ -842,13 +801,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
842
801
if self . scc_universes [ scc] != ty:: UniverseIndex :: ROOT {
843
802
return ;
844
803
}
845
- debug_assert ! (
846
- self . polonius_next_enabled
847
- || self . scc_values. placeholders_contained_in( scc) . next( ) . is_none( ) ,
848
- "scc {:?} in a member constraint has placeholder value: {:?}" ,
849
- scc,
850
- self . scc_values. region_value_str( scc) ,
851
- ) ;
852
804
853
805
// The existing value for `scc` is a lower-bound. This will
854
806
// consist of some set `{P} + {LB}` of points `{P}` and
@@ -933,21 +885,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
933
885
self . scc_values . placeholders_contained_in ( scc_b) . all ( |p| universe_a. can_name ( p. universe ) )
934
886
}
935
887
936
- /// Extend `scc` so that it can outlive some placeholder region
937
- /// from a universe it can't name; at present, the only way for
938
- /// this to be true is if `scc` outlives `'static`. This is
939
- /// actually stricter than necessary: ideally, we'd support bounds
940
- /// like `for<'a: 'b>` that might then allow us to approximate
941
- /// `'a` with `'b` and not `'static`. But it will have to do for
942
- /// now.
943
- fn add_incompatible_universe ( & mut self , scc : ConstraintSccIndex ) {
944
- debug ! ( "add_incompatible_universe(scc={:?})" , scc) ;
945
-
946
- let fr_static = self . universal_regions . fr_static ;
947
- self . scc_values . add_all_points ( scc) ;
948
- self . scc_values . add_element ( scc, fr_static) ;
949
- }
950
-
951
888
/// Once regions have been propagated, this method is used to see
952
889
/// whether the "type tests" produced by typeck were satisfied;
953
890
/// type tests encode type-outlives relationships like `T:
@@ -1579,10 +1516,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1579
1516
// Because this free region must be in the ROOT universe, we
1580
1517
// know it cannot contain any bound universes.
1581
1518
assert ! ( self . scc_universes[ longer_fr_scc] == ty:: UniverseIndex :: ROOT ) ;
1582
- debug_assert ! (
1583
- self . polonius_next_enabled
1584
- || self . scc_values. placeholders_contained_in( longer_fr_scc) . next( ) . is_none( )
1585
- ) ;
1586
1519
1587
1520
// Only check all of the relations for the main representative of each
1588
1521
// SCC, otherwise just check that we outlive said representative. This
@@ -2267,7 +2200,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2267
2200
2268
2201
/// Access to the SCC constraint graph.
2269
2202
pub ( crate ) fn constraint_sccs ( & self ) -> & Sccs < RegionVid , ConstraintSccIndex > {
2270
- self . constraint_sccs . as_ref ( )
2203
+ & self . constraint_sccs
2271
2204
}
2272
2205
2273
2206
/// Access to the region graph, built from the outlives constraints.
0 commit comments