Skip to content

Commit b45aebf

Browse files
qmxspastorino
authored andcommitted
it compiles, but we do not use the output yet
1 parent 4f88283 commit b45aebf

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
198198
let borrow_set = Rc::new(BorrowSet::build(tcx, mir));
199199

200200
// If we are in non-lexical mode, compute the non-lexical lifetimes.
201-
let (regioncx, opt_closure_req) = nll::compute_regions(
201+
let (regioncx, _polonius_output, opt_closure_req) = nll::compute_regions(
202202
infcx,
203203
def_id,
204204
free_regions,

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
use borrow_check::borrow_set::BorrowSet;
12-
use borrow_check::location::LocationTable;
12+
use borrow_check::location::{LocationIndex, LocationTable};
1313
use borrow_check::nll::facts::AllFactsExt;
1414
use dataflow::move_paths::MoveData;
1515
use dataflow::FlowAtLocation;
1616
use dataflow::MaybeInitializedPlaces;
17+
use dataflow::indexes::BorrowIndex;
1718
use rustc::hir::def_id::DefId;
1819
use rustc::infer::InferCtxt;
1920
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir};
@@ -22,13 +23,15 @@ use rustc::util::nodemap::FxHashMap;
2223
use std::collections::BTreeSet;
2324
use std::fmt::Debug;
2425
use std::io;
26+
use std::rc::Rc;
2527
use std::path::PathBuf;
2628
use transform::MirSource;
2729
use util::liveness::{LivenessResults, LocalSet};
2830

2931
use self::mir_util::PassWhere;
3032
use util as mir_util;
3133
use util::pretty::{self, ALIGN};
34+
use polonius_engine::{Algorithm, Output};
3235

3336
mod constraint_generation;
3437
pub mod explain_borrow;
@@ -83,6 +86,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
8386
borrow_set: &BorrowSet<'tcx>,
8487
) -> (
8588
RegionInferenceContext<'tcx>,
89+
Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
8690
Option<ClosureRegionRequirements<'gcx>>,
8791
) {
8892
// Run the MIR type-checker.
@@ -98,7 +102,9 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
98102
move_data,
99103
);
100104

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+
{
102108
Some(AllFacts::default())
103109
} else {
104110
None
@@ -142,11 +148,19 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
142148
);
143149

144150
// 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+
});
150164

151165
// Solve the region constraints.
152166
let closure_region_requirements = regioncx.solve(infcx, &mir, def_id);
@@ -166,7 +180,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
166180
// information
167181
dump_annotation(infcx, &mir, def_id, &regioncx, &closure_region_requirements);
168182

169-
(regioncx, closure_region_requirements)
183+
(regioncx, polonius_output, closure_region_requirements)
170184
}
171185

172186
fn dump_mir_results<'a, 'gcx, 'tcx>(

0 commit comments

Comments
 (0)