@@ -16,8 +16,42 @@ use crate::universal_regions::UniversalRegions;
1616mod loan_invalidations;
1717mod loan_kills;
1818
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+
1953/// Emit facts needed for move/init analysis: moves and assignments.
20- pub ( crate ) fn emit_move_facts (
54+ fn emit_move_facts (
2155 all_facts : & mut AllFacts ,
2256 move_data : & MoveData < ' _ > ,
2357 location_table : & LocationTable ,
@@ -91,7 +125,7 @@ pub(crate) fn emit_move_facts(
91125}
92126
93127/// Emit universal regions facts, and their relations.
94- pub ( crate ) fn emit_universal_region_facts (
128+ fn emit_universal_region_facts (
95129 all_facts : & mut AllFacts ,
96130 borrow_set : & BorrowSet < ' _ > ,
97131 universal_regions : & UniversalRegions < ' _ > ,
@@ -132,33 +166,23 @@ pub(crate) fn emit_universal_region_facts(
132166}
133167
134168/// 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 ,
136171 tcx : TyCtxt < ' tcx > ,
137- all_facts : & mut Option < AllFacts > ,
138172 location_table : & LocationTable ,
139173 body : & Body < ' tcx > ,
140174 borrow_set : & BorrowSet < ' tcx > ,
141175) {
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-
147176 loan_invalidations:: emit_loan_invalidations ( tcx, all_facts, location_table, body, borrow_set) ;
148177}
149178
150179/// 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 ,
152182 tcx : TyCtxt < ' tcx > ,
153- all_facts : & mut Option < AllFacts > ,
154183 location_table : & LocationTable ,
155184 body : & Body < ' tcx > ,
156185 borrow_set : & BorrowSet < ' tcx > ,
157186) {
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-
163187 loan_kills:: emit_loan_kills ( tcx, all_facts, location_table, body, borrow_set) ;
164188}
0 commit comments