@@ -40,7 +40,6 @@ pub(crate) use dump::dump_polonius_mir;
40
40
pub ( crate ) mod legacy;
41
41
42
42
use rustc_middle:: mir:: { Body , Location } ;
43
- use rustc_middle:: ty:: TyCtxt ;
44
43
use rustc_mir_dataflow:: points:: PointIndex ;
45
44
46
45
use crate :: RegionInferenceContext ;
@@ -49,34 +48,31 @@ use crate::region_infer::values::LivenessValues;
49
48
use crate :: type_check:: Locations ;
50
49
use crate :: universal_regions:: UniversalRegions ;
51
50
52
- /// When using `-Zpolonius=next`, fills the given constraint set by:
51
+ /// Creates a constraint set for `-Zpolonius=next` by:
53
52
/// - converting NLL typeck constraints to be localized
54
53
/// - encoding liveness constraints
55
54
pub ( crate ) fn create_localized_constraints < ' tcx > (
56
55
regioncx : & mut RegionInferenceContext < ' tcx > ,
57
- tcx : TyCtxt < ' tcx > ,
58
56
body : & Body < ' tcx > ,
59
- localized_outlives_constraints : & mut LocalizedOutlivesConstraintSet ,
60
- ) {
61
- if !tcx. sess . opts . unstable_opts . polonius . is_next_enabled ( ) {
62
- return ;
63
- }
64
-
57
+ ) -> LocalizedOutlivesConstraintSet {
58
+ let mut localized_outlives_constraints = LocalizedOutlivesConstraintSet :: default ( ) ;
65
59
convert_typeck_constraints (
66
60
body,
67
61
regioncx. liveness_constraints ( ) ,
68
62
regioncx. outlives_constraints ( ) ,
69
- localized_outlives_constraints,
63
+ & mut localized_outlives_constraints,
70
64
) ;
71
65
create_liveness_constraints (
72
66
body,
73
67
regioncx. liveness_constraints ( ) ,
74
68
regioncx. universal_regions ( ) ,
75
- localized_outlives_constraints,
69
+ & mut localized_outlives_constraints,
76
70
) ;
77
71
78
72
// FIXME: here, we can trace loan reachability in the constraint graph and record this as loan
79
73
// liveness for the next step in the chain, the NLL loan scope and active loans computations.
74
+
75
+ localized_outlives_constraints
80
76
}
81
77
82
78
/// Propagate loans throughout the subset graph at a given point (with some subtleties around the
@@ -90,8 +86,9 @@ fn convert_typeck_constraints<'tcx>(
90
86
for outlives_constraint in outlives_constraints {
91
87
match outlives_constraint. locations {
92
88
Locations :: All ( _) => {
93
- // FIXME: for now, turn logical constraints holding at all points into physical
94
- // edges at every point in the graph. We can encode this into *traversal* instead.
89
+ // For now, turn logical constraints holding at all points into physical edges at
90
+ // every point in the graph.
91
+ // FIXME: encode this into *traversal* instead.
95
92
for ( block, bb) in body. basic_blocks . iter_enumerated ( ) {
96
93
let statement_count = bb. statements . len ( ) ;
97
94
for statement_index in 0 ..=statement_count {
@@ -168,9 +165,10 @@ fn propagate_loans_between_points(
168
165
localized_outlives_constraints : & mut LocalizedOutlivesConstraintSet ,
169
166
) {
170
167
// Universal regions are semantically live at all points.
171
- // FIXME: We always have universal regions but they're not always (or often) involved in the
172
- // subset graph. So for now, we emit this edge, but we only need to emit edges for universal
173
- // regions that existential regions can actually reach.
168
+ // Note: we always have universal regions but they're not always (or often) involved in the
169
+ // subset graph. For now, we emit all their edges unconditionally, but some of these subgraphs
170
+ // will be disconnected from the rest of the graph and thus, unnecessary.
171
+ // FIXME: only emit the edges of universal regions that existential regions can reach.
174
172
for region in universal_regions. universal_regions_iter ( ) {
175
173
localized_outlives_constraints. push ( LocalizedOutlivesConstraint {
176
174
source : region,
0 commit comments