9
9
// except according to those terms.
10
10
11
11
use borrow_check:: borrow_set:: BorrowSet ;
12
- use borrow_check:: location:: LocationTable ;
12
+ use borrow_check:: location:: { LocationIndex , LocationTable } ;
13
13
use borrow_check:: nll:: facts:: AllFactsExt ;
14
14
use dataflow:: move_paths:: MoveData ;
15
15
use dataflow:: FlowAtLocation ;
16
16
use dataflow:: MaybeInitializedPlaces ;
17
+ use dataflow:: indexes:: BorrowIndex ;
17
18
use rustc:: hir:: def_id:: DefId ;
18
19
use rustc:: infer:: InferCtxt ;
19
20
use rustc:: mir:: { ClosureOutlivesSubject , ClosureRegionRequirements , Mir } ;
@@ -22,13 +23,15 @@ use rustc::util::nodemap::FxHashMap;
22
23
use std:: collections:: BTreeSet ;
23
24
use std:: fmt:: Debug ;
24
25
use std:: io;
26
+ use std:: rc:: Rc ;
25
27
use std:: path:: PathBuf ;
26
28
use transform:: MirSource ;
27
29
use util:: liveness:: { LivenessResults , LocalSet } ;
28
30
29
31
use self :: mir_util:: PassWhere ;
30
32
use util as mir_util;
31
33
use util:: pretty:: { self , ALIGN } ;
34
+ use polonius_engine:: { Algorithm , Output } ;
32
35
33
36
mod constraint_generation;
34
37
pub mod explain_borrow;
@@ -83,6 +86,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
83
86
borrow_set : & BorrowSet < ' tcx > ,
84
87
) -> (
85
88
RegionInferenceContext < ' tcx > ,
89
+ Option < Rc < Output < RegionVid , BorrowIndex , LocationIndex > > > ,
86
90
Option < ClosureRegionRequirements < ' gcx > > ,
87
91
) {
88
92
// Run the MIR type-checker.
@@ -98,7 +102,9 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
98
102
move_data,
99
103
) ;
100
104
101
- let mut all_facts = if infcx. tcx . sess . opts . debugging_opts . nll_facts {
105
+ let mut all_facts = if infcx. tcx . sess . opts . debugging_opts . nll_facts
106
+ || infcx. tcx . sess . opts . debugging_opts . polonius
107
+ {
102
108
Some ( AllFacts :: default ( ) )
103
109
} else {
104
110
None
@@ -142,11 +148,19 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
142
148
) ;
143
149
144
150
// Dump facts if requested.
145
- if let Some ( all_facts) = all_facts {
146
- let def_path = infcx. tcx . hir . def_path ( def_id) ;
147
- let dir_path = PathBuf :: from ( "nll-facts" ) . join ( def_path. to_filename_friendly_no_crate ( ) ) ;
148
- all_facts. write_to_dir ( dir_path, location_table) . unwrap ( ) ;
149
- }
151
+ let polonius_output = all_facts. and_then ( |all_facts| {
152
+ if infcx. tcx . sess . opts . debugging_opts . nll_facts {
153
+ let def_path = infcx. tcx . hir . def_path ( def_id) ;
154
+ let dir_path = PathBuf :: from ( "nll-facts" ) . join ( def_path. to_filename_friendly_no_crate ( ) ) ;
155
+ all_facts. write_to_dir ( dir_path, location_table) . unwrap ( ) ;
156
+ }
157
+
158
+ if infcx. tcx . sess . opts . debugging_opts . polonius {
159
+ Some ( Rc :: new ( Output :: compute ( & all_facts, Algorithm :: DatafrogOpt , false ) ) )
160
+ } else {
161
+ None
162
+ }
163
+ } ) ;
150
164
151
165
// Solve the region constraints.
152
166
let closure_region_requirements = regioncx. solve ( infcx, & mir, def_id) ;
@@ -166,7 +180,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
166
180
// information
167
181
dump_annotation ( infcx, & mir, def_id, & regioncx, & closure_region_requirements) ;
168
182
169
- ( regioncx, closure_region_requirements)
183
+ ( regioncx, polonius_output , closure_region_requirements)
170
184
}
171
185
172
186
fn dump_mir_results < ' a , ' gcx , ' tcx > (
0 commit comments