Skip to content
Merged
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2618,9 +2618,9 @@ checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"

[[package]]
name = "polonius-engine"
version = "0.12.1"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef2558a4b464e185b36ee08a2937ebb62ea5464c38856cfb1465c97cb38db52d"
checksum = "c4e8e505342045d397d0b6674dcb82d6faf5cf40484d30eeb88fc82ef14e903f"
dependencies = [
"datafrog",
"log",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rustc_arena = { path = "../rustc_arena" }
bitflags = "1.2.1"
tracing = "0.1"
rustc-rayon-core = "0.3.1"
polonius-engine = "0.12.0"
polonius-engine = "0.13.0"
rustc_apfloat = { path = "../rustc_apfloat" }
rustc_attr = { path = "../rustc_attr" }
rustc_feature = { path = "../rustc_feature" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rustc_graphviz = { path = "../rustc_graphviz" }
gsgdt = "0.1.2"
itertools = "0.9"
tracing = "0.1"
polonius-engine = "0.12.0"
polonius-engine = "0.13.0"
regex = "1"
rustc_middle = { path = "../rustc_middle" }
rustc_attr = { path = "../rustc_attr" }
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir/src/borrow_check/constraint_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {

if places_conflict {
let location_index = self.location_table.mid_index(location);
all_facts.killed.push((borrow_index, location_index));
all_facts.loan_killed_at.push((borrow_index, location_index));
}
}
}
Expand All @@ -243,10 +243,10 @@ fn record_killed_borrows_for_local(
location: Location,
) {
if let Some(borrow_indices) = borrow_set.local_map.get(&local) {
all_facts.killed.reserve(borrow_indices.len());
all_facts.loan_killed_at.reserve(borrow_indices.len());
for &borrow_index in borrow_indices {
let location_index = location_table.mid_index(location);
all_facts.killed.push((borrow_index, location_index));
all_facts.loan_killed_at.push((borrow_index, location_index));
}
}
}
12 changes: 6 additions & 6 deletions compiler/rustc_mir/src/borrow_check/facts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ impl AllFactsExt for AllFacts {
}
write_facts_to_path! {
wr.write_facts_to_path(self.[
borrow_region,
loan_issued_at,
universal_region,
placeholder,
cfg_edge,
killed,
outlives,
invalidates,
loan_killed_at,
subset_base,
loan_invalidated_at,
var_used_at,
var_defined_at,
var_dropped_at,
Expand All @@ -81,7 +80,8 @@ impl AllFactsExt for AllFacts {
path_assigned_at_base,
path_moved_at_base,
path_accessed_at_base,
known_subset,
known_placeholder_subset,
placeholder,
])
}
Ok(())
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_mir/src/borrow_check/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
let resume = self.location_table.start_index(resume.start_location());
for (i, data) in borrow_set.iter_enumerated() {
if borrow_of_local_data(data.borrowed_place) {
self.all_facts.invalidates.push((resume, i));
self.all_facts.loan_invalidated_at.push((resume, i));
}
}

Expand All @@ -191,7 +191,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
let start = self.location_table.start_index(location);
for (i, data) in borrow_set.iter_enumerated() {
if borrow_of_local_data(data.borrowed_place) {
self.all_facts.invalidates.push((start, i));
self.all_facts.loan_invalidated_at.push((start, i));
}
}
}
Expand Down Expand Up @@ -420,26 +420,26 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {

// Unique and mutable borrows are invalidated by reads from any
// involved path
this.generate_invalidates(borrow_index, location);
this.emit_loan_invalidated_at(borrow_index, location);
}

(Reservation(_) | Activation(_, _) | Write(_), _) => {
// unique or mutable borrows are invalidated by writes.
// Reservations count as writes since we need to check
// that activating the borrow will be OK
// FIXME(bob_twinkles) is this actually the right thing to do?
this.generate_invalidates(borrow_index, location);
this.emit_loan_invalidated_at(borrow_index, location);
}
}
Control::Continue
},
);
}

/// Generates a new `invalidates(L, B)` fact.
fn generate_invalidates(&mut self, b: BorrowIndex, l: Location) {
/// Generates a new `loan_invalidated_at(L, B)` fact.
fn emit_loan_invalidated_at(&mut self, b: BorrowIndex, l: Location) {
let lidx = self.location_table.start_index(l);
self.all_facts.invalidates.push((lidx, b));
self.all_facts.loan_invalidated_at.push((lidx, b));
}

fn check_activations(&mut self, location: Location) {
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_mir/src/borrow_check/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,15 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
}

// 2: the universal region relations `outlives` constraints are emitted as
// `known_subset` facts.
// `known_placeholder_subset` facts.
for (fr1, fr2) in universal_region_relations.known_outlives() {
if fr1 != fr2 {
debug!(
"compute_regions: emitting polonius `known_subset` fr1={:?}, fr2={:?}",
"compute_regions: emitting polonius `known_placeholder_subset` \
fr1={:?}, fr2={:?}",
fr1, fr2
);
all_facts.known_subset.push((*fr1, *fr2));
all_facts.known_placeholder_subset.push((*fr1, *fr2));
}
}
}
Expand Down Expand Up @@ -281,7 +282,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(

if infcx.tcx.sess.opts.debugging_opts.polonius {
let algorithm =
env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Naive"));
env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Hybrid"));
let algorithm = Algorithm::from_str(&algorithm).unwrap();
debug!("compute_regions: using polonius algorithm {:?}", algorithm);
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir/src/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn translate_outlives_facts(typeck: &mut TypeChecker<'_, '_>) {
if let Some(facts) = cx.all_facts {
let _prof_timer = typeck.infcx.tcx.prof.generic_activity("polonius_fact_generation");
let location_table = cx.location_table;
facts.outlives.extend(cx.constraints.outlives_constraints.outlives().iter().flat_map(
facts.subset_base.extend(cx.constraints.outlives_constraints.outlives().iter().flat_map(
|constraint: &OutlivesConstraint<'_>| {
if let Some(from_location) = constraint.locations.from_location() {
Either::Left(iter::once((
Expand Down Expand Up @@ -2461,7 +2461,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let BorrowCheckContext { borrow_set, location_table, all_facts, constraints, .. } =
self.borrowck_context;

// In Polonius mode, we also push a `borrow_region` fact
// In Polonius mode, we also push a `loan_issued_at` fact
// linking the loan to the region (in some cases, though,
// there is no loan associated with this borrow expression --
// that occurs when we are borrowing an unsafe place, for
Expand All @@ -2470,7 +2470,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
if let Some(borrow_index) = borrow_set.get_index_of(&location) {
let region_vid = borrow_region.to_region_vid();
all_facts.borrow_region.push((
all_facts.loan_issued_at.push((
region_vid,
borrow_index,
location_table.mid_index(location),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:18:9
|
LL | let mut f: Option<&u32> = None;
| ----- `f` declared here, outside of the closure body
LL | closure_expecting_bound(|x| {
| - `x` is a reference that is only valid in the closure body
LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here

error[E0521]: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:28:9
|
LL | let mut f: Option<&u32> = None;
| ----- `f` declared here, outside of the closure body
LL | closure_expecting_bound(|x: &u32| {
| - `x` is a reference that is only valid in the closure body
LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here

error: lifetime may not live long enough
--> $DIR/expect-region-supply-region.rs:37:30
--> $DIR/expect-region-supply-region-2.rs:14:30
|
LL | fn expect_bound_supply_named<'x>() {
| -- lifetime `'x` defined here
Expand All @@ -30,7 +10,7 @@ LL | closure_expecting_bound(|x: &'x u32| {
| requires that `'1` must outlive `'x`

error[E0521]: borrowed data escapes outside of closure
--> $DIR/expect-region-supply-region.rs:42:9
--> $DIR/expect-region-supply-region-2.rs:20:9
|
LL | let mut f: Option<&u32> = None;
| ----- `f` declared here, outside of the closure body
Expand All @@ -42,7 +22,7 @@ LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here

error: lifetime may not live long enough
--> $DIR/expect-region-supply-region.rs:37:30
--> $DIR/expect-region-supply-region-2.rs:14:30
|
LL | fn expect_bound_supply_named<'x>() {
| -- lifetime `'x` defined here
Expand All @@ -52,5 +32,6 @@ LL | closure_expecting_bound(|x: &'x u32| {
|
= help: consider replacing `'x` with `'static`

error: aborting due to 5 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0521`.
36 changes: 19 additions & 17 deletions src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:22:1
--> $DIR/hrtb-perfect-forwarding.rs:16:1
|
LL | / fn no_hrtb<'b,T>(mut t: T)
LL | | where T : Bar<&'b isize>
LL | / fn no_hrtb<'b, T>(mut t: T)
LL | | where
LL | | T: Bar<&'b isize>,
LL | | {
LL | | // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that
LL | | // `&mut T : Bar<&'b isize>`.
... |
LL | | no_hrtb(&mut t);
| | --------------- recursive call site
LL | | }
Expand All @@ -15,12 +15,12 @@ LL | | }
= help: a `loop` may express intention better if this is on purpose

warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:30:1
--> $DIR/hrtb-perfect-forwarding.rs:25:1
|
LL | / fn bar_hrtb<T>(mut t: T)
LL | | where T : for<'b> Bar<&'b isize>
LL | | where
LL | | T: for<'b> Bar<&'b isize>,
LL | | {
LL | | // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above
... |
LL | | bar_hrtb(&mut t);
| | ---------------- recursive call site
Expand All @@ -30,40 +30,42 @@ LL | | }
= help: a `loop` may express intention better if this is on purpose

warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:39:1
--> $DIR/hrtb-perfect-forwarding.rs:35:1
|
LL | / fn foo_hrtb_bar_not<'b,T>(mut t: T)
LL | | where T : for<'a> Foo<&'a isize> + Bar<&'b isize>
LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T)
LL | | where
LL | | T: for<'a> Foo<&'a isize> + Bar<&'b isize>,
LL | | {
LL | | // Not OK -- The forwarding impl for `Foo` requires that `Bar` also
... |
LL | | foo_hrtb_bar_not(&mut t);
| | ------------------------ recursive call site
LL | |
LL | |
LL | | }
| |_^ cannot return without recursing
|
= help: a `loop` may express intention better if this is on purpose

error: higher-ranked subtype error
--> $DIR/hrtb-perfect-forwarding.rs:46:5
--> $DIR/hrtb-perfect-forwarding.rs:43:5
|
LL | foo_hrtb_bar_not(&mut t);
| ^^^^^^^^^^^^^^^^^^^^^^^^

warning: function cannot return without recursing
--> $DIR/hrtb-perfect-forwarding.rs:50:1
--> $DIR/hrtb-perfect-forwarding.rs:48:1
|
LL | / fn foo_hrtb_bar_hrtb<T>(mut t: T)
LL | | where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>
LL | | where
LL | | T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>,
LL | | {
LL | | // OK -- now we have `T : for<'b> Bar&'b isize>`.
LL | | // OK -- now we have `T : for<'b> Bar<&'b isize>`.
LL | | foo_hrtb_bar_hrtb(&mut t);
| | ------------------------- recursive call site
LL | | }
| |_^ cannot return without recursing
|
= help: a `loop` may express intention better if this is on purpose

error: aborting due to previous error
error: aborting due to previous error; 4 warnings emitted

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/error-handling.rs:23:16
--> $DIR/error-handling.rs:22:16
|
LL | fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
| -- -- lifetime `'b` defined here
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/infinite/infinite-instantiation.polonius.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: reached the recursion limit while instantiating `function::<Option<Option<Option<...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/infinite-instantiation.rs:22:9
|
LL | function(counter - 1, t.to_option());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `function` defined here
--> $DIR/infinite-instantiation.rs:20:1
|
LL | fn function<T:ToOpt + Clone>(counter: usize, t: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the full type name has been written to '$TEST_BUILD_DIR/infinite/infinite-instantiation.polonius/infinite-instantiation.long-type.txt'

error: aborting due to previous error

15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-22638.polonius.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: reached the recursion limit while instantiating `A::matches::$CLOSURE`
--> $DIR/issue-22638.rs:56:9
|
LL | a.matches(f)
| ^^^^^^^^^^^^
|
note: `A::matches` defined here
--> $DIR/issue-22638.rs:15:5
|
LL | pub fn matches<F: Fn()>(&self, f: &F) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-22638.polonius/issue-22638.long-type.txt'

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: reached the recursion limit while instantiating `<(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(.....), ...), ...) as Foo>::recurse`
--> $DIR/issue-37311.rs:17:9
|
LL | (self, self).recurse();
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: `<T as Foo>::recurse` defined here
--> $DIR/issue-37311.rs:16:5
|
LL | fn recurse(&self) {
| ^^^^^^^^^^^^^^^^^
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-37311-type-length-limit/issue-37311.polonius/issue-37311.long-type.txt'

error: aborting due to previous error

17 changes: 17 additions & 0 deletions src/test/ui/issues/issue-67552.polonius.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut &... &mut &mut &mut &mut &mut Empty>`
--> $DIR/issue-67552.rs:28:9
|
LL | rec(identity(&mut it))
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: `rec` defined here
--> $DIR/issue-67552.rs:21:1
|
LL | / fn rec<T>(mut it: T)
LL | | where
LL | | T: Iterator,
| |________________^
= note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-67552.polonius/issue-67552.long-type.txt'

error: aborting due to previous error

Loading