@@ -40,7 +40,6 @@ pub(crate) use dump::dump_polonius_mir;
4040pub ( crate ) mod legacy;
4141
4242use rustc_middle:: mir:: { Body , Location } ;
43- use rustc_middle:: ty:: TyCtxt ;
4443use rustc_mir_dataflow:: points:: PointIndex ;
4544
4645use crate :: RegionInferenceContext ;
@@ -49,34 +48,31 @@ use crate::region_infer::values::LivenessValues;
4948use crate :: type_check:: Locations ;
5049use crate :: universal_regions:: UniversalRegions ;
5150
52- /// When using `-Zpolonius=next`, fills the given constraint set by:
51+ /// Creates a constraint set for `-Zpolonius=next` by:
5352/// - converting NLL typeck constraints to be localized
5453/// - encoding liveness constraints
5554pub ( crate ) fn create_localized_constraints < ' tcx > (
5655 regioncx : & mut RegionInferenceContext < ' tcx > ,
57- tcx : TyCtxt < ' tcx > ,
5856 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 ( ) ;
6559 convert_typeck_constraints (
6660 body,
6761 regioncx. liveness_constraints ( ) ,
6862 regioncx. outlives_constraints ( ) ,
69- localized_outlives_constraints,
63+ & mut localized_outlives_constraints,
7064 ) ;
7165 create_liveness_constraints (
7266 body,
7367 regioncx. liveness_constraints ( ) ,
7468 regioncx. universal_regions ( ) ,
75- localized_outlives_constraints,
69+ & mut localized_outlives_constraints,
7670 ) ;
7771
7872 // FIXME: here, we can trace loan reachability in the constraint graph and record this as loan
7973 // liveness for the next step in the chain, the NLL loan scope and active loans computations.
74+
75+ localized_outlives_constraints
8076}
8177
8278/// Propagate loans throughout the subset graph at a given point (with some subtleties around the
@@ -90,8 +86,9 @@ fn convert_typeck_constraints<'tcx>(
9086 for outlives_constraint in outlives_constraints {
9187 match outlives_constraint. locations {
9288 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.
9592 for ( block, bb) in body. basic_blocks . iter_enumerated ( ) {
9693 let statement_count = bb. statements . len ( ) ;
9794 for statement_index in 0 ..=statement_count {
@@ -168,9 +165,10 @@ fn propagate_loans_between_points(
168165 localized_outlives_constraints : & mut LocalizedOutlivesConstraintSet ,
169166) {
170167 // 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.
174172 for region in universal_regions. universal_regions_iter ( ) {
175173 localized_outlives_constraints. push ( LocalizedOutlivesConstraint {
176174 source : region,
0 commit comments