@@ -16,8 +16,42 @@ use crate::universal_regions::UniversalRegions;
16
16
mod loan_invalidations;
17
17
mod loan_kills;
18
18
19
+ /// When requested, emit most of the facts needed by polonius:
20
+ /// - moves and assignments
21
+ /// - universal regions and their relations
22
+ /// - CFG points and edges
23
+ /// - loan kills
24
+ /// - loan invalidations
25
+ ///
26
+ /// The rest of the facts are emitted during typeck and liveness.
27
+ pub ( crate ) fn emit_facts < ' tcx > (
28
+ all_facts : & mut Option < AllFacts > ,
29
+ tcx : TyCtxt < ' tcx > ,
30
+ location_table : & LocationTable ,
31
+ body : & Body < ' tcx > ,
32
+ borrow_set : & BorrowSet < ' tcx > ,
33
+ move_data : & MoveData < ' _ > ,
34
+ universal_regions : & UniversalRegions < ' _ > ,
35
+ universal_region_relations : & UniversalRegionRelations < ' _ > ,
36
+ ) {
37
+ let Some ( all_facts) = all_facts else {
38
+ // We don't do anything if there are no facts to fill.
39
+ return ;
40
+ } ;
41
+ let _prof_timer = tcx. prof . generic_activity ( "polonius_fact_generation" ) ;
42
+ emit_move_facts ( all_facts, move_data, location_table, body) ;
43
+ emit_universal_region_facts (
44
+ all_facts,
45
+ borrow_set,
46
+ & universal_regions,
47
+ & universal_region_relations,
48
+ ) ;
49
+ emit_cfg_and_loan_kills_facts ( all_facts, tcx, location_table, body, borrow_set) ;
50
+ emit_loan_invalidations_facts ( all_facts, tcx, location_table, body, borrow_set) ;
51
+ }
52
+
19
53
/// Emit facts needed for move/init analysis: moves and assignments.
20
- pub ( crate ) fn emit_move_facts (
54
+ fn emit_move_facts (
21
55
all_facts : & mut AllFacts ,
22
56
move_data : & MoveData < ' _ > ,
23
57
location_table : & LocationTable ,
@@ -91,7 +125,7 @@ pub(crate) fn emit_move_facts(
91
125
}
92
126
93
127
/// Emit universal regions facts, and their relations.
94
- pub ( crate ) fn emit_universal_region_facts (
128
+ fn emit_universal_region_facts (
95
129
all_facts : & mut AllFacts ,
96
130
borrow_set : & BorrowSet < ' _ > ,
97
131
universal_regions : & UniversalRegions < ' _ > ,
@@ -132,33 +166,23 @@ pub(crate) fn emit_universal_region_facts(
132
166
}
133
167
134
168
/// Emit facts about loan invalidations.
135
- pub ( crate ) fn emit_loan_invalidations_facts < ' tcx > (
169
+ fn emit_loan_invalidations_facts < ' tcx > (
170
+ all_facts : & mut AllFacts ,
136
171
tcx : TyCtxt < ' tcx > ,
137
- all_facts : & mut Option < AllFacts > ,
138
172
location_table : & LocationTable ,
139
173
body : & Body < ' tcx > ,
140
174
borrow_set : & BorrowSet < ' tcx > ,
141
175
) {
142
- let Some ( all_facts) = all_facts else {
143
- // Nothing to do if we don't have any facts to fill
144
- return ;
145
- } ;
146
-
147
176
loan_invalidations:: emit_loan_invalidations ( tcx, all_facts, location_table, body, borrow_set) ;
148
177
}
149
178
150
179
/// Emit facts about CFG points and edges, as well as locations where loans are killed.
151
- pub ( crate ) fn emit_cfg_and_loan_kills_facts < ' tcx > (
180
+ fn emit_cfg_and_loan_kills_facts < ' tcx > (
181
+ all_facts : & mut AllFacts ,
152
182
tcx : TyCtxt < ' tcx > ,
153
- all_facts : & mut Option < AllFacts > ,
154
183
location_table : & LocationTable ,
155
184
body : & Body < ' tcx > ,
156
185
borrow_set : & BorrowSet < ' tcx > ,
157
186
) {
158
- let Some ( all_facts) = all_facts else {
159
- // Nothing to do if we don't have any facts to fill
160
- return ;
161
- } ;
162
-
163
187
loan_kills:: emit_loan_kills ( tcx, all_facts, location_table, body, borrow_set) ;
164
188
}
0 commit comments