1
1
#![ deny( rustc:: untranslatable_diagnostic) ]
2
2
#![ deny( rustc:: diagnostic_outside_of_impl) ]
3
3
use rustc_infer:: infer:: InferCtxt ;
4
- use rustc_middle:: mir:: visit:: TyContext ;
5
4
use rustc_middle:: mir:: visit:: Visitor ;
6
5
use 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 ,
9
8
} ;
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 } ;
13
10
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} ;
18
12
19
13
pub ( super ) fn generate_constraints < ' tcx > (
20
14
infcx : & InferCtxt < ' tcx > ,
21
- liveness_constraints : & mut LivenessValues < RegionVid > ,
22
15
all_facts : & mut Option < AllFacts > ,
23
16
location_table : & LocationTable ,
24
17
body : & Body < ' tcx > ,
25
18
borrow_set : & BorrowSet < ' tcx > ,
26
19
) {
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 } ;
36
21
for ( bb, data) in body. basic_blocks . iter_enumerated ( ) {
37
22
cg. visit_basic_block_data ( bb, data) ;
38
23
}
@@ -43,44 +28,11 @@ struct ConstraintGeneration<'cg, 'tcx> {
43
28
infcx : & ' cg InferCtxt < ' tcx > ,
44
29
all_facts : & ' cg mut Option < AllFacts > ,
45
30
location_table : & ' cg LocationTable ,
46
- liveness_constraints : & ' cg mut LivenessValues < RegionVid > ,
47
31
borrow_set : & ' cg BorrowSet < ' tcx > ,
48
32
body : & ' cg Body < ' tcx > ,
49
33
}
50
34
51
35
impl < ' 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
-
84
36
fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
85
37
if let Some ( all_facts) = self . all_facts {
86
38
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> {
155
107
}
156
108
157
109
impl < ' 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
-
174
110
/// When recording facts for Polonius, records the borrows on the specified place
175
111
/// as `killed`. For example, when assigning to a local, or on a call's return destination.
176
112
fn record_killed_borrows_for_place ( & mut self , place : Place < ' tcx > , location : Location ) {
0 commit comments