]> git.lizzy.rs Git - rust.git/commitdiff
Use polonius_output
authorSantiago Pastorino <spastorino@gmail.com>
Tue, 29 May 2018 11:54:15 +0000 (08:54 -0300)
committerSantiago Pastorino <spastorino@gmail.com>
Tue, 29 May 2018 13:19:46 +0000 (10:19 -0300)
src/Cargo.lock
src/librustc/Cargo.toml
src/librustc_mir/Cargo.toml
src/librustc_mir/borrow_check/flows.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/lib.rs

index 413ae2db2c869afaeecf62dde0fca1b432af0a26..6b7c165826f0a078d2d9ff43a427dc1c9689d344 100644 (file)
@@ -1455,7 +1455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "polonius-engine"
-version = "0.2.0"
+version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "datafrog 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1784,7 +1784,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.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "polonius-engine 0.4.0 (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",
@@ -2168,10 +2168,11 @@ dependencies = [
  "arena 0.0.0",
  "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "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.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
  "rustc_apfloat 0.0.0",
  "rustc_data_structures 0.0.0",
@@ -3172,7 +3173,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.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89be86c0ed0f63715d74d390b1a1a3df63cfca80b6eab604d7c4fecb5403cfdd"
+"checksum polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9385a6d8f8ff6fd7e48a803c6a77fb89cc929dc7e2af6bf972494bbc8ff8b9e4"
 "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 535fb2fcc3d9b028af5db53aef00cf8019cd803b..df68bf1fd9aabe98c09b7977de39183ee745b971 100644 (file)
@@ -16,7 +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.2.0"
+polonius-engine = "0.4.0"
 proc_macro = { path = "../libproc_macro" }
 rustc_apfloat = { path = "../librustc_apfloat" }
 rustc_target = { path = "../librustc_target" }
index c2cfd3a827db75603604e745be49b41f950ab05c..512ab53f401a6910bea2144f699af0a91de011cd 100644 (file)
@@ -11,10 +11,11 @@ crate-type = ["dylib"]
 [dependencies]
 arena = { path = "../libarena" }
 bitflags = "1.0"
+either = "1.5.0"
 graphviz = { path = "../libgraphviz" }
 log = "0.4"
 log_settings = "0.1.1"
-polonius-engine = "0.2.0"
+polonius-engine = "0.4.0"
 rustc = { path = "../librustc" }
 rustc_target = { path = "../librustc_target" }
 rustc_data_structures = { path = "../librustc_data_structures" }
index 61915646d6fdaf0a75297631a24021bf18726030..5d13eab8cf6b59aa4a8a8c9a1759abb6b91aa888 100644 (file)
@@ -27,6 +27,7 @@
 use dataflow::{FlowAtLocation, FlowsAtLocation};
 use dataflow::move_paths::HasMoveData;
 use dataflow::move_paths::indexes::BorrowIndex;
+use either::Either;
 use std::fmt;
 use std::rc::Rc;
 
@@ -61,8 +62,12 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
         }
     }
 
-    crate fn borrows_in_scope(&self) -> impl Iterator<Item = BorrowIndex> + '_ {
-        self.borrows.iter_incoming()
+    crate fn borrows_in_scope(&self, location: LocationIndex) -> impl Iterator<Item = BorrowIndex> + '_ {
+        if let Some(ref polonius) = self.polonius_output {
+            Either::Left(polonius.errors_at(location).iter().cloned())
+        } else {
+            Either::Right(self.borrows.iter_incoming())
+        }
     }
 
     crate fn with_outgoing_borrows(&self, op: impl FnOnce(Iter<BorrowIndex>)) {
index 983a2ac2ec1d1833d6901e34628eca537644a52f..9bfba219ccd7116e820683cd70981b5e4290f593 100644 (file)
@@ -937,6 +937,8 @@ fn check_access_for_conflict(
         let mut error_reported = false;
         let tcx = self.tcx;
         let mir = self.mir;
+        let location_table = &LocationTable::new(mir);
+        let location = location_table.start_index(context.loc);
         let borrow_set = self.borrow_set.clone();
         each_borrow_involving_path(
             self,
@@ -945,7 +947,7 @@ fn check_access_for_conflict(
             context,
             (sd, place_span.0),
             &borrow_set,
-            flow_state.borrows_in_scope(),
+            flow_state.borrows_in_scope(location),
             |this, borrow_index, borrow|
             match (rw, borrow.kind) {
                 // Obviously an activation is compatible with its own
index ace4709ba1d645d057815258bb02b547e18e6bff..34eb444fdc0cbf59a0ec1d32df22a1247214ce11 100644 (file)
@@ -38,6 +38,7 @@
 #[macro_use]
 extern crate bitflags;
 #[macro_use] extern crate log;
+extern crate either;
 extern crate graphviz as dot;
 extern crate polonius_engine;
 #[macro_use]