Skip to content

Commit 9de4e34

Browse files
committed
Use polonius_output
1 parent db39ec8 commit 9de4e34

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

src/Cargo.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
14551455

14561456
[[package]]
14571457
name = "polonius-engine"
1458-
version = "0.2.0"
1458+
version = "0.4.0"
14591459
source = "registry+https://github.com/rust-lang/crates.io-index"
14601460
dependencies = [
14611461
"datafrog 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1784,7 +1784,7 @@ dependencies = [
17841784
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
17851785
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
17861786
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
1787-
"polonius-engine 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
1787+
"polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
17881788
"proc_macro 0.0.0",
17891789
"rustc_apfloat 0.0.0",
17901790
"rustc_data_structures 0.0.0",
@@ -2168,10 +2168,11 @@ dependencies = [
21682168
"arena 0.0.0",
21692169
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
21702170
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
2171+
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
21712172
"graphviz 0.0.0",
21722173
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
21732174
"log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2174-
"polonius-engine 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2175+
"polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
21752176
"rustc 0.0.0",
21762177
"rustc_apfloat 0.0.0",
21772178
"rustc_data_structures 0.0.0",
@@ -3172,7 +3173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
31723173
"checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
31733174
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
31743175
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
3175-
"checksum polonius-engine 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89be86c0ed0f63715d74d390b1a1a3df63cfca80b6eab604d7c4fecb5403cfdd"
3176+
"checksum polonius-engine 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9385a6d8f8ff6fd7e48a803c6a77fb89cc929dc7e2af6bf972494bbc8ff8b9e4"
31763177
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
31773178
"checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
31783179
"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118"

src/librustc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ graphviz = { path = "../libgraphviz" }
1616
jobserver = "0.1"
1717
lazy_static = "1.0.0"
1818
log = { version = "0.4", features = ["release_max_level_info", "std"] }
19-
polonius-engine = "0.2.0"
19+
polonius-engine = "0.4.0"
2020
proc_macro = { path = "../libproc_macro" }
2121
rustc_apfloat = { path = "../librustc_apfloat" }
2222
rustc_target = { path = "../librustc_target" }

src/librustc_mir/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ crate-type = ["dylib"]
1111
[dependencies]
1212
arena = { path = "../libarena" }
1313
bitflags = "1.0"
14+
either = "1.5.0"
1415
graphviz = { path = "../libgraphviz" }
1516
log = "0.4"
1617
log_settings = "0.1.1"
17-
polonius-engine = "0.2.0"
18+
polonius-engine = "0.4.0"
1819
rustc = { path = "../librustc" }
1920
rustc_target = { path = "../librustc_target" }
2021
rustc_data_structures = { path = "../librustc_data_structures" }

src/librustc_mir/borrow_check/flows.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use dataflow::{Borrows};
2727
use dataflow::{FlowAtLocation, FlowsAtLocation};
2828
use dataflow::move_paths::HasMoveData;
2929
use dataflow::move_paths::indexes::BorrowIndex;
30+
use either::Either;
3031
use std::fmt;
3132
use std::rc::Rc;
3233

@@ -61,8 +62,12 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
6162
}
6263
}
6364

64-
crate fn borrows_in_scope(&self) -> impl Iterator<Item = BorrowIndex> + '_ {
65-
self.borrows.iter_incoming()
65+
crate fn borrows_in_scope(&self, location: LocationIndex) -> impl Iterator<Item = BorrowIndex> + '_ {
66+
if let Some(ref polonius) = self.polonius_output {
67+
Either::Left(polonius.errors_at(location).iter().cloned())
68+
} else {
69+
Either::Right(self.borrows.iter_incoming())
70+
}
6671
}
6772

6873
crate fn with_outgoing_borrows(&self, op: impl FnOnce(Iter<BorrowIndex>)) {

src/librustc_mir/borrow_check/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
937937
let mut error_reported = false;
938938
let tcx = self.tcx;
939939
let mir = self.mir;
940+
let location_table = &LocationTable::new(mir);
941+
let location = location_table.start_index(context.loc);
940942
let borrow_set = self.borrow_set.clone();
941943
each_borrow_involving_path(
942944
self,
@@ -945,7 +947,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
945947
context,
946948
(sd, place_span.0),
947949
&borrow_set,
948-
flow_state.borrows_in_scope(),
950+
flow_state.borrows_in_scope(location),
949951
|this, borrow_index, borrow|
950952
match (rw, borrow.kind) {
951953
// Obviously an activation is compatible with its own

src/librustc_mir/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern crate arena;
3838
#[macro_use]
3939
extern crate bitflags;
4040
#[macro_use] extern crate log;
41+
extern crate either;
4142
extern crate graphviz as dot;
4243
extern crate polonius_engine;
4344
#[macro_use]

0 commit comments

Comments
 (0)