Auto merge of #87738 - lqd:polonius-master, r=nikomatsakis

Update `polonius-engine` to 0.13.0

This PR updates the use of `polonius-engine` to the recently released 0.13.0:
- this version renamed a lot of relations to match the current terminology
- "illegal subset relationships errors" (AKA "subset errors" or "universal region errors" in rustc parlance) have been implemented in all variants, and therefore the `Hybrid` variant can be the rustc default once again
- some of the blessed expectations were updated: new tests have been added since the last time I updated the tests, diagnostics have changed, etc.

In particular:
- a few tests had trivial expectations changes such as basic diagnostics changes for the migrate-mode and full NLLs
- others were recursion and lengths limits which emits a file, and under the polonius compare-mode, the folder has a different name
- a few tests were ignored in the NLL compare-mode for reasons that obviously also apply to Polonius
- some diagnostics were unified so that older expectations no longer made sense: the NLL and Polonius outputs were identical.
- in a few cases Polonius gets a chance to emit more errors than NLLs

A few tests in the compare-mode still are super slow and trigger the 60s warning, or OOM rustc during fact generation, and I've detailed these [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Challenges.20for.20move.2Finit.2C.20liveness.2C.20and.20.60Location.3A.3AAll.60):
- `src/test/ui/numbers-arithmetic/saturating-float-casts.rs` -> OOM during rustc fact generation
- `src/test/ui/numbers-arithmetic/num-wrapping.rs`
- `src/test/ui/issues/issue-72933-match-stack-overflow.rs`
- `src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs`
- `src/test/ui/repr/repr-no-niche.rs`

In addition, 2 tests don't currently pass and I didn't want to bless them now: they deal with HRTBs and miss errors that NLLs emit. We're currently trying to see if we need chalk to deal with HRTB errors (as we thought we would have to) but during the recent sprint, we discovered that we may be able to detect some of these errors in a way that resembles subset errors:
- `ui/hrtb/hrtb-just-for-static.rs` -> 3 errors in NLL, 2 in polonius: a missing error about HRTB + needing to outlive 'static
- `ui/issues/issue-26217.rs` -> missing HRTB that makes the test compile instead of emitting an error

We'll keep talking about this at the next sprint as well.

cc `@rust-lang/wg-polonius` r? `@nikomatsakis`
This commit is contained in:
bors 2021-08-18 05:50:55 +00:00
commit 679dea4cc3
32 changed files with 346 additions and 78 deletions

View File

@ -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",

View File

@ -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" }

View File

@ -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" }

View File

@ -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));
}
}
}

View File

@ -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(())

View File

@ -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) {

View File

@ -217,14 +217,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));
}
}
}
@ -282,7 +283,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");

View File

@ -273,7 +273,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((
@ -2446,7 +2446,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
@ -2455,7 +2455,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),

View File

@ -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`.

View File

@ -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<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
@ -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<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 | | }
@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,26 @@
warning: function cannot return without recursing
--> $DIR/issue-8727.rs:7:1
|
LL | fn generic<T>() {
| ^^^^^^^^^^^^^^^ cannot return without recursing
LL | generic::<Option<T>>();
| ---------------------- 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::<Option<Option<Option<O...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $DIR/issue-8727.rs:8:5
|
LL | generic::<Option<T>>();
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: `generic` defined here
--> $DIR/issue-8727.rs:7:1
|
LL | fn generic<T>() {
| ^^^^^^^^^^^^^^^
= 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

View File

@ -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

View File

@ -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 {
| _____________-

View File

@ -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`

View File

@ -1,4 +1,5 @@
// ignore-compare-mode-nll
// ignore-compare-mode-polonius
// revisions: a
// should-fail

View File

@ -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`.

View File

@ -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`.

View File

@ -0,0 +1,15 @@
error: reached the recursion limit while instantiating `std::ptr::drop_in_place::<S<fn(f...)))))))))))))))))))))))))))))>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
LL | pub unsafe fn drop_in_place<T: ?Sized>(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<T: ?Sized>(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

View File

@ -0,0 +1,15 @@
error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
--> $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<T:Dot> (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

View File

@ -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();
| ^^^^^^^^^^^^^^^^^^^^^

View File

@ -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

View File

@ -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`.

View File

@ -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
}

View File

@ -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 <https://doc.rust-lang.org/nomicon/subtyping.html> 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 <https://doc.rust-lang.org/nomicon/subtyping.html> 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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,11 @@
error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((...,....., ...), ..., ...), ..., ...)>>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub fn drop<T>(_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