Skip to content

Commit 479cc7a

Browse files
committed
update to polonius 0.11 to compute subset errors
- adapt to the new polonius `FactTypes` API - reorganize the type aliases referring to polonius to avoid referencing the inner atom or fact types multiple times: only one input and output types should be enough for everyone. They could equally be in `borrow_check` as `nll` though.
1 parent 7b482cd commit 479cc7a

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,9 +2575,9 @@ checksum = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
25752575

25762576
[[package]]
25772577
name = "polonius-engine"
2578-
version = "0.10.0"
2578+
version = "0.11.0"
25792579
source = "registry+https://github.com/rust-lang/crates.io-index"
2580-
checksum = "50fa9dbfd0d3d60594da338cfe6f94028433eecae4b11b7e83fd99759227bbfe"
2580+
checksum = "1e478d7c38eb785c6416cbe58df12aa55d7aefa3759b6d3e044b2ed03f423cec"
25812581
dependencies = [
25822582
"datafrog",
25832583
"log",

src/librustc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ scoped-tls = "1.0"
2020
log = { version = "0.4", features = ["release_max_level_info", "std"] }
2121
rustc-rayon = "0.3.0"
2222
rustc-rayon-core = "0.3.0"
23-
polonius-engine = "0.10.0"
23+
polonius-engine = "0.11.0"
2424
rustc_apfloat = { path = "../librustc_apfloat" }
2525
rustc_feature = { path = "../librustc_feature" }
2626
rustc_target = { path = "../librustc_target" }

src/librustc_mir/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dot = { path = "../libgraphviz", package = "graphviz" }
1616
itertools = "0.8"
1717
log = "0.4"
1818
log_settings = "0.1.1"
19-
polonius-engine = "0.10.0"
19+
polonius-engine = "0.11.0"
2020
rustc = { path = "../librustc" }
2121
rustc_target = { path = "../librustc_target" }
2222
rustc_data_structures = { path = "../librustc_data_structures" }

src/librustc_mir/borrow_check/flows.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
//! FIXME: this might be better as a "generic" fixed-point combinator,
44
//! but is not as ugly as it is right now.
55
6-
use rustc::mir::{BasicBlock, Local, Location};
7-
use rustc::ty::RegionVid;
6+
use rustc::mir::{BasicBlock, Location};
87
use rustc_index::bit_set::BitIter;
98

109
use crate::borrow_check::location::LocationIndex;
1110

12-
use polonius_engine::Output;
11+
use crate::borrow_check::nll::PoloniusOutput;
1312

1413
use crate::dataflow::indexes::BorrowIndex;
15-
use crate::dataflow::move_paths::{HasMoveData, MovePathIndex};
14+
use crate::dataflow::move_paths::HasMoveData;
1615
use crate::dataflow::Borrows;
1716
use crate::dataflow::EverInitializedPlaces;
1817
use crate::dataflow::MaybeUninitializedPlaces;
@@ -21,8 +20,6 @@ use either::Either;
2120
use std::fmt;
2221
use std::rc::Rc;
2322

24-
crate type PoloniusOutput = Output<RegionVid, BorrowIndex, LocationIndex, Local, MovePathIndex>;
25-
2623
crate struct Flows<'b, 'tcx> {
2724
borrows: FlowAtLocation<'tcx, Borrows<'b, 'tcx>>,
2825
pub uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'tcx>>,

src/librustc_mir/borrow_check/nll/facts.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::borrow_check::location::{LocationIndex, LocationTable};
22
use crate::dataflow::indexes::{BorrowIndex, MovePathIndex};
3-
use polonius_engine::AllFacts as PoloniusAllFacts;
3+
use polonius_engine::AllFacts as PoloniusFacts;
44
use polonius_engine::Atom;
55
use rustc::mir::Local;
66
use rustc::ty::{RegionVid, TyCtxt};
@@ -11,7 +11,18 @@ use std::fs::{self, File};
1111
use std::io::Write;
1212
use std::path::Path;
1313

14-
crate type AllFacts = PoloniusAllFacts<RegionVid, BorrowIndex, LocationIndex, Local, MovePathIndex>;
14+
#[derive(Copy, Clone, Debug)]
15+
crate struct RustcFacts;
16+
17+
impl polonius_engine::FactTypes for RustcFacts {
18+
type Origin = RegionVid;
19+
type Loan = BorrowIndex;
20+
type Point = LocationIndex;
21+
type Variable = Local;
22+
type Path = MovePathIndex;
23+
}
24+
25+
crate type AllFacts = PoloniusFacts<RustcFacts>;
1526

1627
crate trait AllFactsExt {
1728
/// Returns `true` if there is a need to gather `AllFacts` given the

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::borrow_check::borrow_set::BorrowSet;
2-
use crate::borrow_check::location::{LocationIndex, LocationTable};
2+
use crate::borrow_check::location::LocationTable;
33
use crate::borrow_check::nll::facts::AllFactsExt;
44
use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints};
55
use crate::borrow_check::nll::region_infer::values::RegionValueElements;
6-
use crate::dataflow::indexes::BorrowIndex;
7-
use crate::dataflow::move_paths::{InitLocation, MoveData, MovePathIndex, InitKind};
6+
use crate::dataflow::move_paths::{InitLocation, MoveData, InitKind};
87
use crate::dataflow::FlowAtLocation;
98
use crate::dataflow::MaybeInitializedPlaces;
109
use crate::transform::MirSource;
@@ -43,10 +42,12 @@ crate mod universal_regions;
4342
crate mod type_check;
4443
crate mod region_infer;
4544

46-
use self::facts::AllFacts;
45+
use self::facts::{AllFacts, RustcFacts};
4746
use self::region_infer::RegionInferenceContext;
4847
use self::universal_regions::UniversalRegions;
4948

49+
crate type PoloniusOutput = Output<RustcFacts>;
50+
5051
/// Rewrites the regions in the MIR to use NLL variables, also
5152
/// scraping out the set of universal regions (e.g., region parameters)
5253
/// declared on the function. That set will need to be given to
@@ -170,7 +171,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
170171
errors_buffer: &mut Vec<Diagnostic>,
171172
) -> (
172173
RegionInferenceContext<'tcx>,
173-
Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex, Local, MovePathIndex>>>,
174+
Option<Rc<PoloniusOutput>>,
174175
Option<ClosureRegionRequirements<'tcx>>,
175176
) {
176177
let mut all_facts = if AllFacts::enabled(infcx.tcx) {

0 commit comments

Comments
 (0)