diff --git a/Cargo.lock b/Cargo.lock index 094a738b4160f..4c50dc50136fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 483f48db73e0d..2403ce2d24f55 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -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" } diff --git a/compiler/rustc_mir/Cargo.toml b/compiler/rustc_mir/Cargo.toml index ec1627f5c8af4..7656cf38cc14c 100644 --- a/compiler/rustc_mir/Cargo.toml +++ b/compiler/rustc_mir/Cargo.toml @@ -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" } diff --git a/compiler/rustc_mir/src/borrow_check/constraint_generation.rs b/compiler/rustc_mir/src/borrow_check/constraint_generation.rs index 33b09dcb888ed..c84928523d9d6 100644 --- a/compiler/rustc_mir/src/borrow_check/constraint_generation.rs +++ b/compiler/rustc_mir/src/borrow_check/constraint_generation.rs @@ -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)); } } } @@ -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)); } } } diff --git a/compiler/rustc_mir/src/borrow_check/facts.rs b/compiler/rustc_mir/src/borrow_check/facts.rs index 6d6b94ecf6440..bff8dab404903 100644 --- a/compiler/rustc_mir/src/borrow_check/facts.rs +++ b/compiler/rustc_mir/src/borrow_check/facts.rs @@ -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, @@ -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(()) diff --git a/compiler/rustc_mir/src/borrow_check/invalidation.rs b/compiler/rustc_mir/src/borrow_check/invalidation.rs index e621bafb671bb..b83a427f47574 100644 --- a/compiler/rustc_mir/src/borrow_check/invalidation.rs +++ b/compiler/rustc_mir/src/borrow_check/invalidation.rs @@ -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)); } } @@ -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)); } } } @@ -420,7 +420,7 @@ 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(_), _) => { @@ -428,7 +428,7 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> { // 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 @@ -436,10 +436,10 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> { ); } - /// 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) { diff --git a/compiler/rustc_mir/src/borrow_check/nll.rs b/compiler/rustc_mir/src/borrow_check/nll.rs index bfeafa33a91cf..b36bedcfc1135 100644 --- a/compiler/rustc_mir/src/borrow_check/nll.rs +++ b/compiler/rustc_mir/src/borrow_check/nll.rs @@ -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)); } } } @@ -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"); diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index 3fb06cd2f5f44..76732c5c5ce3f 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -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(( @@ -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 @@ -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), diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.polonius.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.polonius.stderr similarity index 51% rename from src/test/ui/closures/closure-expected-type/expect-region-supply-region.polonius.stderr rename to src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.polonius.stderr index df60416709f13..8846ccef34e2b 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.polonius.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.polonius.stderr @@ -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 @@ -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 @@ -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 @@ -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`. diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr b/src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr index 676a934569c47..a94c80eb30b16 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.polonius.stderr @@ -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 | | } @@ -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(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 @@ -30,34 +30,36 @@ 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(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 | | } @@ -65,5 +67,5 @@ LL | | } | = 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 diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr index 6ce3aaf49eb33..ccd0040030da2 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr @@ -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 diff --git a/src/test/ui/infinite/infinite-instantiation.polonius.stderr b/src/test/ui/infinite/infinite-instantiation.polonius.stderr new file mode 100644 index 0000000000000..29eb8c481cdee --- /dev/null +++ b/src/test/ui/infinite/infinite-instantiation.polonius.stderr @@ -0,0 +1,15 @@ +error: reached the recursion limit while instantiating `function::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $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(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 + diff --git a/src/test/ui/issues/issue-22638.polonius.stderr b/src/test/ui/issues/issue-22638.polonius.stderr new file mode 100644 index 0000000000000..87a7c00e4107b --- /dev/null +++ b/src/test/ui/issues/issue-22638.polonius.stderr @@ -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(&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 + diff --git a/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.polonius.stderr b/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.polonius.stderr new file mode 100644 index 0000000000000..3a1c0b82c227a --- /dev/null +++ b/src/test/ui/issues/issue-37311-type-length-limit/issue-37311.polonius.stderr @@ -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: `::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 + diff --git a/src/test/ui/issues/issue-67552.polonius.stderr b/src/test/ui/issues/issue-67552.polonius.stderr new file mode 100644 index 0000000000000..9ab77d3444d00 --- /dev/null +++ b/src/test/ui/issues/issue-67552.polonius.stderr @@ -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(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 + diff --git a/src/test/ui/issues/issue-8727.polonius.stderr b/src/test/ui/issues/issue-8727.polonius.stderr new file mode 100644 index 0000000000000..283c01b6b62a2 --- /dev/null +++ b/src/test/ui/issues/issue-8727.polonius.stderr @@ -0,0 +1,26 @@ +warning: function cannot return without recursing + --> $DIR/issue-8727.rs:7:1 + | +LL | fn generic() { + | ^^^^^^^^^^^^^^^ cannot return without recursing +LL | generic::>(); + | ---------------------- recursive call site + | + = note: `#[warn(unconditional_recursion)]` on by default + = help: a `loop` may express intention better if this is on purpose + +error: reached the recursion limit while instantiating `generic::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/issue-8727.rs:8:5 + | +LL | generic::>(); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: `generic` defined here + --> $DIR/issue-8727.rs:7:1 + | +LL | fn generic() { + | ^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-8727.polonius/issue-8727.long-type.txt' + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs index 4bdd05b4f92fa..2aabc0dab1edb 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.rs @@ -10,6 +10,7 @@ // relationship, and that holds. // // ignore-compare-mode-nll +// ignore-compare-mode-polonius fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) { // The two types above are not equivalent. With the older LUB/GLB diff --git a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.stderr b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.stderr index 252e13aada054..eacbbb8764025 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-hr-noteq2.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/old-lub-glb-hr-noteq2.rs:20:14 + --> $DIR/old-lub-glb-hr-noteq2.rs:21:14 | LL | let z = match 22 { | _____________- diff --git a/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr b/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr index 583b2c4cfe039..32cb5d231ad33 100644 --- a/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr +++ b/src/test/ui/meta/meta-expected-error-wrong-rev.a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/meta-expected-error-wrong-rev.rs:13:18 + --> $DIR/meta-expected-error-wrong-rev.rs:14:18 | LL | let x: u32 = 22_usize; | --- ^^^^^^^^ expected `u32`, found `usize` diff --git a/src/test/ui/meta/meta-expected-error-wrong-rev.rs b/src/test/ui/meta/meta-expected-error-wrong-rev.rs index 7e49434142bcb..80af527a6978d 100644 --- a/src/test/ui/meta/meta-expected-error-wrong-rev.rs +++ b/src/test/ui/meta/meta-expected-error-wrong-rev.rs @@ -1,4 +1,5 @@ // ignore-compare-mode-nll +// ignore-compare-mode-polonius // revisions: a // should-fail diff --git a/src/test/ui/nll/outlives-suggestion-simple.polonius.stderr b/src/test/ui/nll/outlives-suggestion-simple.polonius.stderr index dbbda62d2086c..c00288f2e3c73 100644 --- a/src/test/ui/nll/outlives-suggestion-simple.polonius.stderr +++ b/src/test/ui/nll/outlives-suggestion-simple.polonius.stderr @@ -121,3 +121,4 @@ LL | Bar2::new(&self) error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/nll/user-annotations/closure-substs.polonius.stderr b/src/test/ui/nll/user-annotations/closure-substs.polonius.stderr index 46b6c04dcbc34..af159a6cd1b85 100644 --- a/src/test/ui/nll/user-annotations/closure-substs.polonius.stderr +++ b/src/test/ui/nll/user-annotations/closure-substs.polonius.stderr @@ -21,7 +21,7 @@ error: lifetime may not live long enough --> $DIR/closure-substs.rs:15:16 | LL | |x: &i32| -> &'static i32 { - | - ------------ return type of closure is &'2 i32 + | - - let's call the lifetime of this reference `'2` | | | let's call the lifetime of this reference `'1` LL | return x; @@ -58,3 +58,4 @@ LL | b(x); error: aborting due to 6 previous errors +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/recursion/issue-38591-non-regular-dropck-recursion.polonius.stderr b/src/test/ui/recursion/issue-38591-non-regular-dropck-recursion.polonius.stderr new file mode 100644 index 0000000000000..4b4fc4fb7d189 --- /dev/null +++ b/src/test/ui/recursion/issue-38591-non-regular-dropck-recursion.polonius.stderr @@ -0,0 +1,15 @@ +error: reached the recursion limit while instantiating `std::ptr::drop_in_place::))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | +LL | pub unsafe fn drop_in_place(to_drop: *mut T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `std::ptr::drop_in_place` defined here + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | +LL | pub unsafe fn drop_in_place(to_drop: *mut T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-38591-non-regular-dropck-recursion.polonius/issue-38591-non-regular-dropck-recursion.long-type.txt' + +error: aborting due to previous error + diff --git a/src/test/ui/recursion/recursion.polonius.stderr b/src/test/ui/recursion/recursion.polonius.stderr new file mode 100644 index 0000000000000..c727fe551e3bc --- /dev/null +++ b/src/test/ui/recursion/recursion.polonius.stderr @@ -0,0 +1,15 @@ +error: reached the recursion limit while instantiating `test::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/recursion.rs:18:11 + | +LL | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `test` defined here + --> $DIR/recursion.rs:16:1 + | +LL | fn test (n:isize, i:isize, first:T, second:T) ->isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/recursion.polonius/recursion.long-type.txt' + +error: aborting due to previous error + diff --git a/src/test/ui/regions/issue-78262.default.stderr b/src/test/ui/regions/issue-78262.default.stderr index e97b8eca94892..5250848a65cc3 100644 --- a/src/test/ui/regions/issue-78262.default.stderr +++ b/src/test/ui/regions/issue-78262.default.stderr @@ -1,13 +1,13 @@ error[E0308]: mismatched types - --> $DIR/issue-78262.rs:12:28 + --> $DIR/issue-78262.rs:14:28 | LL | let f = |x: &dyn TT| x.func(); | ^^^^ lifetime mismatch | = note: expected reference `&(dyn TT + 'static)` found reference `&dyn TT` -note: the anonymous lifetime #1 defined on the body at 12:13... - --> $DIR/issue-78262.rs:12:13 +note: the anonymous lifetime #1 defined on the body at 14:13... + --> $DIR/issue-78262.rs:14:13 | LL | let f = |x: &dyn TT| x.func(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/issue-78262.nll.stderr b/src/test/ui/regions/issue-78262.nll.stderr index fafff35e4155f..a35d6fd9bf885 100644 --- a/src/test/ui/regions/issue-78262.nll.stderr +++ b/src/test/ui/regions/issue-78262.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/issue-78262.rs:12:26 + --> $DIR/issue-78262.rs:14:26 | LL | let f = |x: &dyn TT| x.func(); | - ^^^^^^^^ `x` escapes the closure body here diff --git a/src/test/ui/regions/issue-78262.polonius.stderr b/src/test/ui/regions/issue-78262.polonius.stderr new file mode 100644 index 0000000000000..a35d6fd9bf885 --- /dev/null +++ b/src/test/ui/regions/issue-78262.polonius.stderr @@ -0,0 +1,11 @@ +error[E0521]: borrowed data escapes outside of closure + --> $DIR/issue-78262.rs:14:26 + | +LL | let f = |x: &dyn TT| x.func(); + | - ^^^^^^^^ `x` escapes the closure body here + | | + | `x` is a reference that is only valid in the closure body + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/regions/issue-78262.rs b/src/test/ui/regions/issue-78262.rs index 0bdb0abac307d..b88ad678ee61c 100644 --- a/src/test/ui/regions/issue-78262.rs +++ b/src/test/ui/regions/issue-78262.rs @@ -1,6 +1,8 @@ -// revisions: nll default +// revisions: default nll polonius // ignore-compare-mode-nll -//[nll]compile-flags: -Z borrowck=mir +// ignore-compare-mode-polonius +// [nll] compile-flags: -Z borrowck=mir +// [polonius] compile-flags: -Z borrowck=mir -Z polonius trait TT {} @@ -11,4 +13,5 @@ impl dyn TT { fn main() { let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types //[nll]~^ ERROR: borrowed data escapes outside of closure + //[polonius]~^^ ERROR: borrowed data escapes outside of closure } diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr new file mode 100644 index 0000000000000..13741664ef227 --- /dev/null +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr @@ -0,0 +1,82 @@ +error: lifetime may not live long enough + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5 + | +LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; + | ^^^^^^^ assignment requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` + +error: lifetime may not live long enough + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:5 + | +LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | -- -- lifetime `'c` defined here + | | + | lifetime `'b` defined here +... +LL | *z = *y; + | ^^^^^^^ assignment requires that `'b` must outlive `'c` + | + = help: consider adding the following bound: `'b: 'c` + +help: add bound `'b: 'a + 'c` + +error: lifetime may not live long enough + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 + | +LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | a(x, y, z); + | ^^^^^^^^^^ argument requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` + = note: requirement occurs because of a mutable reference to &isize + = note: mutable references are invariant over their type parameter + = help: see for more information about variance + +error: lifetime may not live long enough + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 + | +LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | -- -- lifetime `'c` defined here + | | + | lifetime `'b` defined here +... +LL | a(x, y, z); + | ^^^^^^^^^^ argument requires that `'b` must outlive `'c` + | + = help: consider adding the following bound: `'b: 'c` + = note: requirement occurs because of a mutable reference to &isize + = note: mutable references are invariant over their type parameter + = help: see for more information about variance + +help: add bound `'b: 'a + 'c` + +error: higher-ranked subtype error + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + | +LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: higher-ranked subtype error + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + | +LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: higher-ranked subtype error + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + | +LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr new file mode 100644 index 0000000000000..e48ba709af1fd --- /dev/null +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.polonius.stderr @@ -0,0 +1,22 @@ +error: lifetime may not live long enough + --> $DIR/type-checking-test-3.rs:13:13 + | +LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'a>; // Error + | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-3.rs:18:13 + | +LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'static>; // Error + | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr new file mode 100644 index 0000000000000..a3411f40ad0fb --- /dev/null +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.polonius.stderr @@ -0,0 +1,33 @@ +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:17:13 + | +LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'static, 'a>; // Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:22:13 + | +LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { + | -- lifetime `'a` defined here +LL | let _ = x as &dyn Bar<'a, 'static>; // Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:29:5 + | +LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +... +LL | y.get_b() // ERROR + | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/type_length_limit.polonius.stderr b/src/test/ui/type_length_limit.polonius.stderr new file mode 100644 index 0000000000000..82d066b2a2fef --- /dev/null +++ b/src/test/ui/type_length_limit.polonius.stderr @@ -0,0 +1,11 @@ +error: reached the type-length limit while instantiating `std::mem::drop::>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | pub fn drop(_x: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit.polonius/type_length_limit.long-type.txt' + = help: consider adding a `#![type_length_limit="8"]` attribute to your crate + +error: aborting due to previous error +