@@ -37,21 +37,20 @@ mod constraints;
3737mod dump;
3838pub ( crate ) mod legacy;
3939mod liveness_constraints;
40+ mod typeck_constraints;
4041
4142use std:: collections:: BTreeMap ;
4243
4344use rustc_index:: bit_set:: SparseBitMatrix ;
44- use rustc_middle:: mir:: { Body , Location } ;
45- use rustc_middle:: ty:: RegionVid ;
45+ use rustc_middle:: mir:: Body ;
46+ use rustc_middle:: ty:: { RegionVid , TyCtxt } ;
4647use rustc_mir_dataflow:: points:: PointIndex ;
4748
4849pub ( crate ) use self :: constraints:: * ;
4950pub ( crate ) use self :: dump:: dump_polonius_mir;
5051use self :: liveness_constraints:: create_liveness_constraints;
52+ use self :: typeck_constraints:: convert_typeck_constraints;
5153use crate :: RegionInferenceContext ;
52- use crate :: constraints:: OutlivesConstraint ;
53- use crate :: region_infer:: values:: LivenessValues ;
54- use crate :: type_check:: Locations ;
5554
5655/// This struct holds the data needed to create the Polonius localized constraints.
5756pub ( crate ) struct PoloniusContext {
@@ -88,14 +87,17 @@ impl PoloniusContext {
8887 /// - encoding liveness constraints
8988 pub ( crate ) fn create_localized_constraints < ' tcx > (
9089 & self ,
90+ tcx : TyCtxt < ' tcx > ,
9191 regioncx : & RegionInferenceContext < ' tcx > ,
9292 body : & Body < ' tcx > ,
9393 ) -> LocalizedOutlivesConstraintSet {
9494 let mut localized_outlives_constraints = LocalizedOutlivesConstraintSet :: default ( ) ;
9595 convert_typeck_constraints (
96+ tcx,
9697 body,
9798 regioncx. liveness_constraints ( ) ,
9899 regioncx. outlives_constraints ( ) ,
100+ regioncx. universal_regions ( ) ,
99101 & mut localized_outlives_constraints,
100102 ) ;
101103
@@ -117,38 +119,3 @@ impl PoloniusContext {
117119 localized_outlives_constraints
118120 }
119121}
120-
121- /// Propagate loans throughout the subset graph at a given point (with some subtleties around the
122- /// location where effects start to be visible).
123- fn convert_typeck_constraints < ' tcx > (
124- body : & Body < ' tcx > ,
125- liveness : & LivenessValues ,
126- outlives_constraints : impl Iterator < Item = OutlivesConstraint < ' tcx > > ,
127- localized_outlives_constraints : & mut LocalizedOutlivesConstraintSet ,
128- ) {
129- for outlives_constraint in outlives_constraints {
130- match outlives_constraint. locations {
131- Locations :: All ( _) => {
132- // For now, turn logical constraints holding at all points into physical edges at
133- // every point in the graph.
134- // FIXME: encode this into *traversal* instead.
135- for ( block, bb) in body. basic_blocks . iter_enumerated ( ) {
136- let statement_count = bb. statements . len ( ) ;
137- for statement_index in 0 ..=statement_count {
138- let current_location = Location { block, statement_index } ;
139- let current_point = liveness. point_from_location ( current_location) ;
140-
141- localized_outlives_constraints. push ( LocalizedOutlivesConstraint {
142- source : outlives_constraint. sup ,
143- from : current_point,
144- target : outlives_constraint. sub ,
145- to : current_point,
146- } ) ;
147- }
148- }
149- }
150-
151- _ => { }
152- }
153- }
154- }
0 commit comments