about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlbin Stjerna <albin.stjerna@gmail.com>2019-07-18 12:38:32 +0200
committerAlbin Stjerna <albin.stjerna@gmail.com>2019-09-04 09:44:40 +0200
commit996ba932ccd03f2372c5c25eaf5f5025d397a73c (patch)
treeff020087eaa6142216367611d73d27719ba475b8
parent2adb246b5c6bfcaae09971c9d54810cb7d58d43e (diff)
downloadrust-996ba932ccd03f2372c5c25eaf5f5025d397a73c.tar.gz
rust-996ba932ccd03f2372c5c25eaf5f5025d397a73c.zip
NLL: Adapt to the new Polonius types
-rw-r--r--src/librustc_mir/borrow_check/flows.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/facts.rs16
-rw-r--r--src/librustc_mir/borrow_check/nll/mod.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs14
4 files changed, 24 insertions, 14 deletions
diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs
index bb217a1f965..4400e0c8395 100644
--- a/src/librustc_mir/borrow_check/flows.rs
+++ b/src/librustc_mir/borrow_check/flows.rs
@@ -12,7 +12,7 @@ use crate::borrow_check::location::LocationIndex;
 use polonius_engine::Output;
 
 use crate::dataflow::indexes::BorrowIndex;
-use crate::dataflow::move_paths::HasMoveData;
+use crate::dataflow::move_paths::{HasMoveData, MovePathIndex};
 use crate::dataflow::Borrows;
 use crate::dataflow::EverInitializedPlaces;
 use crate::dataflow::MaybeUninitializedPlaces;
@@ -21,7 +21,7 @@ use either::Either;
 use std::fmt;
 use std::rc::Rc;
 
-crate type PoloniusOutput = Output<RegionVid, BorrowIndex, LocationIndex, Local>;
+crate type PoloniusOutput = Output<RegionVid, BorrowIndex, LocationIndex, Local, MovePathIndex>;
 
 // (forced to be `pub` due to its use as an associated type below.)
 crate struct Flows<'b, 'tcx> {
diff --git a/src/librustc_mir/borrow_check/nll/facts.rs b/src/librustc_mir/borrow_check/nll/facts.rs
index 05451cdfb83..10ce3a099cf 100644
--- a/src/librustc_mir/borrow_check/nll/facts.rs
+++ b/src/librustc_mir/borrow_check/nll/facts.rs
@@ -1,5 +1,5 @@
 use crate::borrow_check::location::{LocationIndex, LocationTable};
-use crate::dataflow::indexes::BorrowIndex;
+use crate::dataflow::indexes::{BorrowIndex, MovePathIndex};
 use polonius_engine::AllFacts as PoloniusAllFacts;
 use polonius_engine::Atom;
 use rustc::mir::Local;
@@ -11,7 +11,7 @@ use std::fs::{self, File};
 use std::io::Write;
 use std::path::Path;
 
-crate type AllFacts = PoloniusAllFacts<RegionVid, BorrowIndex, LocationIndex, Local>;
+crate type AllFacts = PoloniusAllFacts<RegionVid, BorrowIndex, LocationIndex, Local, MovePathIndex>;
 
 crate trait AllFactsExt {
     /// Returns `true` if there is a need to gather `AllFacts` given the
@@ -65,7 +65,11 @@ impl AllFactsExt for AllFacts {
                 var_drop_used,
                 var_uses_region,
                 var_drops_region,
-                var_initialized_on_exit,
+                var_maybe_initialized_on_exit,
+                parent,
+                var_starts_path,
+                initialized_at,
+                moved_out_at,
             ])
         }
         Ok(())
@@ -84,6 +88,12 @@ impl Atom for LocationIndex {
     }
 }
 
+impl Atom for MovePathIndex {
+    fn index(self) -> usize {
+        Idx::index(self)
+    }
+}
+
 struct FactWriter<'w> {
     location_table: &'w LocationTable,
     dir: &'w Path,
diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs
index 11ec154e5b5..19a3d0eb03d 100644
--- a/src/librustc_mir/borrow_check/nll/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/mod.rs
@@ -4,7 +4,7 @@ use crate::borrow_check::nll::facts::AllFactsExt;
 use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints};
 use crate::borrow_check::nll::region_infer::values::RegionValueElements;
 use crate::dataflow::indexes::BorrowIndex;
-use crate::dataflow::move_paths::MoveData;
+use crate::dataflow::move_paths::{MoveData, MovePathIndex};
 use crate::dataflow::FlowAtLocation;
 use crate::dataflow::MaybeInitializedPlaces;
 use crate::transform::MirSource;
@@ -87,7 +87,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
     errors_buffer: &mut Vec<Diagnostic>,
 ) -> (
     RegionInferenceContext<'tcx>,
-    Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex, Local>>>,
+    Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex, Local, MovePathIndex>>>,
     Option<ClosureRegionRequirements<'tcx>>,
 ) {
     let mut all_facts = if AllFacts::enabled(infcx.tcx) {
diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
index 039ed939ada..de085fc480a 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
@@ -134,7 +134,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
 
             // FIXME: this is temporary until we can generate our own initialization
             if self.cx.typeck.borrowck_context.all_facts.is_some() {
-                self.add_polonius_var_initialized_on_exit_for(local)
+                self.add_polonius_var_maybe_initialized_on_exit_for(local)
             }
 
             self.compute_use_live_points_for(local);
@@ -161,14 +161,14 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
     //
     // FIXME: this analysis (the initialization tracking) should be
     // done in Polonius, but isn't yet.
-    fn add_polonius_var_initialized_on_exit_for(&mut self, local: Local) {
+    fn add_polonius_var_maybe_initialized_on_exit_for(&mut self, local: Local) {
         let move_path = self.cx.move_data.rev_lookup.find_local(local);
         let facts = self.cx.typeck.borrowck_context.all_facts.as_mut().unwrap();
         for block in self.cx.body.basic_blocks().indices() {
             debug!("polonius: generating initialization facts for {:?} in {:?}", local, block);
 
             // iterate through the block, applying the effects of each statement
-            // up to and including location, and populate `var_initialized_on_exit`
+            // up to and including location, and populate `var_maybe_initialized_on_exit`
             self.cx.flow_inits.reset_to_entry_of(block);
             let start_location = Location { block, statement_index: 0 };
             self.cx.flow_inits.apply_local_effect(start_location);
@@ -181,7 +181,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
                 // statement has not yet taken effect:
                 if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
                     facts
-                        .var_initialized_on_exit
+                        .var_maybe_initialized_on_exit
                         .push((local, self.cx.location_table.start_index(current_location)));
                 }
 
@@ -190,7 +190,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
 
                 if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
                     facts
-                        .var_initialized_on_exit
+                        .var_maybe_initialized_on_exit
                         .push((local, self.cx.location_table.mid_index(current_location)));
                 }
             }
@@ -199,7 +199,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
 
             if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
                 facts
-                    .var_initialized_on_exit
+                    .var_maybe_initialized_on_exit
                     .push((local, self.cx.location_table.start_index(terminator_location)));
             }
 
@@ -208,7 +208,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
 
             if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
                 facts
-                    .var_initialized_on_exit
+                    .var_maybe_initialized_on_exit
                     .push((local, self.cx.location_table.mid_index(terminator_location)));
             }
         }