]> git.lizzy.rs Git - rust.git/commitdiff
Use AllFacts from polonius-engine
authorSantiago Pastorino <spastorino@gmail.com>
Thu, 24 May 2018 21:52:01 +0000 (18:52 -0300)
committerSantiago Pastorino <spastorino@gmail.com>
Thu, 24 May 2018 22:56:02 +0000 (19:56 -0300)
src/Cargo.lock
src/librustc/Cargo.toml
src/librustc/lib.rs
src/librustc/ty/sty.rs
src/librustc_mir/Cargo.toml
src/librustc_mir/borrow_check/nll/facts.rs
src/librustc_mir/borrow_check/nll/mod.rs
src/librustc_mir/dataflow/move_paths/mod.rs
src/librustc_mir/lib.rs
src/tools/tidy/src/deps.rs

index 0392466956eb6c58a9a5118b0b6293d38544ccc1..ef545db1f2992b8fc723f2f9893799ec2e86dfd4 100644 (file)
@@ -1424,6 +1424,11 @@ name = "pkg-config"
 version = "0.3.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "polonius-engine"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
 [[package]]
 name = "precomputed-hash"
 version = "0.1.1"
@@ -1745,6 +1750,7 @@ dependencies = [
  "jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "proc_macro 0.0.0",
  "rustc_apfloat 0.0.0",
  "rustc_data_structures 0.0.0",
@@ -2111,6 +2117,7 @@ dependencies = [
  "graphviz 0.0.0",
  "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
  "rustc_apfloat 0.0.0",
  "rustc_data_structures 0.0.0",
@@ -3107,6 +3114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
 "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
 "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
+"checksum polonius-engine 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6201ffe79e3da53bd065fbec2a9b391e5a0dc21038b39bb300612ddc658eb7ee"
 "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
 "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
 "checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"
index 8f9a8bd5c015f24b10560c530d17d54fa3f7acb2..4223b49a5b4f0d815c1f5a44e875d47d4b87f7ee 100644 (file)
@@ -16,6 +16,7 @@ graphviz = { path = "../libgraphviz" }
 jobserver = "0.1"
 lazy_static = "1.0.0"
 log = { version = "0.4", features = ["release_max_level_info", "std"] }
+polonius-engine = "0.1.1"
 proc_macro = { path = "../libproc_macro" }
 rustc_apfloat = { path = "../librustc_apfloat" }
 rustc_target = { path = "../librustc_target" }
index 1d53a305193fae50cb8e05d735b4985076ce3fd9..08e49ea94bf026bd4eb5b754bd011e28b3f217b6 100644 (file)
@@ -80,6 +80,7 @@
 #[macro_use] extern crate lazy_static;
 #[cfg(windows)]
 extern crate libc;
+extern crate polonius_engine;
 extern crate rustc_target;
 #[macro_use] extern crate rustc_data_structures;
 extern crate serialize;
index faf93ab30b70af25985d168bdd5641b4fd77a797..5980e19e69991ba34047f418171b9e092928dd14 100644 (file)
@@ -14,6 +14,7 @@
 
 use middle::const_val::ConstVal;
 use middle::region;
+use polonius_engine::Atom;
 use rustc_data_structures::indexed_vec::Idx;
 use ty::subst::{Substs, Subst, Kind, UnpackedKind};
 use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable};
@@ -1169,6 +1170,24 @@ pub struct FloatVid {
         DEBUG_FORMAT = custom,
     });
 
+impl Atom for RegionVid {
+    fn index(self) -> usize {
+        Idx::index(self)
+    }
+}
+
+impl From<usize> for RegionVid {
+    fn from(i: usize) -> RegionVid {
+        RegionVid::new(i)
+    }
+}
+
+impl From<RegionVid> for usize {
+    fn from(vid: RegionVid) -> usize {
+        Idx::index(vid)
+    }
+}
+
 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
 pub enum InferTy {
     TyVar(TyVid),
index 62964745b6f9eb49ff8c8730a4375dd4dd1b255a..e88ff38ed7d34efcd847f6c4db331d467f16bfb2 100644 (file)
@@ -14,6 +14,7 @@ bitflags = "1.0"
 graphviz = { path = "../libgraphviz" }
 log = "0.4"
 log_settings = "0.1.1"
+polonius-engine = "0.1.1"
 rustc = { path = "../librustc" }
 rustc_target = { path = "../librustc_target" }
 rustc_data_structures = { path = "../librustc_data_structures" }
index 2b2aadba7f92e39db1cfab1487a2da4fe7c5a56a..6cb8e64b9f5b46d0226b27c2158abe524f75156d 100644 (file)
 
 use borrow_check::location::{LocationIndex, LocationTable};
 use dataflow::indexes::BorrowIndex;
+use polonius_engine::AllFacts as PoloniusAllFacts;
+use polonius_engine::Atom;
 use rustc::ty::RegionVid;
+use rustc_data_structures::indexed_vec::Idx;
 use std::error::Error;
 use std::fmt::Debug;
 use std::fs::{self, File};
 use std::io::Write;
 use std::path::Path;
 
-/// The "facts" which are the basis of the NLL borrow analysis.
-#[derive(Default)]
-crate struct AllFacts {
-    // `borrow_region(R, B, P)` -- the region R may refer to data from borrow B
-    // starting at the point P (this is usually the point *after* a borrow rvalue)
-    crate borrow_region: Vec<(RegionVid, BorrowIndex, LocationIndex)>,
+crate type AllFacts = PoloniusAllFacts<RegionVid, BorrowIndex, LocationIndex>;
 
-    // universal_region(R) -- this is a "free region" within fn body
-    crate universal_region: Vec<RegionVid>,
-
-    // `cfg_edge(P,Q)` for each edge P -> Q in the control flow
-    crate cfg_edge: Vec<(LocationIndex, LocationIndex)>,
-
-    // `killed(B,P)` when some prefix of the path borrowed at B is assigned at point P
-    crate killed: Vec<(BorrowIndex, LocationIndex)>,
-
-    // `outlives(R1, R2, P)` when we require `R1@P: R2@P`
-    crate outlives: Vec<(RegionVid, RegionVid, LocationIndex)>,
-
-    // `region_live_at(R, P)` when the region R appears in a live variable at P
-    crate region_live_at: Vec<(RegionVid, LocationIndex)>,
-
-    // `invalidates(P, B)` when the borrow B is invalidated at point P
-    crate invalidates: Vec<(LocationIndex, BorrowIndex)>,
+crate trait AllFactsExt {
+    fn write_to_dir(
+        &self,
+        dir: impl AsRef<Path>,
+        location_table: &LocationTable,
+    ) -> Result<(), Box<dyn Error>>;
 }
 
-impl AllFacts {
-    crate fn write_to_dir(
+impl AllFactsExt for AllFacts {
+    fn write_to_dir(
         &self,
         dir: impl AsRef<Path>,
         location_table: &LocationTable,
@@ -79,6 +66,42 @@ macro_rules! write_facts_to_path {
     }
 }
 
+impl Atom for BorrowIndex {
+    fn index(self) -> usize {
+        Idx::index(self)
+    }
+}
+
+impl From<usize> for BorrowIndex {
+    fn from(i: usize) -> BorrowIndex {
+        BorrowIndex::new(i)
+    }
+}
+
+impl From<BorrowIndex> for usize {
+    fn from(vid: BorrowIndex) -> usize {
+        Idx::index(vid)
+    }
+}
+
+impl Atom for LocationIndex {
+    fn index(self) -> usize {
+        Idx::index(self)
+    }
+}
+
+impl From<usize> for LocationIndex {
+    fn from(i: usize) -> LocationIndex {
+        LocationIndex::new(i)
+    }
+}
+
+impl From<LocationIndex> for usize {
+    fn from(vid: LocationIndex) -> usize {
+        Idx::index(vid)
+    }
+}
+
 struct FactWriter<'w> {
     location_table: &'w LocationTable,
     dir: &'w Path,
index 04e23c6f041e809e9a73a588a80326a73252cef2..a91789733a95e9ed4222d763ee92c2e121044473 100644 (file)
@@ -10,6 +10,7 @@
 
 use borrow_check::borrow_set::BorrowSet;
 use borrow_check::location::LocationTable;
+use borrow_check::nll::facts::AllFactsExt;
 use dataflow::move_paths::MoveData;
 use dataflow::FlowAtLocation;
 use dataflow::MaybeInitializedPlaces;
index 3a49e28f04187dbaf71b8e4e1bf7cd0cd1421f45..610963af9e13c67eeb6cea6c4099b46ea2380925 100644 (file)
@@ -34,7 +34,7 @@ pub(crate) mod indexes {
 
     macro_rules! new_index {
         ($Index:ident, $debug_name:expr) => {
-            #[derive(Copy, Clone, PartialEq, Eq, Hash)]
+            #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
             pub struct $Index(NonZeroUsize);
 
             impl Idx for $Index {
index 3bf9453fb513c82a5d2a69f2caa9620cce8ed4bd..ace4709ba1d645d057815258bb02b547e18e6bff 100644 (file)
@@ -39,6 +39,7 @@
 extern crate bitflags;
 #[macro_use] extern crate log;
 extern crate graphviz as dot;
+extern crate polonius_engine;
 #[macro_use]
 extern crate rustc;
 #[macro_use] extern crate rustc_data_structures;
index 5739ec5f325135669c35959a8b81e2446e622679..ab323843bf4dcec9ca5bb5d14d7a5e186d3162f7 100644 (file)
@@ -94,6 +94,7 @@
     Crate("owning_ref"),
     Crate("parking_lot"),
     Crate("parking_lot_core"),
+    Crate("polonius-engine"),
     Crate("quick-error"),
     Crate("rand"),
     Crate("redox_syscall"),