11#![ deny( rustc:: untranslatable_diagnostic) ]
22#![ deny( rustc:: diagnostic_outside_of_impl) ]
33use rustc_infer:: infer:: InferCtxt ;
4- use rustc_middle:: mir:: visit:: TyContext ;
54use rustc_middle:: mir:: visit:: Visitor ;
65use rustc_middle:: mir:: {
7- Body , Local , Location , Place , PlaceRef , ProjectionElem , Rvalue , SourceInfo , Statement ,
8- StatementKind , Terminator , TerminatorKind , UserTypeProjection ,
6+ Body , Local , Location , Place , PlaceRef , ProjectionElem , Rvalue , Statement , StatementKind ,
7+ Terminator , TerminatorKind , UserTypeProjection ,
98} ;
10- use rustc_middle:: ty:: visit:: TypeVisitable ;
11- use rustc_middle:: ty:: GenericArgsRef ;
12- use rustc_middle:: ty:: { self , RegionVid , Ty , TyCtxt } ;
9+ use rustc_middle:: ty:: { self } ;
1310
14- use crate :: {
15- borrow_set:: BorrowSet , facts:: AllFacts , location:: LocationTable , places_conflict,
16- region_infer:: values:: LivenessValues ,
17- } ;
11+ use crate :: { borrow_set:: BorrowSet , facts:: AllFacts , location:: LocationTable , places_conflict} ;
1812
1913pub ( super ) fn generate_constraints < ' tcx > (
2014 infcx : & InferCtxt < ' tcx > ,
21- liveness_constraints : & mut LivenessValues < RegionVid > ,
2215 all_facts : & mut Option < AllFacts > ,
2316 location_table : & LocationTable ,
2417 body : & Body < ' tcx > ,
2518 borrow_set : & BorrowSet < ' tcx > ,
2619) {
27- let mut cg = ConstraintGeneration {
28- borrow_set,
29- infcx,
30- liveness_constraints,
31- location_table,
32- all_facts,
33- body,
34- } ;
35-
20+ let mut cg = ConstraintGeneration { borrow_set, infcx, location_table, all_facts, body } ;
3621 for ( bb, data) in body. basic_blocks . iter_enumerated ( ) {
3722 cg. visit_basic_block_data ( bb, data) ;
3823 }
@@ -43,44 +28,11 @@ struct ConstraintGeneration<'cg, 'tcx> {
4328 infcx : & ' cg InferCtxt < ' tcx > ,
4429 all_facts : & ' cg mut Option < AllFacts > ,
4530 location_table : & ' cg LocationTable ,
46- liveness_constraints : & ' cg mut LivenessValues < RegionVid > ,
4731 borrow_set : & ' cg BorrowSet < ' tcx > ,
4832 body : & ' cg Body < ' tcx > ,
4933}
5034
5135impl < ' cg , ' tcx > Visitor < ' tcx > for ConstraintGeneration < ' cg , ' tcx > {
52- /// We sometimes have `args` within an rvalue, or within a
53- /// call. Make them live at the location where they appear.
54- fn visit_args ( & mut self , args : & GenericArgsRef < ' tcx > , location : Location ) {
55- self . add_regular_live_constraint ( * args, location) ;
56- self . super_args ( args) ;
57- }
58-
59- /// We sometimes have `region` within an rvalue, or within a
60- /// call. Make them live at the location where they appear.
61- fn visit_region ( & mut self , region : ty:: Region < ' tcx > , location : Location ) {
62- self . add_regular_live_constraint ( region, location) ;
63- self . super_region ( region) ;
64- }
65-
66- /// We sometimes have `ty` within an rvalue, or within a
67- /// call. Make them live at the location where they appear.
68- fn visit_ty ( & mut self , ty : Ty < ' tcx > , ty_context : TyContext ) {
69- match ty_context {
70- TyContext :: ReturnTy ( SourceInfo { span, .. } )
71- | TyContext :: YieldTy ( SourceInfo { span, .. } )
72- | TyContext :: UserTy ( span)
73- | TyContext :: LocalDecl { source_info : SourceInfo { span, .. } , .. } => {
74- span_bug ! ( span, "should not be visiting outside of the CFG: {:?}" , ty_context) ;
75- }
76- TyContext :: Location ( location) => {
77- self . add_regular_live_constraint ( ty, location) ;
78- }
79- }
80-
81- self . super_ty ( ty) ;
82- }
83-
8436 fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
8537 if let Some ( all_facts) = self . all_facts {
8638 let _prof_timer = self . infcx . tcx . prof . generic_activity ( "polonius_fact_generation" ) ;
@@ -155,22 +107,6 @@ impl<'cg, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'tcx> {
155107}
156108
157109impl < ' cx , ' tcx > ConstraintGeneration < ' cx , ' tcx > {
158- /// Some variable with type `live_ty` is "regular live" at
159- /// `location` -- i.e., it may be used later. This means that all
160- /// regions appearing in the type `live_ty` must be live at
161- /// `location`.
162- fn add_regular_live_constraint < T > ( & mut self , live_ty : T , location : Location )
163- where
164- T : TypeVisitable < TyCtxt < ' tcx > > ,
165- {
166- debug ! ( "add_regular_live_constraint(live_ty={:?}, location={:?})" , live_ty, location) ;
167-
168- self . infcx . tcx . for_each_free_region ( & live_ty, |live_region| {
169- let vid = live_region. as_var ( ) ;
170- self . liveness_constraints . add_element ( vid, location) ;
171- } ) ;
172- }
173-
174110 /// When recording facts for Polonius, records the borrows on the specified place
175111 /// as `killed`. For example, when assigning to a local, or on a call's return destination.
176112 fn record_killed_borrows_for_place ( & mut self , place : Place < ' tcx > , location : Location ) {
0 commit comments