diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.stderr b/src/test/ui/associated-type-bounds/implied-region-constraints.base.stderr similarity index 90% rename from src/test/ui/associated-type-bounds/implied-region-constraints.stderr rename to src/test/ui/associated-type-bounds/implied-region-constraints.base.stderr index c338e38d28f71..b4437069cd745 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.stderr +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/implied-region-constraints.rs:17:64 + --> $DIR/implied-region-constraints.rs:21:64 | LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>) | ------------- this type is declared with multiple lifetimes... @@ -8,7 +8,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; | ^^^^^ ...but data with one lifetime flows into the other here error[E0623]: lifetime mismatch - --> $DIR/implied-region-constraints.rs:38:72 + --> $DIR/implied-region-constraints.rs:43:72 | LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>) | -------------- this type is declared with multiple lifetimes... diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr b/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr index cddce8777eab7..bf9fecf06a478 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/implied-region-constraints.rs:17:56 + --> $DIR/implied-region-constraints.rs:21:56 | LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>) | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/implied-region-constraints.rs:38:64 + --> $DIR/implied-region-constraints.rs:43:64 | LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>) | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.rs b/src/test/ui/associated-type-bounds/implied-region-constraints.rs index ccad947f7f074..a41c764343086 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.rs +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![feature(associated_type_bounds)] trait Tr1 { type As1; } @@ -15,7 +19,8 @@ where { // This should fail because `T: 'b` is not implied from `WF(St<'a, 'b, T>)`. let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } enum En7<'a, 'b, T> // `::As2: 'a` is implied. @@ -36,7 +41,8 @@ where En7::V0(x) => { // Also fails for the same reason as above: let _failure_proves_not_implied_outlives_region_b: &'b T = &x; - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough }, En7::V1(_) => {}, } diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.base.stderr similarity index 89% rename from src/test/ui/associated-types/associated-types-eq-hr.stderr rename to src/test/ui/associated-types/associated-types-eq-hr.base.stderr index 1329e1382fd4a..4313078064cc5 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.base.stderr @@ -1,18 +1,18 @@ error[E0271]: type mismatch resolving `for<'x> >::A == &'x isize` - --> $DIR/associated-types-eq-hr.rs:87:5 + --> $DIR/associated-types-eq-hr.rs:91:5 | LL | foo::(); | ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> >::A == &'x isize` | note: expected this to be `&isize` - --> $DIR/associated-types-eq-hr.rs:26:14 + --> $DIR/associated-types-eq-hr.rs:30:14 | LL | type A = &'a usize; | ^^^^^^^^^ = note: expected reference `&isize` found reference `&usize` note: required by a bound in `foo` - --> $DIR/associated-types-eq-hr.rs:45:36 + --> $DIR/associated-types-eq-hr.rs:49:36 | LL | fn foo() | --- required by a bound in this @@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>, | ^^^^^^^^^^^^^ required by this bound in `foo` error[E0271]: type mismatch resolving `for<'x> >::A == &'x usize` - --> $DIR/associated-types-eq-hr.rs:91:5 + --> $DIR/associated-types-eq-hr.rs:95:5 | LL | bar::(); | ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> >::A == &'x usize` | note: expected this to be `&usize` - --> $DIR/associated-types-eq-hr.rs:14:14 + --> $DIR/associated-types-eq-hr.rs:18:14 | LL | type A = &'a isize; | ^^^^^^^^^ = note: expected reference `&usize` found reference `&isize` note: required by a bound in `bar` - --> $DIR/associated-types-eq-hr.rs:52:36 + --> $DIR/associated-types-eq-hr.rs:56:36 | LL | fn bar() | --- required by a bound in this @@ -43,7 +43,7 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>, | ^^^^^^^^^^^^^ required by this bound in `bar` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:96:5 + --> $DIR/associated-types-eq-hr.rs:100:5 | LL | tuple_one::(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -52,7 +52,7 @@ LL | tuple_one::(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:96:5 + --> $DIR/associated-types-eq-hr.rs:100:5 | LL | tuple_one::(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -61,7 +61,7 @@ LL | tuple_one::(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:102:5 + --> $DIR/associated-types-eq-hr.rs:106:5 | LL | tuple_two::(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -70,7 +70,7 @@ LL | tuple_two::(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:102:5 + --> $DIR/associated-types-eq-hr.rs:106:5 | LL | tuple_two::(); | ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough @@ -79,7 +79,7 @@ LL | tuple_two::(); = note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `TheTrait` is not general enough - --> $DIR/associated-types-eq-hr.rs:112:5 + --> $DIR/associated-types-eq-hr.rs:116:5 | LL | tuple_four::(); | ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough diff --git a/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr b/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr index b306ae273e870..8d128821656f9 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr +++ b/src/test/ui/associated-types/associated-types-eq-hr.nll.stderr @@ -1,18 +1,18 @@ error[E0271]: type mismatch resolving `for<'x> >::A == &'x isize` - --> $DIR/associated-types-eq-hr.rs:87:5 + --> $DIR/associated-types-eq-hr.rs:91:5 | LL | foo::(); | ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> >::A == &'x isize` | note: expected this to be `&isize` - --> $DIR/associated-types-eq-hr.rs:26:14 + --> $DIR/associated-types-eq-hr.rs:30:14 | LL | type A = &'a usize; | ^^^^^^^^^ = note: expected reference `&isize` found reference `&usize` note: required by a bound in `foo` - --> $DIR/associated-types-eq-hr.rs:45:36 + --> $DIR/associated-types-eq-hr.rs:49:36 | LL | fn foo() | --- required by a bound in this @@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>, | ^^^^^^^^^^^^^ required by this bound in `foo` error[E0271]: type mismatch resolving `for<'x> >::A == &'x usize` - --> $DIR/associated-types-eq-hr.rs:91:5 + --> $DIR/associated-types-eq-hr.rs:95:5 | LL | bar::(); | ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> >::A == &'x usize` | note: expected this to be `&usize` - --> $DIR/associated-types-eq-hr.rs:14:14 + --> $DIR/associated-types-eq-hr.rs:18:14 | LL | type A = &'a isize; | ^^^^^^^^^ = note: expected reference `&usize` found reference `&isize` note: required by a bound in `bar` - --> $DIR/associated-types-eq-hr.rs:52:36 + --> $DIR/associated-types-eq-hr.rs:56:36 | LL | fn bar() | --- required by a bound in this diff --git a/src/test/ui/associated-types/associated-types-eq-hr.rs b/src/test/ui/associated-types/associated-types-eq-hr.rs index fb391913c321e..deb3fd059f801 100644 --- a/src/test/ui/associated-types/associated-types-eq-hr.rs +++ b/src/test/ui/associated-types/associated-types-eq-hr.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Check testing of equality constraints in a higher-ranked context. pub trait TheTrait { @@ -94,14 +98,14 @@ pub fn call_bar() { pub fn call_tuple_one() { tuple_one::(); - //~^ ERROR implementation of `TheTrait` is not general enough - //~| ERROR implementation of `TheTrait` is not general enough + //[base]~^ ERROR implementation of `TheTrait` is not general enough + //[base]~| ERROR implementation of `TheTrait` is not general enough } pub fn call_tuple_two() { tuple_two::(); - //~^ ERROR implementation of `TheTrait` is not general enough - //~| ERROR implementation of `TheTrait` is not general enough + //[base]~^ ERROR implementation of `TheTrait` is not general enough + //[base]~| ERROR implementation of `TheTrait` is not general enough } pub fn call_tuple_three() { @@ -110,7 +114,7 @@ pub fn call_tuple_three() { pub fn call_tuple_four() { tuple_four::(); - //~^ ERROR implementation of `TheTrait` is not general enough + //[base]~^ ERROR implementation of `TheTrait` is not general enough } fn main() {} diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.base.stderr similarity index 88% rename from src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr rename to src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.base.stderr index d5310c47fcf1e..fe238344263c3 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40 + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40 | LL | x: >::A, | --------- these two types are declared with different lifetimes... diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr index e12d42e5ed0cc..ae6ccb8af5521 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:29 + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:29 | LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let z: I::A = if cond { x } else { y }; = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40 + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40 | LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs index 9434a88e633c2..7ad12f2a1f361 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Check projection of an associated type out of a higher-ranked // trait-bound in the context of a function body. @@ -20,7 +24,9 @@ fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( { // x and y here have two distinct lifetimes: let z: I::A = if cond { x } else { y }; - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough } pub fn main() {} diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.stderr b/src/test/ui/associated-types/associated-types-subtyping-1.base.stderr similarity index 88% rename from src/test/ui/associated-types/associated-types-subtyping-1.stderr rename to src/test/ui/associated-types/associated-types-subtyping-1.base.stderr index 58ceec9040b9d..35b3a83ee4302 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.stderr +++ b/src/test/ui/associated-types/associated-types-subtyping-1.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/associated-types-subtyping-1.rs:26:38 + --> $DIR/associated-types-subtyping-1.rs:31:38 | LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T) | ----- ----- these two types are declared with different lifetimes... @@ -8,7 +8,7 @@ LL | let _c: >::Type = a; | ^ ...but data from `y` flows into `x` here error[E0623]: lifetime mismatch - --> $DIR/associated-types-subtyping-1.rs:35:38 + --> $DIR/associated-types-subtyping-1.rs:41:38 | LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T) | ----- ----- these two types are declared with different lifetimes... diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr b/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr index 11d3cfe5b4669..44f918e12ba15 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr +++ b/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/associated-types-subtyping-1.rs:24:12 + --> $DIR/associated-types-subtyping-1.rs:28:12 | LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T) | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let a: >::Type = make_any(); = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/associated-types-subtyping-1.rs:35:13 + --> $DIR/associated-types-subtyping-1.rs:41:13 | LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T) | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.rs b/src/test/ui/associated-types/associated-types-subtyping-1.rs index 012cffb7b97af..5b75e023b85ce 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.rs +++ b/src/test/ui/associated-types/associated-types-subtyping-1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(unused_variables)] fn make_any() -> T { loop {} } @@ -22,8 +26,10 @@ fn method2<'a,'b,T>(x: &'a T, y: &'b T) { // Note that &'static T <: &'a T. let a: >::Type = make_any(); + //[nll]~^ ERROR lifetime may not live long enough let b: >::Type = make_any(); - let _c: >::Type = a; //~ ERROR E0623 + let _c: >::Type = a; + //[base]~^ ERROR E0623 } fn method3<'a,'b,T>(x: &'a T, y: &'b T) @@ -32,7 +38,9 @@ fn method3<'a,'b,T>(x: &'a T, y: &'b T) // Note that &'static T <: &'a T. let a: >::Type = make_any(); let b: >::Type = make_any(); - let _c: >::Type = b; //~ ERROR E0623 + let _c: >::Type = b; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn method4<'a,'b,T>(x: &'a T, y: &'b T) diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr new file mode 100644 index 0000000000000..ed5518b628f6a --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr @@ -0,0 +1,25 @@ +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-contravariant-nll.rs:51:5 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ------- ------------------ + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) + | ^ ...but data from `y` is returned here + +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-contravariant-nll.rs:51:8 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ------- ------------------ + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) + | ^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs new file mode 100644 index 0000000000000..c3ac9949c214b --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs @@ -0,0 +1,55 @@ +#![feature(unboxed_closures)] + +// Test for projection cache. We should be able to project distinct +// lifetimes from `foo` as we reinstantiate it multiple times, but not +// if we do it just once. In this variant, the region `'a` is used in +// an contravariant position, which affects the results. + +// revisions: ok oneuse transmute krisskross +//[ok] check-pass +//[oneuse] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should replace `project-fn-ret-contravariant.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + +#![allow(dead_code, unused_variables)] + +fn foo<'a>() -> &'a u32 { loop { } } + +fn bar(t: T, x: T::Output) -> T::Output + where T: FnOnce<()> +{ + t() +} + +#[cfg(ok)] // two instantiations: OK +fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let a = bar(foo, x); + let b = bar(foo, y); + (a, b) +} + +#[cfg(oneuse)] // one instantiation: OK (surprisingly) +fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let f /* : fn() -> &'static u32 */ = foo; // <-- inferred type annotated + let a = bar(f, x); // this is considered ok because fn args are contravariant... + let b = bar(f, y); // ...and hence we infer T to distinct values in each call. + (a, b) +} + +#[cfg(transmute)] // one instantiations: BAD +fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + bar(foo, x) //[transmute]~ ERROR E0759 +} + +#[cfg(krisskross)] // two instantiations, mixing and matching: BAD +fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let a = bar(foo, y); + let b = bar(foo, x); + (a, b) //[krisskross]~ ERROR lifetime mismatch [E0623] + //[krisskross]~^ ERROR lifetime mismatch [E0623] +} + +fn main() { } diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr new file mode 100644 index 0000000000000..ca57142ecee09 --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr @@ -0,0 +1,11 @@ +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/project-fn-ret-contravariant-nll.rs:44:8 + | +LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + | ------- this data with lifetime `'a`... +LL | bar(foo, x) + | ^^^ - ...is used and required to live as long as `'static` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr deleted file mode 100644 index a5b6d64039147..0000000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:45:4 - | -LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | (a, b) - | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - | - = help: consider adding the following bound: `'a: 'b` - -error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:45:4 - | -LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | (a, b) - | ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | - = help: consider adding the following bound: `'b: 'a` - -help: `'a` and `'b` must be the same: replace one with the other - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr index fa4c6adb5fff7..52824b3922e69 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-contravariant.rs:45:5 + --> $DIR/project-fn-ret-contravariant.rs:52:5 | LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | ------- ------------------ @@ -10,7 +10,7 @@ LL | (a, b) | ^ ...but data from `y` is returned here error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-contravariant.rs:45:8 + --> $DIR/project-fn-ret-contravariant.rs:52:8 | LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | ------- ------------------ diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr deleted file mode 100644 index ed900079cfc22..0000000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.ok.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/project-fn-ret-contravariant.rs:50:1 - | -LL | fn main() { } - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr deleted file mode 100644 index ed900079cfc22..0000000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/project-fn-ret-contravariant.rs:50:1 - | -LL | fn main() { } - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs index 1eeb01ccc846e..7bd245d1c340a 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.rs @@ -1,5 +1,4 @@ #![feature(unboxed_closures)] -#![feature(rustc_attrs)] // Test for projection cache. We should be able to project distinct // lifetimes from `foo` as we reinstantiate it multiple times, but not @@ -7,6 +6,14 @@ // an contravariant position, which affects the results. // revisions: ok oneuse transmute krisskross +//[ok] check-pass +//[oneuse] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replaced with +// `project-fn-ret-contravariant-nll.rs` The two would normally be just +// revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. #![allow(dead_code, unused_variables)] @@ -46,5 +53,4 @@ fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { //[krisskross]~^ ERROR lifetime mismatch [E0623] } -#[rustc_error] -fn main() { } //[ok,oneuse]~ ERROR fatal error triggered by #[rustc_error] +fn main() { } diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr deleted file mode 100644 index f532c96ed2cc7..0000000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:38:4 - | -LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - | -- lifetime `'a` defined here -LL | bar(foo, x) - | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr index 33f1e0f05b252..3d7f36ca32ba9 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/project-fn-ret-contravariant.rs:38:8 + --> $DIR/project-fn-ret-contravariant.rs:45:8 | LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { | ------- this data with lifetime `'a`... diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.krisskross.stderr similarity index 94% rename from src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr rename to src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.krisskross.stderr index 55532d6b9b3fa..231e98cf841f2 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.krisskross.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:56:5 + --> $DIR/project-fn-ret-invariant-nll.rs:63:5 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | (a, b) = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:56:5 + --> $DIR/project-fn-ret-invariant-nll.rs:63:5 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.oneuse.stderr similarity index 93% rename from src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr rename to src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.oneuse.stderr index fd9eb05473af8..1dbfff6a8cdeb 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.oneuse.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:39:13 + --> $DIR/project-fn-ret-invariant-nll.rs:46:13 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | let a = bar(f, x); = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:40:13 + --> $DIR/project-fn-ret-invariant-nll.rs:47:13 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs new file mode 100644 index 0000000000000..6cd5c6417a914 --- /dev/null +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs @@ -0,0 +1,68 @@ +#![feature(unboxed_closures)] +// Test for projection cache. We should be able to project distinct +// lifetimes from `foo` as we reinstantiate it multiple times, but not +// if we do it just once. In this variant, the region `'a` is used in +// an invariant position, which affects the results. + +// revisions: ok oneuse transmute krisskross +//[ok] check-pass + +// compile-flags: -Z borrowck=mir +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should replace with `project-fn-ret-invariant.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + +#![allow(dead_code, unused_variables)] + +use std::marker::PhantomData; + +struct Type<'a> { + // Invariant + data: PhantomData &'a u32>, +} + +fn foo<'a>() -> Type<'a> { + loop {} +} + +fn bar(t: T, x: T::Output) -> T::Output +where + T: FnOnce<()>, +{ + t() +} + +#[cfg(ok)] // two instantiations: OK +fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let a = bar(foo, x); + let b = bar(foo, y); + (a, b) +} + +#[cfg(oneuse)] // one instantiation: BAD +fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let f = foo; // <-- No consistent type can be inferred for `f` here. + let a = bar(f, x); //[oneuse]~ ERROR lifetime may not live long enough + let b = bar(f, y); //[oneuse]~ ERROR lifetime may not live long enough + (a, b) +} + +#[cfg(transmute)] // one instantiations: BAD +fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { + // Cannot instantiate `foo` with any lifetime other than `'a`, + // since it is provided as input. + + bar(foo, x) //[transmute]~ ERROR lifetime may not live long enough +} + +#[cfg(krisskross)] // two instantiations, mixing and matching: BAD +fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let a = bar(foo, y); + let b = bar(foo, x); + (a, b) + //[krisskross]~^ ERROR lifetime may not live long enough + //[krisskross]~| ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.transmute.stderr similarity index 92% rename from src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr rename to src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.transmute.stderr index 5a7ead729498d..352914f020c2c 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.transmute.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:49:5 + --> $DIR/project-fn-ret-invariant-nll.rs:56:5 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | -- lifetime `'a` defined here diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr index 9462121bdf203..fd1152dd80cc1 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-invariant.rs:54:22 + --> $DIR/project-fn-ret-invariant.rs:60:22 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -------- -------------------- @@ -9,7 +9,7 @@ LL | let a = bar(foo, y); | ^ ...but data from `x` is returned here error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-invariant.rs:56:9 + --> $DIR/project-fn-ret-invariant.rs:62:9 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -------- -------------------- diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr deleted file mode 100644 index c340850094857..0000000000000 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.ok.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/project-fn-ret-invariant.rs:60:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr index 64b5722390858..1b10c6b990a6d 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/project-fn-ret-invariant.rs:40:20 + --> $DIR/project-fn-ret-invariant.rs:46:20 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -------- -------------------- diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs b/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs index 08d864f7836d2..d42d99d778376 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.rs @@ -1,11 +1,17 @@ #![feature(unboxed_closures)] -#![feature(rustc_attrs)] // Test for projection cache. We should be able to project distinct // lifetimes from `foo` as we reinstantiate it multiple times, but not // if we do it just once. In this variant, the region `'a` is used in // an invariant position, which affects the results. // revisions: ok oneuse transmute krisskross +//[ok] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replaced with `project-fn-ret-invariant-nll.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + #![allow(dead_code, unused_variables)] use std::marker::PhantomData; @@ -56,6 +62,4 @@ fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { (a, b) //[krisskross]~ ERROR E0623 } -#[rustc_error] fn main() {} -//[ok]~^ ERROR fatal error triggered by #[rustc_error] diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr index 609627aaa9ef0..8c1d9d1e28409 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/project-fn-ret-invariant.rs:49:9 + --> $DIR/project-fn-ret-invariant.rs:55:9 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | -------- this data with lifetime `'a`... @@ -8,7 +8,7 @@ LL | bar(foo, x) | ^^^ - ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/project-fn-ret-invariant.rs:45:37 + --> $DIR/project-fn-ret-invariant.rs:51:37 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/associated-types/higher-ranked-projection.badbase.stderr b/src/test/ui/associated-types/higher-ranked-projection.badbase.stderr new file mode 100644 index 0000000000000..732f5d9584bc8 --- /dev/null +++ b/src/test/ui/associated-types/higher-ranked-projection.badbase.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/higher-ranked-projection.rs:25:5 + | +LL | foo(()); + | ^^^ lifetime mismatch + | + = note: expected reference `&'a ()` + found reference `&()` +note: the lifetime requirement is introduced here + --> $DIR/higher-ranked-projection.rs:16:33 + | +LL | where for<'a> &'a T: Mirror + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/associated-types/higher-ranked-projection.badnll.stderr b/src/test/ui/associated-types/higher-ranked-projection.badnll.stderr new file mode 100644 index 0000000000000..8b2b87223a58a --- /dev/null +++ b/src/test/ui/associated-types/higher-ranked-projection.badnll.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/higher-ranked-projection.rs:25:5 + | +LL | foo(()); + | ^^^^^^^ one type is more general than the other + | + = note: expected reference `&'a ()` + found reference `&()` +note: the lifetime requirement is introduced here + --> $DIR/higher-ranked-projection.rs:16:33 + | +LL | where for<'a> &'a T: Mirror + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/associated-types/higher-ranked-projection.good.stderr b/src/test/ui/associated-types/higher-ranked-projection.good.stderr deleted file mode 100644 index 1dc41a2165fff..0000000000000 --- a/src/test/ui/associated-types/higher-ranked-projection.good.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/higher-ranked-projection.rs:24:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/associated-types/higher-ranked-projection.rs b/src/test/ui/associated-types/higher-ranked-projection.rs index 1b5476d4c364f..8b1046b6bbc9d 100644 --- a/src/test/ui/associated-types/higher-ranked-projection.rs +++ b/src/test/ui/associated-types/higher-ranked-projection.rs @@ -1,6 +1,7 @@ -#![feature(rustc_attrs)] - -// revisions: good bad +// ignore-compare-mode-nll +// revisions: good badbase badnll +//[good] check-pass +// [badnll]compile-flags: -Zborrowck=mir trait Mirror { type Image; @@ -10,7 +11,7 @@ impl Mirror for T { type Image = T; } -#[cfg(bad)] +#[cfg(any(badbase, badnll))] fn foo(_t: T) where for<'a> &'a T: Mirror {} @@ -20,8 +21,8 @@ fn foo(_t: T) where for<'a> &'a T: Mirror {} -#[rustc_error] -fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error] +fn main() { foo(()); - //[bad]~^ ERROR mismatched types + //[badbase]~^ ERROR mismatched types + //[badnll]~^^ ERROR mismatched types } diff --git a/src/test/ui/async-await/issue-76547.stderr b/src/test/ui/async-await/issue-76547.base.stderr similarity index 91% rename from src/test/ui/async-await/issue-76547.stderr rename to src/test/ui/async-await/issue-76547.base.stderr index ac5f99970c814..34705d4838e76 100644 --- a/src/test/ui/async-await/issue-76547.stderr +++ b/src/test/ui/async-await/issue-76547.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-76547.rs:20:13 + --> $DIR/issue-76547.rs:24:13 | LL | async fn fut(bufs: &mut [&mut [u8]]) { | ---------------- these two types are declared with different lifetimes... @@ -7,7 +7,7 @@ LL | ListFut(bufs).await | ^^^^ ...but data from `bufs` flows into `bufs` here error[E0623]: lifetime mismatch - --> $DIR/issue-76547.rs:34:14 + --> $DIR/issue-76547.rs:39:14 | LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | ---------------- these two types are declared with different lifetimes... diff --git a/src/test/ui/async-await/issue-76547.nll.stderr b/src/test/ui/async-await/issue-76547.nll.stderr index 0ac2a39666966..bc30da1e389b3 100644 --- a/src/test/ui/async-await/issue-76547.nll.stderr +++ b/src/test/ui/async-await/issue-76547.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-76547.rs:20:13 + --> $DIR/issue-76547.rs:24:13 | LL | async fn fut(bufs: &mut [&mut [u8]]) { | - - let's call the lifetime of this reference `'2` @@ -9,7 +9,7 @@ LL | ListFut(bufs).await | ^^^^ this usage requires that `'1` must outlive `'2` error: lifetime may not live long enough - --> $DIR/issue-76547.rs:34:14 + --> $DIR/issue-76547.rs:39:14 | LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | - - let's call the lifetime of this reference `'2` diff --git a/src/test/ui/async-await/issue-76547.rs b/src/test/ui/async-await/issue-76547.rs index 5b3ee5b95c4cb..45c7ab63135b1 100644 --- a/src/test/ui/async-await/issue-76547.rs +++ b/src/test/ui/async-await/issue-76547.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test for diagnostic improvement issue #76547 // edition:2018 @@ -18,7 +22,8 @@ impl<'a> Future for ListFut<'a> { async fn fut(bufs: &mut [&mut [u8]]) { ListFut(bufs).await - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } pub struct ListFut2<'a>(&'a mut [&'a mut [u8]]); @@ -32,7 +37,8 @@ impl<'a> Future for ListFut2<'a> { async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { ListFut2(bufs).await - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/async-await/issues/issue-62097.stderr b/src/test/ui/async-await/issues/issue-62097.base.stderr similarity index 89% rename from src/test/ui/async-await/issues/issue-62097.stderr rename to src/test/ui/async-await/issues/issue-62097.base.stderr index e23277543c66f..7577b95fa2e2f 100644 --- a/src/test/ui/async-await/issues/issue-62097.stderr +++ b/src/test/ui/async-await/issues/issue-62097.base.stderr @@ -1,13 +1,14 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-62097.rs:12:31 + --> $DIR/issue-62097.rs:16:31 | LL | pub async fn run_dummy_fn(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... +LL | LL | foo(|| self.bar()).await; | --- ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by this bound - --> $DIR/issue-62097.rs:4:19 + --> $DIR/issue-62097.rs:8:19 | LL | F: FnOnce() + 'static | ^^^^^^^ diff --git a/src/test/ui/async-await/issues/issue-62097.nll.stderr b/src/test/ui/async-await/issues/issue-62097.nll.stderr index 786f621326049..b2b7c46d34878 100644 --- a/src/test/ui/async-await/issues/issue-62097.nll.stderr +++ b/src/test/ui/async-await/issues/issue-62097.nll.stderr @@ -1,5 +1,5 @@ error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function - --> $DIR/issue-62097.rs:13:13 + --> $DIR/issue-62097.rs:18:13 | LL | foo(|| self.bar()).await; | ^^ ---- `self` is borrowed here @@ -7,7 +7,7 @@ LL | foo(|| self.bar()).await; | may outlive borrowed value `self` | note: function requires argument type to outlive `'static` - --> $DIR/issue-62097.rs:13:9 + --> $DIR/issue-62097.rs:18:9 | LL | foo(|| self.bar()).await; | ^^^^^^^^^^^^^^^^^^ @@ -17,13 +17,14 @@ LL | foo(move || self.bar()).await; | ++++ error[E0521]: borrowed data escapes outside of associated function - --> $DIR/issue-62097.rs:13:9 + --> $DIR/issue-62097.rs:18:9 | LL | pub async fn run_dummy_fn(&self) { | ----- | | | `self` is a reference that is only valid in the associated function body | let's call the lifetime of this reference `'1` +LL | LL | foo(|| self.bar()).await; | ^^^^^^^^^^^^^^^^^^ | | diff --git a/src/test/ui/async-await/issues/issue-62097.rs b/src/test/ui/async-await/issues/issue-62097.rs index 66ebbd83ffa9e..d2260cd68c1ad 100644 --- a/src/test/ui/async-await/issues/issue-62097.rs +++ b/src/test/ui/async-await/issues/issue-62097.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 async fn foo(fun: F) where @@ -9,8 +13,11 @@ where struct Struct; impl Struct { - pub async fn run_dummy_fn(&self) { //~ ERROR E0759 + pub async fn run_dummy_fn(&self) { + //[base]~^ ERROR E0759 foo(|| self.bar()).await; + //[nll]~^ ERROR closure may outlive the current function + //[nll]~| ERROR borrowed data escapes outside of associated function } pub fn bar(&self) {} diff --git a/src/test/ui/async-await/issues/issue-63388-1.stderr b/src/test/ui/async-await/issues/issue-63388-1.base.stderr similarity index 90% rename from src/test/ui/async-await/issues/issue-63388-1.stderr rename to src/test/ui/async-await/issues/issue-63388-1.base.stderr index 8f602a1492ad2..2ff85a27a4645 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.base.stderr @@ -1,11 +1,11 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-63388-1.rs:14:9 + --> $DIR/issue-63388-1.rs:19:9 | LL | &'a self, foo: &dyn Foo | -------- this parameter and the return type are declared with different lifetimes... LL | ) -> &dyn Foo | -------- -LL | { +... LL | foo | ^^^ ...but data from `foo` is returned here diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr index 464459d2d61ad..eee0cee278b9c 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-63388-1.rs:13:5 + --> $DIR/issue-63388-1.rs:17:5 | LL | async fn do_sth<'a>( | -- lifetime `'a` defined here @@ -7,7 +7,9 @@ LL | &'a self, foo: &dyn Foo | - let's call the lifetime of this reference `'1` LL | ) -> &dyn Foo LL | / { +LL | | LL | | foo +LL | | LL | | } | |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs index baecf49c798e2..c45d2a42177ce 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.rs +++ b/src/test/ui/async-await/issues/issue-63388-1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 struct Xyz { @@ -11,7 +15,9 @@ impl Xyz { &'a self, foo: &dyn Foo ) -> &dyn Foo { - foo //~ ERROR lifetime mismatch + //[nll]~^ ERROR lifetime may not live long enough + foo + //[base]~^ ERROR lifetime mismatch } } diff --git a/src/test/ui/async-await/issues/issue-72312.stderr b/src/test/ui/async-await/issues/issue-72312.base.stderr similarity index 88% rename from src/test/ui/async-await/issues/issue-72312.stderr rename to src/test/ui/async-await/issues/issue-72312.base.stderr index 798f755765cc1..a4bdc447f6504 100644 --- a/src/test/ui/async-await/issues/issue-72312.stderr +++ b/src/test/ui/async-await/issues/issue-72312.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-72312.rs:10:24 + --> $DIR/issue-72312.rs:14:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... @@ -8,12 +8,12 @@ LL | &self; | ----- ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/issue-72312.rs:13:9 + --> $DIR/issue-72312.rs:20:9 | LL | require_static(async move { | ^^^^^^^^^^^^^^ note: `'static` lifetime requirement introduced by this bound - --> $DIR/issue-72312.rs:2:22 + --> $DIR/issue-72312.rs:6:22 | LL | fn require_static(val: T) -> T { | ^^^^^^^ diff --git a/src/test/ui/async-await/issues/issue-72312.nll.stderr b/src/test/ui/async-await/issues/issue-72312.nll.stderr index 068d8c64d6898..53b2c931cceab 100644 --- a/src/test/ui/async-await/issues/issue-72312.nll.stderr +++ b/src/test/ui/async-await/issues/issue-72312.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of associated function - --> $DIR/issue-72312.rs:13:24 + --> $DIR/issue-72312.rs:20:24 | LL | pub async fn start(&self) { | ----- @@ -9,6 +9,10 @@ LL | pub async fn start(&self) { ... LL | require_static(async move { | ________________________^ +LL | | +LL | | +LL | | +LL | | LL | | &self; LL | | }); | | ^ diff --git a/src/test/ui/async-await/issues/issue-72312.rs b/src/test/ui/async-await/issues/issue-72312.rs index eb7d12e290cb6..c1eceefd64377 100644 --- a/src/test/ui/async-await/issues/issue-72312.rs +++ b/src/test/ui/async-await/issues/issue-72312.rs @@ -1,17 +1,28 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 fn require_static(val: T) -> T { - //~^ NOTE 'static` lifetime requirement introduced by this bound + //[base]~^ NOTE 'static` lifetime requirement introduced by this bound val } struct Problem; impl Problem { - pub async fn start(&self) { //~ ERROR E0759 - //~^ NOTE this data with an anonymous lifetime `'_` - //~| NOTE in this expansion of desugaring of `async` block or function - require_static(async move { //~ NOTE ...and is required to live as long as `'static` here - &self; //~ NOTE ...is used here... + pub async fn start(&self) { + //[base]~^ ERROR E0759 + //[base]~| NOTE this data with an anonymous lifetime `'_` + //[base]~| NOTE in this expansion of desugaring of `async` block or function + //[nll]~^^^^ NOTE let's call + //[nll]~| NOTE `self` is a reference + require_static(async move { + //[base]~^ NOTE ...and is required to live as long as `'static` here + //[nll]~^^ ERROR borrowed data escapes + //[nll]~| NOTE `self` escapes + //[nll]~| NOTE argument requires + &self; //[base]~ NOTE ...is used here... }); } } diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.base.stderr similarity index 94% rename from src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr rename to src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.base.stderr index 2eb3a07059f7b..907c1f6c4079f 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.base.stderr @@ -1,17 +1,18 @@ error[E0623]: lifetime mismatch - --> $DIR/ret-impl-trait-one.rs:10:85 + --> $DIR/ret-impl-trait-one.rs:14:85 | LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { | ______________________________________________________------_____-------------------_^ | | | | | this parameter and the return type are declared with different lifetimes... LL | | +LL | | LL | | (a, b) LL | | } | |_^ ...but data from `a` is returned here error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ret-impl-trait-one.rs:16:80 + --> $DIR/ret-impl-trait-one.rs:21:80 | LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { | ____________________________________--__________________________________________^ diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr index cdb141c0e3ea2..dbf7293a38903 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ret-impl-trait-one.rs:10:85 + --> $DIR/ret-impl-trait-one.rs:14:85 | LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { | ________________________________--__--_______________________________________________^ @@ -7,6 +7,7 @@ LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trai | | | lifetime `'b` defined here | | lifetime `'a` defined here LL | | +LL | | LL | | (a, b) LL | | } | |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` @@ -14,7 +15,7 @@ LL | | } = help: consider adding the following bound: `'a: 'b` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ret-impl-trait-one.rs:16:80 + --> $DIR/ret-impl-trait-one.rs:21:80 | LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { | ____________________________________--__________________________________________^ diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs index 4f32489014d53..f4c309b4c10da 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // edition:2018 // Test that a feature gate is needed to use `impl Trait` as the @@ -8,7 +12,8 @@ impl Trait<'_> for T { } // Fails to recognize that both 'a and 'b are mentioned and should thus be accepted async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough (a, b) } diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.base.stderr similarity index 89% rename from src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr rename to src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.base.stderr index 67b6f64eaa64f..3d6d00a0f958b 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5 + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:13:5 | LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { | ------------- ----- diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr index f28c42ce2d58f..7c4de57320e78 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5 + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:13:5 | LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs index a7c9200d35ad1..60101d06820cc 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. @@ -7,7 +11,8 @@ struct S<'a> { fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { S { pointer: &mut *p.pointer } - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr new file mode 100644 index 0000000000000..3518a663e59b5 --- /dev/null +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr @@ -0,0 +1,93 @@ +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:51:11 + | +LL | f(f(10)); + | - ^ second mutable borrow occurs here + | | + | first mutable borrow occurs here + | first borrow later used by call + +error[E0382]: use of moved value: `f` + --> $DIR/two-phase-nonrecv-autoref.rs:58:11 + | +LL | fn twice_ten_so i32>(f: Box) { + | - move occurs because `f` has type `Box`, which does not implement the `Copy` trait +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:63:11 + | +LL | f(f(10)); + | - ^ second mutable borrow occurs here + | | + | first mutable borrow occurs here + | first borrow later used by call + +error[E0382]: use of moved value: `f` + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 + | +LL | fn twice_ten_oo(f: Box i32>) { + | - move occurs because `f` has type `Box i32>`, which does not implement the `Copy` trait +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:108:27 + | +LL | double_access(&mut a, &a); + | ------------- ------ ^^ immutable borrow occurs here + | | | + | | mutable borrow occurs here + | mutable borrow later used by call + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 + | +LL | i[i[3]] = 4; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | mutable borrow later used here + | +help: try adding a local storing this... + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 + | +LL | i[i[3]] = 4; + | ^^^^ +help: ...and then using that local here + --> $DIR/two-phase-nonrecv-autoref.rs:133:5 + | +LL | i[i[3]] = 4; + | ^^^^^^^ + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 + | +LL | i[i[3]] = i[4]; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | mutable borrow later used here + | +help: try adding a local storing this... + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 + | +LL | i[i[3]] = i[4]; + | ^^^^ +help: ...and then using that local here + --> $DIR/two-phase-nonrecv-autoref.rs:139:5 + | +LL | i[i[3]] = i[4]; + | ^^^^^^^ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0382, E0499, E0502. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index 0f2daaf99d914..3518a663e59b5 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -8,7 +8,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:59:11 + --> $DIR/two-phase-nonrecv-autoref.rs:58:11 | LL | fn twice_ten_so i32>(f: Box) { | - move occurs because `f` has type `Box`, which does not implement the `Copy` trait @@ -18,7 +18,7 @@ LL | f(f(10)); | value moved here error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:65:11 + --> $DIR/two-phase-nonrecv-autoref.rs:63:11 | LL | f(f(10)); | - ^ second mutable borrow occurs here @@ -27,7 +27,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:73:11 + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 | LL | fn twice_ten_oo(f: Box i32>) { | - move occurs because `f` has type `Box i32>`, which does not implement the `Copy` trait @@ -37,7 +37,7 @@ LL | f(f(10)); | value moved here error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:112:27 + --> $DIR/two-phase-nonrecv-autoref.rs:108:27 | LL | double_access(&mut a, &a); | ------------- ------ ^^ immutable borrow occurs here @@ -46,7 +46,7 @@ LL | double_access(&mut a, &a); | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:138:7 + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 | LL | i[i[3]] = 4; | --^---- @@ -56,18 +56,18 @@ LL | i[i[3]] = 4; | mutable borrow later used here | help: try adding a local storing this... - --> $DIR/two-phase-nonrecv-autoref.rs:138:7 + --> $DIR/two-phase-nonrecv-autoref.rs:133:7 | LL | i[i[3]] = 4; | ^^^^ help: ...and then using that local here - --> $DIR/two-phase-nonrecv-autoref.rs:138:5 + --> $DIR/two-phase-nonrecv-autoref.rs:133:5 | LL | i[i[3]] = 4; | ^^^^^^^ error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:143:7 + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 | LL | i[i[3]] = i[4]; | --^---- @@ -77,12 +77,12 @@ LL | i[i[3]] = i[4]; | mutable borrow later used here | help: try adding a local storing this... - --> $DIR/two-phase-nonrecv-autoref.rs:143:7 + --> $DIR/two-phase-nonrecv-autoref.rs:139:7 | LL | i[i[3]] = i[4]; | ^^^^ help: ...and then using that local here - --> $DIR/two-phase-nonrecv-autoref.rs:143:5 + --> $DIR/two-phase-nonrecv-autoref.rs:139:5 | LL | i[i[3]] = i[4]; | ^^^^^^^ diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index 918c7a1be197a..b6cc099a6145f 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -1,4 +1,4 @@ -// revisions: nll +// revisions: base nll //[nll]compile-flags: -Z borrowck=mir //[g2p]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref @@ -49,30 +49,26 @@ fn overloaded_call_traits() { fn twice_ten_sm i32>(f: &mut F) { f(f(10)); - //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time + //~^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_si i32>(f: &mut F) { f(f(10)); } fn twice_ten_so i32>(f: Box) { f(f(10)); - //[nll]~^ ERROR use of moved value: `f` - //[g2p]~^^ ERROR use of moved value: `f` + //~^ ERROR use of moved value: `f` } fn twice_ten_om(f: &mut dyn FnMut(i32) -> i32) { f(f(10)); - //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time + //~^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_oi(f: &mut dyn Fn(i32) -> i32) { f(f(10)); } fn twice_ten_oo(f: Box i32>) { f(f(10)); - //[nll]~^ ERROR use of moved value: `f` - //[g2p]~^^ ERROR use of moved value: `f` + //~^ ERROR use of moved value: `f` } twice_ten_sm(&mut |x| x + 1); @@ -110,8 +106,7 @@ fn coerce_unsized() { // This is not okay. double_access(&mut a, &a); - //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + //~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // But this is okay. a.m(a.i(10)); @@ -136,12 +131,14 @@ impl IndexMut for I { fn coerce_index_op() { let mut i = I(10); i[i[3]] = 4; - //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + // Shoud be accepted with g2p i[3] = i[4]; i[i[3]] = i[4]; - //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + // Shoud be accepted with g2p } fn main() { diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.base.stderr similarity index 87% rename from src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr rename to src/test/ui/closure-expected-type/expect-fn-supply-fn.base.stderr index b25a7ab3dc6c7..c3efe16e251ba 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:16:52 + --> $DIR/expect-fn-supply-fn.rs:20:52 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); = note: expected fn pointer `fn(&u32)` found fn pointer `fn(&'x u32)` note: the anonymous lifetime #1 defined here... - --> $DIR/expect-fn-supply-fn.rs:16:48 + --> $DIR/expect-fn-supply-fn.rs:20:48 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^ note: ...does not necessarily outlive the lifetime `'x` as defined here - --> $DIR/expect-fn-supply-fn.rs:13:36 + --> $DIR/expect-fn-supply-fn.rs:17:36 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | ^^ error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:16:52 + --> $DIR/expect-fn-supply-fn.rs:20:52 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^ lifetime mismatch @@ -26,18 +26,18 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); = note: expected fn pointer `fn(&u32)` found fn pointer `fn(&'x u32)` note: the lifetime `'x` as defined here... - --> $DIR/expect-fn-supply-fn.rs:13:36 + --> $DIR/expect-fn-supply-fn.rs:17:36 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | ^^ note: ...does not necessarily outlive the anonymous lifetime #1 defined here - --> $DIR/expect-fn-supply-fn.rs:16:48 + --> $DIR/expect-fn-supply-fn.rs:20:48 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:32:52 + --> $DIR/expect-fn-supply-fn.rs:38:52 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); | ^^^^^^^^ one type is more general than the other @@ -46,7 +46,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); found fn pointer `for<'r> fn(&'r u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:39:53 + --> $DIR/expect-fn-supply-fn.rs:45:53 | LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^ one type is more general than the other @@ -55,7 +55,7 @@ LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); found fn pointer `fn(&'x u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:48:53 + --> $DIR/expect-fn-supply-fn.rs:54:53 | LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { | ^^^^^^^ one type is more general than the other diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr index 26f47eb684dfc..52e2898d2bb1a 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/expect-fn-supply-fn.rs:16:49 + --> $DIR/expect-fn-supply-fn.rs:20:49 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | -- lifetime `'x` defined here @@ -11,7 +11,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | requires that `'1` must outlive `'x` error: lifetime may not live long enough - --> $DIR/expect-fn-supply-fn.rs:16:49 + --> $DIR/expect-fn-supply-fn.rs:20:49 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | -- lifetime `'x` defined here @@ -20,7 +20,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^ requires that `'x` must outlive `'static` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:32:49 + --> $DIR/expect-fn-supply-fn.rs:38:49 | LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); | ^ one type is more general than the other @@ -29,7 +29,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); found fn pointer `fn(&u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:39:50 + --> $DIR/expect-fn-supply-fn.rs:45:50 | LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); | ^ one type is more general than the other @@ -38,7 +38,7 @@ LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); found fn pointer `for<'r> fn(&'r u32)` error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:48:50 + --> $DIR/expect-fn-supply-fn.rs:54:50 | LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { | ^ one type is more general than the other diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs b/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs index c81c40c18b45b..1715f56ff63ce 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn with_closure_expecting_fn_with_free_region(_: F) where F: for<'a> FnOnce(fn(&'a u32), &i32), @@ -14,8 +18,10 @@ fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { // Here, the type given for `'x` "obscures" a region from the // expected signature that is bound at closure level. with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); - //~^ ERROR mismatched types - //~| ERROR mismatched types + //[base]~^ ERROR mismatched types + //[base]~| ERROR mismatched types + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough } fn expect_free_supply_free_from_closure() { diff --git a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.base.stderr similarity index 77% rename from src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr rename to src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.base.stderr index af1f908a80852..93ed51fa7e114 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.base.stderr @@ -1,22 +1,24 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9 | LL | fn foo(x: &()) { | --- this data with an anonymous lifetime `'_`... LL | bar(|| { | _________^ LL | | +LL | | +LL | | LL | | let _ = x; LL | | }) | |_____^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5 | LL | bar(|| { | ^^^ note: `'static` lifetime requirement introduced by this bound - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:1:39 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:39 | LL | fn bar(blk: F) where F: FnOnce() + 'static { | ^^^^^^^ diff --git a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr index af3810e91aeb0..dc5188a86511a 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5 | LL | fn foo(x: &()) { | - - let's call the lifetime of this reference `'1` @@ -7,6 +7,8 @@ LL | fn foo(x: &()) { | `x` is a reference that is only valid in the function body LL | / bar(|| { LL | | +LL | | +LL | | LL | | let _ = x; LL | | }) | | ^ @@ -15,19 +17,21 @@ LL | | }) | argument requires that `'1` must outlive `'static` error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9 | LL | bar(|| { | ^^ may outlive borrowed value `x` -LL | +... LL | let _ = x; | - `x` is borrowed here | note: function requires argument type to outlive `'static` - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5 | LL | / bar(|| { LL | | +LL | | +LL | | LL | | let _ = x; LL | | }) | |______^ diff --git a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs index cbdc8b7deef38..6c49cd76b13f0 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.rs @@ -1,9 +1,15 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + fn bar(blk: F) where F: FnOnce() + 'static { } fn foo(x: &()) { bar(|| { - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR borrowed data escapes + //[nll]~| ERROR closure may outlive let _ = x; }) } diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.base.stderr similarity index 81% rename from src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr rename to src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.base.stderr index f584b0c8382d0..be81efd27c4eb 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/expect-region-supply-region-2.rs:14:33 + --> $DIR/expect-region-supply-region-2.rs:18:33 | LL | closure_expecting_bound(|x: &'x u32| { | ^^^^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | closure_expecting_bound(|x: &'x u32| { = note: expected reference `&u32` found reference `&'x u32` note: the anonymous lifetime #1 defined here... - --> $DIR/expect-region-supply-region-2.rs:14:29 + --> $DIR/expect-region-supply-region-2.rs:18:29 | LL | closure_expecting_bound(|x: &'x u32| { | _____________________________^ @@ -19,13 +19,13 @@ LL | | f = Some(x); LL | | }); | |_____^ note: ...does not necessarily outlive the lifetime `'x` as defined here - --> $DIR/expect-region-supply-region-2.rs:9:30 + --> $DIR/expect-region-supply-region-2.rs:13:30 | LL | fn expect_bound_supply_named<'x>() { | ^^ error[E0308]: mismatched types - --> $DIR/expect-region-supply-region-2.rs:14:33 + --> $DIR/expect-region-supply-region-2.rs:18:33 | LL | closure_expecting_bound(|x: &'x u32| { | ^^^^^^^ lifetime mismatch @@ -33,12 +33,12 @@ LL | closure_expecting_bound(|x: &'x u32| { = note: expected reference `&u32` found reference `&'x u32` note: the lifetime `'x` as defined here... - --> $DIR/expect-region-supply-region-2.rs:9:30 + --> $DIR/expect-region-supply-region-2.rs:13:30 | LL | fn expect_bound_supply_named<'x>() { | ^^ note: ...does not necessarily outlive the anonymous lifetime #1 defined here - --> $DIR/expect-region-supply-region-2.rs:14:29 + --> $DIR/expect-region-supply-region-2.rs:18:29 | LL | closure_expecting_bound(|x: &'x u32| { | _____________________________^ diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr index 9aab51c986cac..4a9a19422d7cd 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/expect-region-supply-region-2.rs:14:30 + --> $DIR/expect-region-supply-region-2.rs:18:30 | LL | fn expect_bound_supply_named<'x>() { | -- lifetime `'x` defined here @@ -10,7 +10,7 @@ LL | closure_expecting_bound(|x: &'x u32| { | requires that `'1` must outlive `'x` error: lifetime may not live long enough - --> $DIR/expect-region-supply-region-2.rs:14:30 + --> $DIR/expect-region-supply-region-2.rs:18:30 | LL | fn expect_bound_supply_named<'x>() { | -- lifetime `'x` defined here diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs index 7405b1a1e3a28..072ba57c10bf4 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(warnings)] fn closure_expecting_bound(_: F) @@ -12,8 +16,10 @@ fn expect_bound_supply_named<'x>() { // Here we give a type annotation that `x` should be free. We get // an error because of that. closure_expecting_bound(|x: &'x u32| { - //~^ ERROR mismatched types - //~| ERROR mismatched types + //[base]~^ ERROR mismatched types + //[base]~| ERROR mismatched types + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough // Borrowck doesn't get a chance to run, but if it did it should error // here. diff --git a/src/test/ui/const-generics/invariant.stderr b/src/test/ui/const-generics/invariant.base.stderr similarity index 94% rename from src/test/ui/const-generics/invariant.stderr rename to src/test/ui/const-generics/invariant.base.stderr index 318c885e6a6bb..255900e19bb4b 100644 --- a/src/test/ui/const-generics/invariant.stderr +++ b/src/test/ui/const-generics/invariant.base.stderr @@ -1,5 +1,5 @@ warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())` - --> $DIR/invariant.rs:14:1 + --> $DIR/invariant.rs:18:1 | LL | impl SadBee for for<'a> fn(&'a ()) { | ---------------------------------- first implementation here @@ -13,7 +13,7 @@ LL | impl SadBee for fn(&'static ()) { = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details error[E0308]: mismatched types - --> $DIR/invariant.rs:27:5 + --> $DIR/invariant.rs:31:5 | LL | v | ^ one type is more general than the other diff --git a/src/test/ui/const-generics/invariant.nll.stderr b/src/test/ui/const-generics/invariant.nll.stderr index ce0fad104713b..f684f7fddc8f5 100644 --- a/src/test/ui/const-generics/invariant.nll.stderr +++ b/src/test/ui/const-generics/invariant.nll.stderr @@ -1,5 +1,5 @@ warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())` - --> $DIR/invariant.rs:14:1 + --> $DIR/invariant.rs:18:1 | LL | impl SadBee for for<'a> fn(&'a ()) { | ---------------------------------- first implementation here @@ -13,7 +13,7 @@ LL | impl SadBee for fn(&'static ()) { = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details error[E0308]: mismatched types - --> $DIR/invariant.rs:27:5 + --> $DIR/invariant.rs:31:5 | LL | v | ^ one type is more general than the other diff --git a/src/test/ui/const-generics/invariant.rs b/src/test/ui/const-generics/invariant.rs index ee191b65c2c76..65d1ee9420c3d 100644 --- a/src/test/ui/const-generics/invariant.rs +++ b/src/test/ui/const-generics/invariant.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generic_const_exprs)] #![allow(incomplete_features)] use std::marker::PhantomData; diff --git a/src/test/ui/error-codes/E0490.stderr b/src/test/ui/error-codes/E0490.base.stderr similarity index 85% rename from src/test/ui/error-codes/E0490.stderr rename to src/test/ui/error-codes/E0490.base.stderr index 96e99bd88a497..5cb62e19ccf48 100644 --- a/src/test/ui/error-codes/E0490.stderr +++ b/src/test/ui/error-codes/E0490.base.stderr @@ -1,72 +1,72 @@ error[E0490]: a value of type `&'b ()` is borrowed for too long - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ | note: the type is valid for the lifetime `'a` as defined here - --> $DIR/E0490.rs:1:6 + --> $DIR/E0490.rs:5:6 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: but the borrow lasts for the lifetime `'b` as defined here - --> $DIR/E0490.rs:1:10 + --> $DIR/E0490.rs:5:10 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ | note: first, the lifetime cannot outlive the lifetime `'b` as defined here... - --> $DIR/E0490.rs:1:10 + --> $DIR/E0490.rs:5:10 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that the type `&'b ()` is not borrowed for too long - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/E0490.rs:1:6 + --> $DIR/E0490.rs:5:6 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ | note: first, the lifetime cannot outlive the lifetime `'b` as defined here... - --> $DIR/E0490.rs:1:10 + --> $DIR/E0490.rs:5:10 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that the expression is assignable - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | let x: &'a _ = &y; | ^^ = note: expected `&'a &()` found `&'a &'b ()` note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/E0490.rs:1:6 + --> $DIR/E0490.rs:5:6 | LL | fn f<'a, 'b>(y: &'b ()) { | ^^ note: ...so that the reference type `&'a &()` does not outlive the data it points at - --> $DIR/E0490.rs:2:12 + --> $DIR/E0490.rs:6:12 | LL | let x: &'a _ = &y; | ^^^^^ diff --git a/src/test/ui/error-codes/E0490.nll.stderr b/src/test/ui/error-codes/E0490.nll.stderr index a1c33bbcd5f75..80bf076e2bd6b 100644 --- a/src/test/ui/error-codes/E0490.nll.stderr +++ b/src/test/ui/error-codes/E0490.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/E0490.rs:2:12 + --> $DIR/E0490.rs:6:12 | LL | fn f<'a, 'b>(y: &'b ()) { | -- -- lifetime `'b` defined here @@ -11,7 +11,7 @@ LL | let x: &'a _ = &y; = help: consider adding the following bound: `'b: 'a` error[E0597]: `y` does not live long enough - --> $DIR/E0490.rs:2:20 + --> $DIR/E0490.rs:6:20 | LL | fn f<'a, 'b>(y: &'b ()) { | -- lifetime `'a` defined here diff --git a/src/test/ui/error-codes/E0490.rs b/src/test/ui/error-codes/E0490.rs index 36bafa2bd868c..304548215dc25 100644 --- a/src/test/ui/error-codes/E0490.rs +++ b/src/test/ui/error-codes/E0490.rs @@ -1,8 +1,14 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn f<'a, 'b>(y: &'b ()) { let x: &'a _ = &y; - //~^ E0490 - //~| E0495 - //~| E0495 + //[base]~^ E0490 + //[base]~| E0495 + //[base]~| E0495 + //[nll]~^^^^ lifetime may not live long enough + //[nll]~| E0597 } fn main() {} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.base.stderr similarity index 88% rename from src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr rename to src/test/ui/fn/implied-bounds-unnorm-associated-type.base.stderr index 93ab5dceee947..6f0ea1af0579b 100644 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/implied-bounds-unnorm-associated-type.rs:14:5 + --> $DIR/implied-bounds-unnorm-associated-type.rs:18:5 | LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { | ------- ---------- diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr index 8096f08385c8c..a7a91f3e685fa 100644 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/implied-bounds-unnorm-associated-type.rs:14:5 + --> $DIR/implied-bounds-unnorm-associated-type.rs:18:5 | LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs index 2e5ac7d7398eb..30bd042009b6e 100644 --- a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // check-fail // See issue #91068. Types in the substs of an associated type can't be implied // to be WF, since they don't actually have to be constructed. @@ -11,7 +15,9 @@ impl Trait for T { } fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { - s //~ ERROR lifetime mismatch [E0623] + s + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/generator/auto-trait-regions.stderr b/src/test/ui/generator/auto-trait-regions.base.stderr similarity index 90% rename from src/test/ui/generator/auto-trait-regions.stderr rename to src/test/ui/generator/auto-trait-regions.base.stderr index da3d3249f0e7e..d44c8eb1b8233 100644 --- a/src/test/ui/generator/auto-trait-regions.stderr +++ b/src/test/ui/generator/auto-trait-regions.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:35:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:35:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough @@ -17,7 +17,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:50:5 + --> $DIR/auto-trait-regions.rs:56:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough @@ -26,7 +26,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:50:5 + --> $DIR/auto-trait-regions.rs:56:5 | LL | assert_foo(gen); | ^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/generator/auto-trait-regions.nll.stderr b/src/test/ui/generator/auto-trait-regions.nll.stderr index 76970fb787214..25456881fa0ef 100644 --- a/src/test/ui/generator/auto-trait-regions.nll.stderr +++ b/src/test/ui/generator/auto-trait-regions.nll.stderr @@ -1,31 +1,31 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:46:24 + --> $DIR/auto-trait-regions.rs:50:24 | LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement | | | creates a temporary which is freed while still in use -LL | yield; +... LL | assert_foo(a); | - borrow later used here | = note: consider using a `let` binding to create a longer lived value error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:46:35 + --> $DIR/auto-trait-regions.rs:50:35 | LL | let a = A(&mut true, &mut true, No); | ^^^^ - temporary value is freed at the end of this statement | | | creates a temporary which is freed while still in use -LL | yield; +... LL | assert_foo(a); | - borrow later used here | = note: consider using a `let` binding to create a longer lived value error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 + --> $DIR/auto-trait-regions.rs:35:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -34,7 +34,7 @@ LL | assert_foo(gen); = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:50:5 + --> $DIR/auto-trait-regions.rs:56:5 | LL | assert_foo(gen); | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/generator/auto-trait-regions.rs b/src/test/ui/generator/auto-trait-regions.rs index 8f1e4f1b66f48..98af4a3939163 100644 --- a/src/test/ui/generator/auto-trait-regions.rs +++ b/src/test/ui/generator/auto-trait-regions.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generators)] #![feature(auto_traits)] #![feature(negative_impls)] @@ -30,7 +34,7 @@ fn main() { }; assert_foo(gen); //~^ ERROR implementation of `Foo` is not general enough - //~| ERROR implementation of `Foo` is not general enough + //[base]~^^ ERROR implementation of `Foo` is not general enough // Allow impls which matches any lifetime let x = &OnlyFooIfRef(No); @@ -44,10 +48,12 @@ fn main() { // Disallow impls which relates lifetimes in the generator interior let gen = || { let a = A(&mut true, &mut true, No); + //[nll]~^ temporary value dropped while borrowed + //[nll]~| temporary value dropped while borrowed yield; assert_foo(a); }; assert_foo(gen); //~^ ERROR not general enough - //~| ERROR not general enough + //[base]~^^ ERROR not general enough } diff --git a/src/test/ui/generator/generator-region-requirements.stderr b/src/test/ui/generator/generator-region-requirements.base.stderr similarity index 92% rename from src/test/ui/generator/generator-region-requirements.stderr rename to src/test/ui/generator/generator-region-requirements.base.stderr index 30d67050b904c..89f6a81ad3b04 100644 --- a/src/test/ui/generator/generator-region-requirements.stderr +++ b/src/test/ui/generator/generator-region-requirements.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/generator-region-requirements.rs:8:9 + --> $DIR/generator-region-requirements.rs:12:9 | LL | fn dangle(x: &mut i32) -> &'static mut i32 { | -------- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/generator/generator-region-requirements.nll.stderr b/src/test/ui/generator/generator-region-requirements.nll.stderr index b4530cfda2b54..9f54c6c9dc12d 100644 --- a/src/test/ui/generator/generator-region-requirements.nll.stderr +++ b/src/test/ui/generator/generator-region-requirements.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/generator-region-requirements.rs:13:51 + --> $DIR/generator-region-requirements.rs:17:51 | LL | fn dangle(x: &mut i32) -> &'static mut i32 { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/generator/generator-region-requirements.rs b/src/test/ui/generator/generator-region-requirements.rs index cec68509a66e6..ec718b174607e 100644 --- a/src/test/ui/generator/generator-region-requirements.rs +++ b/src/test/ui/generator/generator-region-requirements.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generators, generator_trait)] use std::ops::{Generator, GeneratorState}; use std::pin::Pin; @@ -6,11 +10,12 @@ fn dangle(x: &mut i32) -> &'static mut i32 { let mut g = || { yield; x - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] }; loop { match Pin::new(&mut g).resume(()) { GeneratorState::Complete(c) => return c, + //[nll]~^ ERROR lifetime may not live long enough GeneratorState::Yielded(_) => (), } } diff --git a/src/test/ui/generator/resume-arg-late-bound.stderr b/src/test/ui/generator/resume-arg-late-bound.base.stderr similarity index 84% rename from src/test/ui/generator/resume-arg-late-bound.stderr rename to src/test/ui/generator/resume-arg-late-bound.base.stderr index 5e60e33584e10..8521951d0c999 100644 --- a/src/test/ui/generator/resume-arg-late-bound.stderr +++ b/src/test/ui/generator/resume-arg-late-bound.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 + --> $DIR/resume-arg-late-bound.rs:19:5 | LL | test(gen); | ^^^^ lifetime mismatch @@ -7,7 +7,7 @@ LL | test(gen); = note: expected type `for<'a> Generator<&'a mut bool>` found type `Generator<&mut bool>` note: the required lifetime does not necessarily outlive the anonymous lifetime #1 defined here - --> $DIR/resume-arg-late-bound.rs:11:15 + --> $DIR/resume-arg-late-bound.rs:15:15 | LL | let gen = |arg: &mut bool| { | _______________^ @@ -16,13 +16,13 @@ LL | | *arg = true; LL | | }; | |_____^ note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 + --> $DIR/resume-arg-late-bound.rs:12:17 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 + --> $DIR/resume-arg-late-bound.rs:19:5 | LL | test(gen); | ^^^^ lifetime mismatch @@ -30,7 +30,7 @@ LL | test(gen); = note: expected type `for<'a> Generator<&'a mut bool>` found type `Generator<&mut bool>` note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements - --> $DIR/resume-arg-late-bound.rs:11:15 + --> $DIR/resume-arg-late-bound.rs:15:15 | LL | let gen = |arg: &mut bool| { | _______________^ @@ -39,7 +39,7 @@ LL | | *arg = true; LL | | }; | |_____^ note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 + --> $DIR/resume-arg-late-bound.rs:12:17 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/generator/resume-arg-late-bound.nll.stderr b/src/test/ui/generator/resume-arg-late-bound.nll.stderr index b5144c607a880..868d1352f2502 100644 --- a/src/test/ui/generator/resume-arg-late-bound.nll.stderr +++ b/src/test/ui/generator/resume-arg-late-bound.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 + --> $DIR/resume-arg-late-bound.rs:19:5 | LL | test(gen); | ^^^^^^^^^ one type is more general than the other @@ -7,7 +7,7 @@ LL | test(gen); = note: expected type `for<'a> Generator<&'a mut bool>` found type `Generator<&mut bool>` note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 + --> $DIR/resume-arg-late-bound.rs:12:17 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/generator/resume-arg-late-bound.rs b/src/test/ui/generator/resume-arg-late-bound.rs index a8f657eaabe47..b973d8a300a5e 100644 --- a/src/test/ui/generator/resume-arg-late-bound.rs +++ b/src/test/ui/generator/resume-arg-late-bound.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + //! Tests that we cannot produce a generator that accepts a resume argument //! with any lifetime and then stores it across a `yield`. @@ -14,5 +18,5 @@ fn main() { }; test(gen); //~^ ERROR mismatched types - //~| ERROR mismatched types + //[base]~^^ ERROR mismatched types } diff --git a/src/test/ui/generic-associated-types/extended/lending_iterator.base.nll.stderr b/src/test/ui/generic-associated-types/extended/lending_iterator.base.nll.stderr deleted file mode 100644 index 3da7794b3d2c0..0000000000000 --- a/src/test/ui/generic-associated-types/extended/lending_iterator.base.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0276]: impl has stricter requirements than trait - --> $DIR/lending_iterator.rs:14:45 - | -LL | fn from_iter LendingIterator = A>>(iter: T) -> Self; - | ------------------------------------------------------------------------ definition of `from_iter` from trait -... -LL | fn from_iter LendingIterator = A>>(mut iter: I) -> Self { - | ^^^^^^^^^^^^ impl has extra requirement `I: 'x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0276`. diff --git a/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr b/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr index c5588b0912ba8..aa1e50014fe4e 100644 --- a/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr +++ b/src/test/ui/generic-associated-types/extended/lending_iterator.base.stderr @@ -1,5 +1,5 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/lending_iterator.rs:14:45 + --> $DIR/lending_iterator.rs:16:45 | LL | fn from_iter LendingIterator = A>>(iter: T) -> Self; | ------------------------------------------------------------------------ definition of `from_iter` from trait @@ -8,7 +8,7 @@ LL | fn from_iter LendingIterator = A>>(mut iter: I) -> | ^^^^^^^^^^^^ impl has extra requirement `I: 'x` error[E0311]: the parameter type `Self` may not live long enough - --> $DIR/lending_iterator.rs:35:9 + --> $DIR/lending_iterator.rs:37:9 | LL | >::from_iter(self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | >::from_iter(self) = help: consider adding an explicit lifetime bound `Self: 'a`... = note: ...so that the type `Self` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/lending_iterator.rs:10:45 + --> $DIR/lending_iterator.rs:12:45 | LL | fn from_iter LendingIterator = A>>(iter: T) -> Self; | ^^^^^^^^^^^^ diff --git a/src/test/ui/generic-associated-types/extended/lending_iterator.rs b/src/test/ui/generic-associated-types/extended/lending_iterator.rs index df11ab2124986..6048e6e87c0ec 100644 --- a/src/test/ui/generic-associated-types/extended/lending_iterator.rs +++ b/src/test/ui/generic-associated-types/extended/lending_iterator.rs @@ -1,3 +1,5 @@ +// FIXME(nll): this is experimental anyways, don't really care about the output +// ignore-compare-mode-nll // revisions: base extended //[base] check-fail //[extended] check-pass diff --git a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.base.stderr similarity index 92% rename from src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr rename to src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.base.stderr index 32c5ccf164874..341e2e05d1cd9 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/projection-type-lifetime-mismatch.rs:17:7 + --> $DIR/projection-type-lifetime-mismatch.rs:21:7 | LL | fn f(x: &impl for<'a> X = &'a ()>) -> &'static () { | ------------------------------- this data with an anonymous lifetime `'_`... @@ -9,7 +9,7 @@ LL | x.m() | ...is used and required to live as long as `'static` here error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/projection-type-lifetime-mismatch.rs:22:7 + --> $DIR/projection-type-lifetime-mismatch.rs:27:7 | LL | fn g X = &'a ()>>(x: &T) -> &'static () { | -- this data with an anonymous lifetime `'_`... @@ -19,7 +19,7 @@ LL | x.m() | ...is used and required to live as long as `'static` here error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/projection-type-lifetime-mismatch.rs:27:7 + --> $DIR/projection-type-lifetime-mismatch.rs:33:7 | LL | fn h(x: &()) -> &'static () { | --- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr index 4620aa34e84d9..00395af4889dd 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/projection-type-lifetime-mismatch.rs:17:5 + --> $DIR/projection-type-lifetime-mismatch.rs:21:5 | LL | fn f(x: &impl for<'a> X = &'a ()>) -> &'static () { | - let's call the lifetime of this reference `'1` @@ -7,7 +7,7 @@ LL | x.m() | ^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/projection-type-lifetime-mismatch.rs:22:5 + --> $DIR/projection-type-lifetime-mismatch.rs:27:5 | LL | fn g X = &'a ()>>(x: &T) -> &'static () { | - let's call the lifetime of this reference `'1` @@ -15,7 +15,7 @@ LL | x.m() | ^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/projection-type-lifetime-mismatch.rs:27:5 + --> $DIR/projection-type-lifetime-mismatch.rs:33:5 | LL | fn h(x: &()) -> &'static () { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs index 9b04fe233208e..9f14c6f3dc03e 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![feature(generic_associated_types)] pub trait X { @@ -15,17 +19,20 @@ impl X for () { fn f(x: &impl for<'a> X = &'a ()>) -> &'static () { x.m() - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn g X = &'a ()>>(x: &T) -> &'static () { x.m() - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn h(x: &()) -> &'static () { x.m() - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/generic-associated-types/trait-objects.base.stderr b/src/test/ui/generic-associated-types/trait-objects.base.stderr index 1df76a21bf9b4..eed12f56be23a 100644 --- a/src/test/ui/generic-associated-types/trait-objects.base.stderr +++ b/src/test/ui/generic-associated-types/trait-objects.base.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object - --> $DIR/trait-objects.rs:14:21 + --> $DIR/trait-objects.rs:16:21 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/trait-objects.rs:8:10 + --> $DIR/trait-objects.rs:10:10 | LL | trait StreamingIterator { | ----------------- this trait cannot be made into an object... diff --git a/src/test/ui/generic-associated-types/trait-objects.extended.nll.stderr b/src/test/ui/generic-associated-types/trait-objects.extended.nll.stderr deleted file mode 100644 index 52d48d57859f4..0000000000000 --- a/src/test/ui/generic-associated-types/trait-objects.extended.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0521]: borrowed data escapes outside of function - --> $DIR/trait-objects.rs:16:5 - | -LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { - | - - let's call the lifetime of this reference `'1` - | | - | `x` is a reference that is only valid in the function body -LL | -LL | x.size_hint().0 - | ^^^^^^^^^^^^^ - | | - | `x` escapes the function body here - | argument requires that `'1` must outlive `'static` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generic-associated-types/trait-objects.extended.stderr b/src/test/ui/generic-associated-types/trait-objects.extended.stderr index 7cc3dad992110..c7b072256addc 100644 --- a/src/test/ui/generic-associated-types/trait-objects.extended.stderr +++ b/src/test/ui/generic-associated-types/trait-objects.extended.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/trait-objects.rs:16:7 + --> $DIR/trait-objects.rs:18:7 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { | ------------------------------------------------------ help: add explicit lifetime `'a` to the type of `x`: `&'a mut (dyn StreamingIterator Item = &'a i32> + 'a)` diff --git a/src/test/ui/generic-associated-types/trait-objects.rs b/src/test/ui/generic-associated-types/trait-objects.rs index 644e56ce21f10..d742d2051becc 100644 --- a/src/test/ui/generic-associated-types/trait-objects.rs +++ b/src/test/ui/generic-associated-types/trait-objects.rs @@ -1,3 +1,5 @@ +// FIXME(nll): this is experimental anyways, don't really care about the output +// ignore-compare-mode-nll // revisions: base extended #![feature(generic_associated_types)] diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr b/src/test/ui/higher-rank-trait-bounds/issue-59311.base.stderr similarity index 85% rename from src/test/ui/higher-rank-trait-bounds/issue-59311.stderr rename to src/test/ui/higher-rank-trait-bounds/issue-59311.base.stderr index 3dd05bba5c0a1..ec576ee529a4d 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'a V` does not fulfill the required lifetime - --> $DIR/issue-59311.rs:17:5 + --> $DIR/issue-59311.rs:21:5 | LL | v.t(|| {}); | ^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/issue-59311.rs:15:24 + --> $DIR/issue-59311.rs:19:24 | LL | for<'a> &'a V: T + 'static, | ^^^^^^^ diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr b/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr index 15e83ab5a347d..7f98cefdf019f 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.nll.stderr @@ -1,13 +1,13 @@ error: higher-ranked lifetime error - --> $DIR/issue-59311.rs:17:5 + --> $DIR/issue-59311.rs:21:5 | LL | v.t(|| {}); | ^^^^^^^^^^ | - = note: could not prove [closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed + = note: could not prove [closure@$DIR/issue-59311.rs:21:9: 21:14] well-formed error: higher-ranked lifetime error - --> $DIR/issue-59311.rs:17:9 + --> $DIR/issue-59311.rs:21:9 | LL | v.t(|| {}); | ^^^^^ diff --git a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs index 6970857728560..a63c5754f8f11 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-59311.rs +++ b/src/test/ui/higher-rank-trait-bounds/issue-59311.rs @@ -6,6 +6,10 @@ // an error, but the regression test is here to ensure // that it does not ICE. See discussion on #74889 for details. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait T { fn t(&self, _: F) {} } @@ -14,7 +18,10 @@ pub fn crash(v: &V) where for<'a> &'a V: T + 'static, { - v.t(|| {}); //~ ERROR: `&'a V` does not fulfill the required lifetime + v.t(|| {}); + //[base]~^ ERROR: `&'a V` does not fulfill the required lifetime + //[nll]~^^ ERROR: higher-ranked lifetime error + //[nll]~| ERROR: higher-ranked lifetime error } fn main() {} diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.base.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.base.stderr new file mode 100644 index 0000000000000..c24afdd418bf9 --- /dev/null +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.base.stderr @@ -0,0 +1,20 @@ +error: implementation of `Parser` is not general enough + --> $DIR/issue-71955.rs:49:5 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^ implementation of `Parser` is not general enough + | + = note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... + = note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` + +error: implementation of `Parser` is not general enough + --> $DIR/issue-71955.rs:53:5 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^ implementation of `Parser` is not general enough + | + = note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... + = note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr index 0f38f8e3283a2..9d3cd4dee531d 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:54:5 + --> $DIR/issue-71955.rs:49:5 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -7,18 +7,18 @@ LL | foo(bar, "string", |s| s.len() == 5); = note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>` found type `for<'r> FnOnce<(&'r &str,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:54:24 + --> $DIR/issue-71955.rs:49:24 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:9 + --> $DIR/issue-71955.rs:29:9 | LL | F2: FnOnce(&::Output) -> bool | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:54:5 + --> $DIR/issue-71955.rs:49:5 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -26,18 +26,18 @@ LL | foo(bar, "string", |s| s.len() == 5); = note: expected type `FnOnce<(&&str,)>` found type `for<'r> FnOnce<(&'r &str,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:54:24 + --> $DIR/issue-71955.rs:49:24 | LL | foo(bar, "string", |s| s.len() == 5); | ^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:44 + --> $DIR/issue-71955.rs:29:44 | LL | F2: FnOnce(&::Output) -> bool | ^^^^ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:58:5 + --> $DIR/issue-71955.rs:53:5 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -45,18 +45,18 @@ LL | foo(baz, "string", |s| s.0.len() == 5); = note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>` found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:58:24 + --> $DIR/issue-71955.rs:53:24 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:9 + --> $DIR/issue-71955.rs:29:9 | LL | F2: FnOnce(&::Output) -> bool | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-71955.rs:58:5 + --> $DIR/issue-71955.rs:53:5 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -64,12 +64,12 @@ LL | foo(baz, "string", |s| s.0.len() == 5); = note: expected type `FnOnce<(&Wrapper<'_>,)>` found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:58:24 + --> $DIR/issue-71955.rs:53:24 | LL | foo(baz, "string", |s| s.0.len() == 5); | ^^^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:44 + --> $DIR/issue-71955.rs:29:44 | LL | F2: FnOnce(&::Output) -> bool | ^^^^ diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs index 4b7e207b96d49..8d283afd09d64 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs @@ -1,13 +1,8 @@ // ignore-compare-mode-nll -// revisions: migrate nll +// revisions: base nll // [nll]compile-flags: -Zborrowck=mir -// check-fail - -// Since we are testing nll (and migration) explicitly as a separate -// revisions, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll +// check-fail #![feature(rustc_attrs)] trait Parser<'s> { @@ -52,11 +47,11 @@ fn main() { } foo(bar, "string", |s| s.len() == 5); - //[migrate]~^ ERROR implementation of `Parser` is not general enough + //[base]~^ ERROR implementation of `Parser` is not general enough //[nll]~^^ ERROR mismatched types //[nll]~| ERROR mismatched types foo(baz, "string", |s| s.0.len() == 5); - //[migrate]~^ ERROR implementation of `Parser` is not general enough + //[base]~^ ERROR implementation of `Parser` is not general enough //[nll]~^^ ERROR mismatched types //[nll]~| ERROR mismatched types } diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_b_ret_a_vs_bound_a_ret_a.stderr similarity index 95% rename from src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.nll.stderr rename to src/test/ui/hr-subtype/hr-subtype-nll.bound_a_b_ret_a_vs_bound_a_ret_a.stderr index 87d826021b703..3edb1064e3e3e 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_b_ret_a_vs_bound_a_ret_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_vs_free_x.stderr similarity index 94% rename from src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.nll.stderr rename to src/test/ui/hr-subtype/hr-subtype-nll.bound_a_vs_free_x.stderr index bd97f6f090646..f02eeea90bfd3 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.bound_a_vs_free_x.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.bound_inv_a_b_vs_bound_inv_a.stderr similarity index 95% rename from src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.nll.stderr rename to src/test/ui/hr-subtype/hr-subtype-nll.bound_inv_a_b_vs_bound_inv_a.stderr index 874909bf486c8..bfc9793fe5d6d 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.bound_inv_a_b_vs_bound_inv_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -13,7 +13,7 @@ LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.free_inv_x_vs_free_inv_y.stderr similarity index 96% rename from src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr rename to src/test/ui/hr-subtype/hr-subtype-nll.free_inv_x_vs_free_inv_y.stderr index f5db68e8be140..ee0dc877fd127 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.free_inv_x_vs_free_inv_y.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:39:13 + --> $DIR/hr-subtype-nll.rs:54:13 | LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { | -- -- lifetime `'y` defined here @@ -19,7 +19,7 @@ LL | | fn(Inv<'y>)) } = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | -- -- lifetime `'y` defined here diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype-nll.free_x_vs_free_y.stderr similarity index 95% rename from src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr rename to src/test/ui/hr-subtype/hr-subtype-nll.free_x_vs_free_y.stderr index ab97481824d82..75904d6df997a 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype-nll.free_x_vs_free_y.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:45:13 + --> $DIR/hr-subtype-nll.rs:60:13 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | -- -- lifetime `'y` defined here diff --git a/src/test/ui/hr-subtype/hr-subtype-nll.rs b/src/test/ui/hr-subtype/hr-subtype-nll.rs new file mode 100644 index 0000000000000..7fc1692b3506c --- /dev/null +++ b/src/test/ui/hr-subtype/hr-subtype-nll.rs @@ -0,0 +1,117 @@ +// Targeted tests for the higher-ranked subtyping code. + +#![allow(dead_code)] + +// revisions: bound_a_vs_bound_a +// revisions: bound_a_vs_bound_b +// revisions: bound_inv_a_vs_bound_inv_b +// revisions: bound_co_a_vs_bound_co_b +// revisions: bound_a_vs_free_x +// revisions: free_x_vs_free_x +// revisions: free_x_vs_free_y +// revisions: free_inv_x_vs_free_inv_y +// revisions: bound_a_b_vs_bound_a +// revisions: bound_co_a_b_vs_bound_co_a +// revisions: bound_contra_a_contra_b_ret_co_a +// revisions: bound_co_a_co_b_ret_contra_a +// revisions: bound_inv_a_b_vs_bound_inv_a +// revisions: bound_a_b_ret_a_vs_bound_a_ret_a + +//[bound_a_vs_bound_a] check-pass +//[bound_a_vs_bound_b] check-pass +//[bound_inv_a_vs_bound_inv_b] check-pass +//[bound_co_a_vs_bound_co_b] check-pass +//[free_x_vs_free_x] check-pass +//[bound_co_a_b_vs_bound_co_a] check-pass +//[bound_co_a_co_b_ret_contra_a] check-pass +//[bound_a_b_vs_bound_a] check-pass +//[bound_contra_a_contra_b_ret_co_a] check-pass + +// compile-flags: -Z borrowck=mir +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replace with `hr-subtype.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + +fn gimme(_: Option) {} + +struct Inv<'a> { + x: *mut &'a u32, +} + +struct Co<'a> { + x: fn(&'a u32), +} + +struct Contra<'a> { + x: &'a u32, +} + +macro_rules! check { + ($rev:ident: ($t1:ty, $t2:ty)) => { + #[cfg($rev)] + fn subtype<'x, 'y: 'x, 'z: 'y>() { + gimme::<$t2>(None::<$t1>); + //[free_inv_x_vs_free_inv_y]~^ ERROR + } + + #[cfg($rev)] + fn supertype<'x, 'y: 'x, 'z: 'y>() { + gimme::<$t1>(None::<$t2>); + //[bound_a_vs_free_x]~^ ERROR + //[free_x_vs_free_y]~^^ ERROR + //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR + //[bound_inv_a_b_vs_bound_inv_a]~| ERROR + //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^^ ERROR + //[free_inv_x_vs_free_inv_y]~^^^^^^ ERROR + } + }; +} + +// If both have bound regions, they are equivalent, regardless of +// variant. +check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32), +for<'a> fn(&'a u32)) } +check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32), +for<'b> fn(&'b u32)) } +check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>), +for<'b> fn(Inv<'b>)) } +check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>), +for<'b> fn(Co<'b>)) } + +// Bound is a subtype of free. +check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), +fn(&'x u32)) } + +// Two free regions are relatable if subtyping holds. +check! { free_x_vs_free_x: (fn(&'x u32), +fn(&'x u32)) } +check! { free_x_vs_free_y: (fn(&'x u32), +fn(&'y u32)) } +check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +fn(Inv<'y>)) } + +// Somewhat surprisingly, a fn taking two distinct bound lifetimes and +// a fn taking one bound lifetime can be interchangeable, but only if +// we are co- or contra-variant with respect to both lifetimes. +// +// The reason is: +// - if we are covariant, then 'a and 'b can be set to the call-site +// intersection; +// - if we are contravariant, then 'a can be inferred to 'static. +check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), +for<'a> fn(&'a u32, &'a u32)) } +check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), +for<'a> fn(Co<'a>, Co<'a>)) } +check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, +for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } +check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, +for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } + +// If we make those lifetimes invariant, then the two types are not interchangeable. +check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), +for<'a> fn(Inv<'a>, Inv<'a>)) } +check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, +for<'a> fn(&'a u32, &'a u32) -> &'a u32) } + +fn main() {} diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr index 91bd0b6929ac4..13e9fa8a8944a 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr index 27ce56fc16afa..b66ff5a392eb6 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr index bb20f81a1deef..fa715fd354eaa 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr index 9f200357222ab..377689603aa6c 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:39:26 + --> $DIR/hr-subtype.rs:53:26 | LL | gimme::<$t2>(None::<$t1>); | ^^^^^^^^^^^ lifetime mismatch @@ -11,7 +11,7 @@ LL | | fn(Inv<'y>)) } = note: expected enum `Option)>` found enum `Option)>` note: the lifetime `'x` as defined here... - --> $DIR/hr-subtype.rs:38:20 + --> $DIR/hr-subtype.rs:52:20 | LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -20,7 +20,7 @@ LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |______________- in this macro invocation note: ...does not necessarily outlive the lifetime `'y` as defined here - --> $DIR/hr-subtype.rs:38:24 + --> $DIR/hr-subtype.rs:52:24 | LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -31,7 +31,7 @@ LL | | fn(Inv<'y>)) } = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ lifetime mismatch @@ -43,7 +43,7 @@ LL | | fn(Inv<'y>)) } = note: expected enum `Option)>` found enum `Option)>` note: the lifetime `'x` as defined here... - --> $DIR/hr-subtype.rs:44:22 + --> $DIR/hr-subtype.rs:58:22 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -52,7 +52,7 @@ LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |______________- in this macro invocation note: ...does not necessarily outlive the lifetime `'y` as defined here - --> $DIR/hr-subtype.rs:44:26 + --> $DIR/hr-subtype.rs:58:26 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr deleted file mode 100644 index 2bf78d122903a..0000000000000 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:102:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr index 07add3d91a018..9e5eb972f476a 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:45:26 + --> $DIR/hr-subtype.rs:59:26 | LL | gimme::<$t1>(None::<$t2>); | ^^^^^^^^^^^ lifetime mismatch @@ -11,7 +11,7 @@ LL | | fn(&'y u32)) } = note: expected enum `Option` found enum `Option` note: the lifetime `'x` as defined here... - --> $DIR/hr-subtype.rs:44:22 + --> $DIR/hr-subtype.rs:58:22 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ @@ -20,7 +20,7 @@ LL | / check! { free_x_vs_free_y: (fn(&'x u32), LL | | fn(&'y u32)) } | |______________- in this macro invocation note: ...does not necessarily outlive the lifetime `'y` as defined here - --> $DIR/hr-subtype.rs:44:26 + --> $DIR/hr-subtype.rs:58:26 | LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { | ^^ diff --git a/src/test/ui/hr-subtype/hr-subtype.rs b/src/test/ui/hr-subtype/hr-subtype.rs index ad9500eedca93..33929cdb86837 100644 --- a/src/test/ui/hr-subtype/hr-subtype.rs +++ b/src/test/ui/hr-subtype/hr-subtype.rs @@ -1,6 +1,5 @@ // Targeted tests for the higher-ranked subtyping code. -#![feature(rustc_attrs)] #![allow(dead_code)] // revisions: bound_a_vs_bound_a @@ -18,6 +17,21 @@ // revisions: bound_inv_a_b_vs_bound_inv_a // revisions: bound_a_b_ret_a_vs_bound_a_ret_a +//[bound_a_vs_bound_a] check-pass +//[bound_a_vs_bound_b] check-pass +//[bound_inv_a_vs_bound_inv_b] check-pass +//[bound_co_a_vs_bound_co_b] check-pass +//[free_x_vs_free_x] check-pass +//[bound_co_a_b_vs_bound_co_a] check-pass +//[bound_co_a_co_b_ret_contra_a] check-pass +//[bound_a_b_vs_bound_a] check-pass +//[bound_contra_a_contra_b_ret_co_a] check-pass + +// ignore-compare-mode-nll +// FIXME(nll): When stabilizing, this test should be replaced with `hr-subtype-nll.rs` +// The two would normally be just revisions, but this test uses revisions heavily, so splitting into +// a separate test is just easier. + fn gimme(_: Option) {} struct Inv<'a> { @@ -98,15 +112,4 @@ for<'a> fn(Inv<'a>, Inv<'a>)) } check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, for<'a> fn(&'a u32, &'a u32) -> &'a u32) } -#[rustc_error] -fn main() { - //[bound_a_vs_bound_a]~^ ERROR fatal error triggered by #[rustc_error] - //[bound_a_vs_bound_b]~^^ ERROR fatal error triggered by #[rustc_error] - //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR fatal error triggered by #[rustc_error] - //[bound_co_a_vs_bound_co_b]~^^^^ ERROR fatal error triggered by #[rustc_error] - //[free_x_vs_free_x]~^^^^^ ERROR fatal error triggered by #[rustc_error] - //[bound_co_a_b_vs_bound_co_a]~^^^^^^ ERROR - //[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR - //[bound_a_b_vs_bound_a]~^^^^^^^^ ERROR - //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR -} +fn main() {} diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr b/src/test/ui/hr-subtype/placeholder-pattern-fail.base.stderr similarity index 84% rename from src/test/ui/hr-subtype/placeholder-pattern-fail.stderr rename to src/test/ui/hr-subtype/placeholder-pattern-fail.base.stderr index 7bd5308052b0f..c6cb77d8d8db9 100644 --- a/src/test/ui/hr-subtype/placeholder-pattern-fail.stderr +++ b/src/test/ui/hr-subtype/placeholder-pattern-fail.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:9:47 + --> $DIR/placeholder-pattern-fail.rs:13:47 | LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:14:31 + --> $DIR/placeholder-pattern-fail.rs:18:31 | LL | let _x: (&'static i32,) = x; | ^ lifetime mismatch @@ -16,14 +16,14 @@ LL | let _x: (&'static i32,) = x; = note: expected tuple `(&'static i32,)` found tuple `(&'c i32,)` note: the lifetime `'c` as defined here... - --> $DIR/placeholder-pattern-fail.rs:13:12 + --> $DIR/placeholder-pattern-fail.rs:17:12 | LL | fn simple1<'c>(x: (&'c i32,)) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:19:30 + --> $DIR/placeholder-pattern-fail.rs:23:30 | LL | let _: (&'static i32,) = x; | ^ lifetime mismatch @@ -31,7 +31,7 @@ LL | let _: (&'static i32,) = x; = note: expected tuple `(&'static i32,)` found tuple `(&'c i32,)` note: the lifetime `'c` as defined here... - --> $DIR/placeholder-pattern-fail.rs:18:12 + --> $DIR/placeholder-pattern-fail.rs:22:12 | LL | fn simple2<'c>(x: (&'c i32,)) { | ^^ diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr b/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr index 73b0a31736447..a1f713d8afb3b 100644 --- a/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr +++ b/src/test/ui/hr-subtype/placeholder-pattern-fail.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/placeholder-pattern-fail.rs:9:47 + --> $DIR/placeholder-pattern-fail.rs:13:47 | LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; | ^^^ one type is more general than the other diff --git a/src/test/ui/hr-subtype/placeholder-pattern-fail.rs b/src/test/ui/hr-subtype/placeholder-pattern-fail.rs index 3b5b075cb582e..ac276a889824e 100644 --- a/src/test/ui/hr-subtype/placeholder-pattern-fail.rs +++ b/src/test/ui/hr-subtype/placeholder-pattern-fail.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Check that incorrect higher ranked subtyping // causes an error. struct Inv<'a>(fn(&'a ()) -> &'a ()); @@ -12,12 +16,12 @@ fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) { fn simple1<'c>(x: (&'c i32,)) { let _x: (&'static i32,) = x; - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types } fn simple2<'c>(x: (&'c i32,)) { let _: (&'static i32,) = x; - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types } fn main() { diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.base.stderr similarity index 91% rename from src/test/ui/hrtb/hrtb-conflate-regions.stderr rename to src/test/ui/hrtb/hrtb-conflate-regions.base.stderr index b1d4c0bf37505..e55e56f916bad 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:31:10 | LL | fn b() { want_foo2::(); } | ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr b/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr index 46f5308dd87ba..61b549b9cd761 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr +++ b/src/test/ui/hrtb/hrtb-conflate-regions.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:31:10 | LL | fn b() { want_foo2::(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | fn b() { want_foo2::(); } = note: ...but it actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 + --> $DIR/hrtb-conflate-regions.rs:31:10 | LL | fn b() { want_foo2::(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-conflate-regions.rs b/src/test/ui/hrtb/hrtb-conflate-regions.rs index 004d62ac513ff..11285d0757530 100644 --- a/src/test/ui/hrtb/hrtb-conflate-regions.rs +++ b/src/test/ui/hrtb/hrtb-conflate-regions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that an impl with only one bound region `'a` cannot be used to // satisfy a constraint where there are two bound regions. @@ -24,6 +28,9 @@ impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct } fn a() { want_foo1::(); } // OK -- foo wants just one region -fn b() { want_foo2::(); } //~ ERROR +fn b() { want_foo2::(); } +//[base]~^ ERROR +//[nll]~^^ ERROR implementation of +//[nll]~| ERROR implementation of fn main() { } diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.nll.stderr b/src/test/ui/hrtb/hrtb-exists-forall-fn.nll.stderr deleted file mode 100644 index 9914783d9767d..0000000000000 --- a/src/test/ui/hrtb/hrtb-exists-forall-fn.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/hrtb-exists-forall-fn.rs:17:34 - | -LL | let _: for<'b> fn(&'b u32) = foo(); - | ^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'b> fn(&'b u32)` - found fn pointer `fn(&u32)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.base.stderr similarity index 85% rename from src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr rename to src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.base.stderr index 613f4dc4951ec..006b6756b1eb5 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:38:5 | LL | foo::<()>(); | ^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr index 364b613fc7717..23b5072826418 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:38:5 | LL | foo::<()>(); | ^^^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs index 921061916fc95..4b33dcb2cab4c 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test a case where variance and higher-ranked types interact in surprising ways. // // In particular, we test this pattern in trait solving, where it is not connected diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.base.stderr similarity index 86% rename from src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr rename to src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.base.stderr index b487ce3e0ffa1..05575b01834b7 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 + --> $DIR/hrtb-exists-forall-trait-invariant.rs:32:5 | LL | foo::<()>(); | ^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr index cb2ce8a4116aa..58d59f60379f7 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 + --> $DIR/hrtb-exists-forall-trait-invariant.rs:32:5 | LL | foo::<()>(); | ^^^^^^^^^^^ implementation of `Trait` is not general enough diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs index 9b9e4496a870d..c779bc3f46c33 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-invariant.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test an `exists<'a> { forall<'b> { 'a = 'b } }` pattern -- which should not compile! // // In particular, we test this pattern in trait solving, where it is not connected diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.base.stderr similarity index 90% rename from src/test/ui/hrtb/hrtb-just-for-static.stderr rename to src/test/ui/hrtb/hrtb-just-for-static.base.stderr index ffc83aab4af4d..6e20b10066467 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:24:5 + --> $DIR/hrtb-just-for-static.rs:28:5 | LL | want_hrtb::() | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | want_hrtb::() = note: ...but it actually implements `Foo<&'static isize>` error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:34:5 | LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr b/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr index a5770431eaff1..090bd9f68ad1b 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:24:5 + --> $DIR/hrtb-just-for-static.rs:28:5 | LL | want_hrtb::() | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | want_hrtb::() = note: ...but it actually implements `Foo<&'static isize>` error: lifetime may not live long enough - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:34:5 | LL | fn give_some<'a>() { | -- lifetime `'a` defined here @@ -16,7 +16,7 @@ LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:30:5 + --> $DIR/hrtb-just-for-static.rs:34:5 | LL | want_hrtb::<&'a u32>() | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/hrtb-just-for-static.rs b/src/test/ui/hrtb/hrtb-just-for-static.rs index 88d5ce8e64056..dc70609c16841 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.rs +++ b/src/test/ui/hrtb/hrtb-just-for-static.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test a case where you have an impl of `Foo` for all `X` that // is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. @@ -27,7 +31,10 @@ fn give_static() { // AnyInt implements Foo<&'a isize> for any 'a, so it is a match. impl<'a> Foo<&'a isize> for &'a u32 { } fn give_some<'a>() { - want_hrtb::<&'a u32>() //~ ERROR + want_hrtb::<&'a u32>() + //[base]~^ ERROR + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR implementation of `Foo` is not general enough } fn main() { } diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.stderr b/src/test/ui/hrtb/hrtb-perfect-forwarding.base.stderr similarity index 88% rename from src/test/ui/hrtb/hrtb-perfect-forwarding.stderr rename to src/test/ui/hrtb/hrtb-perfect-forwarding.base.stderr index 07ff9b96e44ff..678a1137cd678 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.stderr +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough @@ -8,7 +8,7 @@ LL | foo_hrtb_bar_not(&mut t); = note: ...but it actually implements `Bar<&'b isize>` error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr b/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr index 68da46d46bd14..3643ce62d40b7 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:16:1 + --> $DIR/hrtb-perfect-forwarding.rs:20:1 | LL | / fn no_hrtb<'b, T>(mut t: T) LL | | where @@ -15,7 +15,7 @@ LL | | } = help: a `loop` may express intention better if this is on purpose warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:25:1 + --> $DIR/hrtb-perfect-forwarding.rs:29:1 | LL | / fn bar_hrtb(mut t: T) LL | | where @@ -30,7 +30,7 @@ LL | | } = help: a `loop` may express intention better if this is on purpose warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:35:1 + --> $DIR/hrtb-perfect-forwarding.rs:39:1 | LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T) LL | | where @@ -39,7 +39,7 @@ LL | | { ... | LL | | foo_hrtb_bar_not(&mut t); | | ------------------------ recursive call site -LL | | +... | LL | | LL | | } | |_^ cannot return without recursing @@ -47,7 +47,7 @@ LL | | } = help: a `loop` may express intention better if this is on purpose error: lifetime may not live long enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) | -- lifetime `'b` defined here @@ -56,7 +56,7 @@ LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 + --> $DIR/hrtb-perfect-forwarding.rs:47:5 | LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough @@ -65,7 +65,7 @@ LL | foo_hrtb_bar_not(&mut t); = note: ...but it actually implements `Bar<&'1 isize>`, for some specific lifetime `'1` warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:48:1 + --> $DIR/hrtb-perfect-forwarding.rs:53:1 | LL | / fn foo_hrtb_bar_hrtb(mut t: T) LL | | where diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs b/src/test/ui/hrtb/hrtb-perfect-forwarding.rs index 441a788359e03..2db9f661cf41c 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.rs +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test a case where you have an impl of `Foo` for all `X` that // is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. @@ -13,7 +17,7 @@ impl<'a, X, F> Foo for &'a mut F where F: Foo + Bar {} impl<'a, X, F> Bar for &'a mut F where F: Bar {} -fn no_hrtb<'b, T>(mut t: T) +fn no_hrtb<'b, T>(mut t: T) //[nll]~ WARN function cannot return where T: Bar<&'b isize>, { @@ -22,7 +26,7 @@ where no_hrtb(&mut t); } -fn bar_hrtb(mut t: T) +fn bar_hrtb(mut t: T) //[nll]~ WARN function cannot return where T: for<'b> Bar<&'b isize>, { @@ -32,7 +36,7 @@ where bar_hrtb(&mut t); } -fn foo_hrtb_bar_not<'b, T>(mut t: T) +fn foo_hrtb_bar_not<'b, T>(mut t: T) //[nll]~ WARN function cannot return where T: for<'a> Foo<&'a isize> + Bar<&'b isize>, { @@ -42,10 +46,11 @@ where // clause only specifies `T : Bar<&'b isize>`. foo_hrtb_bar_not(&mut t); //~^ ERROR implementation of `Bar` is not general enough - //~| ERROR implementation of `Bar` is not general enough + //[base]~^^ ERROR implementation of `Bar` is not general enough + //[nll]~^^^ ERROR lifetime may not live long enough } -fn foo_hrtb_bar_hrtb(mut t: T) +fn foo_hrtb_bar_hrtb(mut t: T) //[nll]~ WARN function cannot return where T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, { diff --git a/src/test/ui/hrtb/issue-30786.migrate.stderr b/src/test/ui/hrtb/issue-30786.base.stderr similarity index 69% rename from src/test/ui/hrtb/issue-30786.migrate.stderr rename to src/test/ui/hrtb/issue-30786.base.stderr index 7157b186fc8ad..dba3911d99c17 100644 --- a/src/test/ui/hrtb/issue-30786.migrate.stderr +++ b/src/test/ui/hrtb/issue-30786.base.stderr @@ -1,5 +1,5 @@ -error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:127:22 +error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:122:22 | LL | pub struct Map { | -------------------- @@ -8,13 +8,13 @@ LL | pub struct Map { | doesn't satisfy `_: StreamExt` ... LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds + | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Map: Stream` - `&'a mut &mut Map: Stream` - `&'a mut Map: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Map: Stream` + `&'a mut &mut Map: Stream` + `&'a mut Map: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here @@ -23,8 +23,8 @@ help: one of the expressions' fields has a method of the same name LL | let filter = map.stream.filterx(|x: &_| true); | +++++++ -error[E0599]: the method `countx` exists for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:140:24 +error[E0599]: the method `countx` exists for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:134:24 | LL | pub struct Filter { | ----------------------- @@ -33,13 +33,13 @@ LL | pub struct Filter { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method cannot be called on `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut &mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut &mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here diff --git a/src/test/ui/hrtb/issue-30786.nll.stderr b/src/test/ui/hrtb/issue-30786.nll.stderr index 7157b186fc8ad..dba3911d99c17 100644 --- a/src/test/ui/hrtb/issue-30786.nll.stderr +++ b/src/test/ui/hrtb/issue-30786.nll.stderr @@ -1,5 +1,5 @@ -error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:127:22 +error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:122:22 | LL | pub struct Map { | -------------------- @@ -8,13 +8,13 @@ LL | pub struct Map { | doesn't satisfy `_: StreamExt` ... LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds + | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Map: Stream` - `&'a mut &mut Map: Stream` - `&'a mut Map: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Map: Stream` + `&'a mut &mut Map: Stream` + `&'a mut Map: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here @@ -23,8 +23,8 @@ help: one of the expressions' fields has a method of the same name LL | let filter = map.stream.filterx(|x: &_| true); | +++++++ -error[E0599]: the method `countx` exists for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:140:24 +error[E0599]: the method `countx` exists for struct `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:134:24 | LL | pub struct Filter { | ----------------------- @@ -33,13 +33,13 @@ LL | pub struct Filter { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method cannot be called on `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut &mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - `&'a mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>: Stream` - --> $DIR/issue-30786.rs:105:50 + `&'a mut &Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut &mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + `&'a mut Filter fn(&'r u64) -> &'r u64 {identity::}>, [closure@$DIR/issue-30786.rs:133:30: 133:42]>: Stream` + --> $DIR/issue-30786.rs:100:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here diff --git a/src/test/ui/hrtb/issue-30786.rs b/src/test/ui/hrtb/issue-30786.rs index 540c26c358b1d..c2e019098706e 100644 --- a/src/test/ui/hrtb/issue-30786.rs +++ b/src/test/ui/hrtb/issue-30786.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // rust-lang/rust#30786: the use of `for<'b> &'b mut A: Stream Option; @@ -125,8 +120,7 @@ fn variant1() { // guess. let map = source.mapx(|x: &_| x); let filter = map.filterx(|x: &_| true); - //[migrate]~^ ERROR the method - //[nll]~^^ ERROR the method + //~^ ERROR the method } fn variant2() { @@ -138,8 +132,7 @@ fn variant2() { let map = source.mapx(identity); let filter = map.filterx(|x: &_| true); let count = filter.countx(); - //[migrate]~^ ERROR the method - //[nll]~^^ ERROR the method + //~^ ERROR the method } fn main() {} diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.base.stderr similarity index 92% rename from src/test/ui/hrtb/issue-46989.stderr rename to src/test/ui/hrtb/issue-46989.base.stderr index f3d906cae4cc3..d1f6fed10fdde 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-46989.rs:38:5 + --> $DIR/issue-46989.rs:42:5 | LL | assert_foo::(); | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/issue-46989.nll.stderr b/src/test/ui/hrtb/issue-46989.nll.stderr index 309e1a676edaf..e1ddd7235f57d 100644 --- a/src/test/ui/hrtb/issue-46989.nll.stderr +++ b/src/test/ui/hrtb/issue-46989.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-46989.rs:38:5 + --> $DIR/issue-46989.rs:42:5 | LL | assert_foo::(); | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/hrtb/issue-46989.rs b/src/test/ui/hrtb/issue-46989.rs index 4a09f4be156e2..0bb6d7a18eb75 100644 --- a/src/test/ui/hrtb/issue-46989.rs +++ b/src/test/ui/hrtb/issue-46989.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #46989: // // In the move to universes, this test started passing. diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.base.stderr similarity index 90% rename from src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr rename to src/test/ui/impl-header-lifetime-elision/dyn-trait.base.stderr index 2307572cc3f24..a01560e70e311 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/dyn-trait.rs:20:16 + --> $DIR/dyn-trait.rs:24:16 | LL | fn with_dyn_debug_static<'a>(x: Box) { | ------------------- this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | static_val(x); | ^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/dyn-trait.rs:20:5 + --> $DIR/dyn-trait.rs:24:5 | LL | static_val(x); | ^^^^^^^^^^ diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr index 88c260b18cbb0..762698c4fc141 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/dyn-trait.rs:20:5 + --> $DIR/dyn-trait.rs:24:5 | LL | fn with_dyn_debug_static<'a>(x: Box) { | -- - `x` is a reference that is only valid in the function body diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs b/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs index 89210fdf137e0..a103034a53765 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a, // 'b> MyTrait<'a> for &'b i32`. @@ -17,7 +21,9 @@ fn static_val(_: T) { } fn with_dyn_debug_static<'a>(x: Box) { - static_val(x); //~ ERROR E0759 + static_val(x); + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR borrowed data escapes outside of function } fn not_static_val(_: T) { diff --git a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs index 41b6a9eb0551f..5251eeee8bb26 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs @@ -1,7 +1,5 @@ // edition:2018 // check-pass -// revisions: migrate mir -//[mir]compile-flags: -Z borrowck=mir trait Trait<'a, 'b> {} impl Trait<'_, '_> for T {} diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.base.stderr similarity index 90% rename from src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr rename to src/test/ui/impl-trait/must_outlive_least_region_or_bound.base.stderr index dade2b91fe0b6..45cc935b7ccd1 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.base.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:3:35 + --> $DIR/must_outlive_least_region_or_bound.rs:7:35 | LL | fn elided(x: &i32) -> impl Copy { x } | ---- ^ @@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 + --> $DIR/must_outlive_least_region_or_bound.rs:10:44 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | -- ^ @@ -25,7 +25,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } | ++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:9:46 + --> $DIR/must_outlive_least_region_or_bound.rs:13:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | ---- ^ ...is used here... @@ -33,7 +33,7 @@ LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | this data with an anonymous lifetime `'_`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:9:24 + --> $DIR/must_outlive_least_region_or_bound.rs:13:24 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:11:55 + --> $DIR/must_outlive_least_region_or_bound.rs:17:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | ------- ^ ...is used here... @@ -55,7 +55,7 @@ LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | this data with lifetime `'a`... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:11:33 + --> $DIR/must_outlive_least_region_or_bound.rs:17:33 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | ^^^^^^^^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:13:24 + --> $DIR/must_outlive_least_region_or_bound.rs:21:24 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | ---- ^^^^^^^^^^^^^^ lifetime `'a` required @@ -77,7 +77,7 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:24:65 + --> $DIR/must_outlive_least_region_or_bound.rs:36:65 | LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | ---- this data with an anonymous lifetime `'_`... ^ ...is used and required to live as long as `'static` here @@ -92,13 +92,13 @@ LL | fn elided5(x: &i32) -> (Box, impl Debug + '_) { (Box::new(x), x) | ++++ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:29:69 + --> $DIR/must_outlive_least_region_or_bound.rs:43:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | ------- this data with lifetime `'a`... ^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/must_outlive_least_region_or_bound.rs:29:34 + --> $DIR/must_outlive_least_region_or_bound.rs:43:34 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,10 +112,10 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x | ~~~~~~~~~~~~ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + --> $DIR/must_outlive_least_region_or_bound.rs:50:5 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here + | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:50:5: 50:31]` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -125,7 +125,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:38:51 + --> $DIR/must_outlive_least_region_or_bound.rs:54:51 | LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds @@ -136,7 +136,7 @@ LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 's | +++++++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:16:50 + --> $DIR/must_outlive_least_region_or_bound.rs:24:50 | LL | fn elided3(x: &i32) -> Box { Box::new(x) } | ---- ^ ...is used and required to live as long as `'static` here @@ -144,7 +144,7 @@ LL | fn elided3(x: &i32) -> Box { Box::new(x) } | this data with an anonymous lifetime `'_`... | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:16:28 + --> $DIR/must_outlive_least_region_or_bound.rs:24:28 | LL | fn elided3(x: &i32) -> Box { Box::new(x) } | ^^^^^^^^^ ----------- because of this returned expression @@ -156,7 +156,7 @@ LL | fn elided3(x: &i32) -> Box { Box::new(x) } | ++++ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:18:59 + --> $DIR/must_outlive_least_region_or_bound.rs:27:59 | LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } | ------- ^ ...is used and required to live as long as `'static` here @@ -164,7 +164,7 @@ LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } | this data with lifetime `'a`... | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:18:37 + --> $DIR/must_outlive_least_region_or_bound.rs:27:37 | LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } | ^^^^^^^^^ ----------- because of this returned expression @@ -176,7 +176,7 @@ LL | fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } | ++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:20:60 + --> $DIR/must_outlive_least_region_or_bound.rs:30:60 | LL | fn elided4(x: &i32) -> Box { Box::new(x) } | ---- ^ ...is used and required to live as long as `'static` here @@ -184,7 +184,7 @@ LL | fn elided4(x: &i32) -> Box { Box::new(x) } | this data with an anonymous lifetime `'_`... | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:20:40 + --> $DIR/must_outlive_least_region_or_bound.rs:30:40 | LL | fn elided4(x: &i32) -> Box { Box::new(x) } | ^^^^^^^ ----------- because of this returned expression @@ -200,13 +200,13 @@ LL | fn elided4(x: &'static i32) -> Box { Box::new(x) } | ~~~~~~~~~~~~ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/must_outlive_least_region_or_bound.rs:22:69 + --> $DIR/must_outlive_least_region_or_bound.rs:33:69 | LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } | ------- this data with lifetime `'a`... ^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/must_outlive_least_region_or_bound.rs:22:49 + --> $DIR/must_outlive_least_region_or_bound.rs:33:49 | LL | fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } | ^^^^^^^ ----------- because of this returned expression diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index db737a9c544c0..0252e546fb0f2 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:3:35 + --> $DIR/must_outlive_least_region_or_bound.rs:7:35 | LL | fn elided(x: &i32) -> impl Copy { x } | ---- ^ @@ -12,7 +12,7 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 + --> $DIR/must_outlive_least_region_or_bound.rs:10:44 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | -- ^ @@ -25,7 +25,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } | ++++ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:9:46 + --> $DIR/must_outlive_least_region_or_bound.rs:13:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } | - ^ returning this value requires that `'1` must outlive `'static` @@ -42,7 +42,7 @@ LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:11:55 + --> $DIR/must_outlive_least_region_or_bound.rs:17:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` @@ -57,7 +57,7 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:13:41 + --> $DIR/must_outlive_least_region_or_bound.rs:21:41 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | ---- ^ lifetime `'a` required @@ -65,7 +65,7 @@ LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:24:55 + --> $DIR/must_outlive_least_region_or_bound.rs:36:55 | LL | fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } | - ^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` @@ -82,7 +82,7 @@ LL | fn elided5(x: &i32) -> (Box, impl Debug + '_) { (Box::new(x), x) | ++++ error: lifetime may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:29:69 + --> $DIR/must_outlive_least_region_or_bound.rs:43:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` @@ -97,10 +97,10 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x | ~~~~~~~~~~~~ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + --> $DIR/must_outlive_least_region_or_bound.rs:50:5 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here + | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:50:5: 50:31]` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -110,7 +110,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:40:5 + --> $DIR/must_outlive_least_region_or_bound.rs:56:5 | LL | x | ^ ...so that the type `T` will meet its required lifetime bounds diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs index 60e4672f1b7ff..6bb3141b0125a 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + use std::fmt::Debug; fn elided(x: &i32) -> impl Copy { x } @@ -6,27 +10,39 @@ fn elided(x: &i32) -> impl Copy { x } fn explicit<'a>(x: &'a i32) -> impl Copy { x } //~^ ERROR: captures lifetime that does not appear in bounds -fn elided2(x: &i32) -> impl Copy + 'static { x } //~ ERROR E0759 +fn elided2(x: &i32) -> impl Copy + 'static { x } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough -fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } //~ ERROR E0759 +fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough fn foo<'a>(x: &i32) -> impl Copy + 'a { x } //~^ ERROR explicit lifetime required in the type of `x` -fn elided3(x: &i32) -> Box { Box::new(x) } //~ ERROR E0759 +fn elided3(x: &i32) -> Box { Box::new(x) } +//[base]~^ ERROR E0759 -fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } //~ ERROR E0759 +fn explicit3<'a>(x: &'a i32) -> Box { Box::new(x) } +//[base]~^ ERROR E0759 -fn elided4(x: &i32) -> Box { Box::new(x) } //~ ERROR E0759 +fn elided4(x: &i32) -> Box { Box::new(x) } +//[base]~^ ERROR E0759 -fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } //~ ERROR E0759 +fn explicit4<'a>(x: &'a i32) -> Box { Box::new(x) } +//[base]~^ ERROR E0759 -fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } //~ ERROR E0759 +fn elided5(x: &i32) -> (Box, impl Debug) { (Box::new(x), x) } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough trait LifetimeTrait<'a> {} impl<'a> LifetimeTrait<'a> for &'a i32 {} -fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } //~ ERROR E0759 +fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } +//[base]~^ ERROR E0759 +//[nll]~^^ ERROR lifetime may not live long enough // Tests that a closure type containing 'b cannot be returned from a type where // only 'a was expected. @@ -36,8 +52,9 @@ fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { } fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { - //~^ ERROR the parameter type `T` may not live long enough + //[base]~^ ERROR the parameter type `T` may not live long enough x + //[nll]~^ ERROR the parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/ui/impl-trait/type_parameters_captured.stderr b/src/test/ui/impl-trait/type_parameters_captured.base.stderr similarity index 91% rename from src/test/ui/impl-trait/type_parameters_captured.stderr rename to src/test/ui/impl-trait/type_parameters_captured.base.stderr index 9f28a8d44a7b7..cfa1d93d57143 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.base.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:7:20 + --> $DIR/type_parameters_captured.rs:11:20 | LL | fn foo(x: T) -> impl Any + 'static { | ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds diff --git a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr index 3050f10b2057d..a07ba564490a9 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:9:5 + --> $DIR/type_parameters_captured.rs:13:5 | LL | x | ^ ...so that the type `T` will meet its required lifetime bounds diff --git a/src/test/ui/impl-trait/type_parameters_captured.rs b/src/test/ui/impl-trait/type_parameters_captured.rs index 6c9c9d4a42af5..0618beeef9763 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.rs +++ b/src/test/ui/impl-trait/type_parameters_captured.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + use std::fmt::Debug; trait Any {} @@ -5,8 +9,9 @@ impl Any for T {} // Check that type parameters are captured and not considered 'static fn foo(x: T) -> impl Any + 'static { - //~^ ERROR the parameter type `T` may not live long enough + //[base]~^ ERROR the parameter type `T` may not live long enough x + //[nll]~^ ERROR the parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/ui/issues/issue-10291.stderr b/src/test/ui/issues/issue-10291.base.stderr similarity index 86% rename from src/test/ui/issues/issue-10291.stderr rename to src/test/ui/issues/issue-10291.base.stderr index a80b0ba5e9151..cad22b2f3ea6e 100644 --- a/src/test/ui/issues/issue-10291.stderr +++ b/src/test/ui/issues/issue-10291.base.stderr @@ -1,19 +1,21 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/issue-10291.rs:3:9 + --> $DIR/issue-10291.rs:7:9 | LL | x | ^ | note: ...the reference is valid for the anonymous lifetime #1 defined here... - --> $DIR/issue-10291.rs:2:69 + --> $DIR/issue-10291.rs:6:69 | LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { | _____________________________________________________________________^ LL | | x +LL | | +LL | | LL | | })); | |_____^ note: ...but the borrowed content is only valid for the lifetime `'x` as defined here - --> $DIR/issue-10291.rs:1:9 + --> $DIR/issue-10291.rs:5:9 | LL | fn test<'x>(x: &'x isize) { | ^^ diff --git a/src/test/ui/issues/issue-10291.nll.stderr b/src/test/ui/issues/issue-10291.nll.stderr index a7b827d27a87b..47c4d4945f3ed 100644 --- a/src/test/ui/issues/issue-10291.nll.stderr +++ b/src/test/ui/issues/issue-10291.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-10291.rs:3:9 + --> $DIR/issue-10291.rs:7:9 | LL | fn test<'x>(x: &'x isize) { | -- lifetime `'x` defined here diff --git a/src/test/ui/issues/issue-10291.rs b/src/test/ui/issues/issue-10291.rs index 559c5fcac954b..8ee3ce44d3d9e 100644 --- a/src/test/ui/issues/issue-10291.rs +++ b/src/test/ui/issues/issue-10291.rs @@ -1,6 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn test<'x>(x: &'x isize) { drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - x //~ ERROR E0312 + x + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough })); } diff --git a/src/test/ui/issues/issue-13058.stderr b/src/test/ui/issues/issue-13058.base.stderr similarity index 94% rename from src/test/ui/issues/issue-13058.stderr rename to src/test/ui/issues/issue-13058.base.stderr index 53a2c987c5256..2b9fff3f98105 100644 --- a/src/test/ui/issues/issue-13058.stderr +++ b/src/test/ui/issues/issue-13058.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `cont` - --> $DIR/issue-13058.rs:14:26 + --> $DIR/issue-13058.rs:18:26 | LL | fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &T) -> bool | -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T` diff --git a/src/test/ui/issues/issue-13058.nll.stderr b/src/test/ui/issues/issue-13058.nll.stderr index 8368978deab1a..ddefa8a62c98d 100644 --- a/src/test/ui/issues/issue-13058.nll.stderr +++ b/src/test/ui/issues/issue-13058.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `cont` - --> $DIR/issue-13058.rs:14:21 + --> $DIR/issue-13058.rs:18:21 | LL | fn check<'r, I: Iterator, T: Itble<'r, usize, I>>(cont: &T) -> bool | -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T` diff --git a/src/test/ui/issues/issue-13058.rs b/src/test/ui/issues/issue-13058.rs index a5806feb720d6..cbd52a802e8de 100644 --- a/src/test/ui/issues/issue-13058.rs +++ b/src/test/ui/issues/issue-13058.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::ops::Range; trait Itble<'r, T, I: Iterator> { fn iter(&'r self) -> I; } diff --git a/src/test/ui/issues/issue-15034.stderr b/src/test/ui/issues/issue-15034.base.stderr similarity index 93% rename from src/test/ui/issues/issue-15034.stderr rename to src/test/ui/issues/issue-15034.base.stderr index 3ede5ba4fa30a..293692c1ddc62 100644 --- a/src/test/ui/issues/issue-15034.stderr +++ b/src/test/ui/issues/issue-15034.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:17:25 + --> $DIR/issue-15034.rs:21:25 | LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { | ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>` diff --git a/src/test/ui/issues/issue-15034.nll.stderr b/src/test/ui/issues/issue-15034.nll.stderr index f142e260a2313..54af22fb726ec 100644 --- a/src/test/ui/issues/issue-15034.nll.stderr +++ b/src/test/ui/issues/issue-15034.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:17:9 + --> $DIR/issue-15034.rs:21:9 | LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { | ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>` diff --git a/src/test/ui/issues/issue-15034.rs b/src/test/ui/issues/issue-15034.rs index 9ea6ed89ca249..f95275e3a7b80 100644 --- a/src/test/ui/issues/issue-15034.rs +++ b/src/test/ui/issues/issue-15034.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub struct Lexer<'a> { input: &'a str, } diff --git a/src/test/ui/issues/issue-16683.stderr b/src/test/ui/issues/issue-16683.base.stderr similarity index 83% rename from src/test/ui/issues/issue-16683.stderr rename to src/test/ui/issues/issue-16683.base.stderr index d4e18df8de324..f684dd04a36ca 100644 --- a/src/test/ui/issues/issue-16683.stderr +++ b/src/test/ui/issues/issue-16683.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/issue-16683.rs:4:14 + --> $DIR/issue-16683.rs:8:14 | LL | self.a(); | ^ | note: first, the lifetime cannot outlive the anonymous lifetime defined here... - --> $DIR/issue-16683.rs:3:10 + --> $DIR/issue-16683.rs:7:10 | LL | fn b(&self) { | ^^^^^ note: ...so that reference does not outlive borrowed content - --> $DIR/issue-16683.rs:4:9 + --> $DIR/issue-16683.rs:8:9 | LL | self.a(); | ^^^^ note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/issue-16683.rs:1:9 + --> $DIR/issue-16683.rs:5:9 | LL | trait T<'a> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-16683.rs:4:14 + --> $DIR/issue-16683.rs:8:14 | LL | self.a(); | ^ diff --git a/src/test/ui/issues/issue-16683.nll.stderr b/src/test/ui/issues/issue-16683.nll.stderr index fff681b2e0b76..308d6352602d2 100644 --- a/src/test/ui/issues/issue-16683.nll.stderr +++ b/src/test/ui/issues/issue-16683.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-16683.rs:4:9 + --> $DIR/issue-16683.rs:8:9 | LL | trait T<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-16683.rs b/src/test/ui/issues/issue-16683.rs index bbbd4daa4c5c4..05969bc7b9f13 100644 --- a/src/test/ui/issues/issue-16683.rs +++ b/src/test/ui/issues/issue-16683.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait T<'a> { fn a(&'a self) -> &'a bool; fn b(&self) { - self.a(); //~ ERROR cannot infer + self.a(); + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/issues/issue-16922.stderr b/src/test/ui/issues/issue-16922.base.stderr similarity index 95% rename from src/test/ui/issues/issue-16922.stderr rename to src/test/ui/issues/issue-16922.base.stderr index 53405a660f861..e139de2019d62 100644 --- a/src/test/ui/issues/issue-16922.stderr +++ b/src/test/ui/issues/issue-16922.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `value` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-16922.rs:4:14 + --> $DIR/issue-16922.rs:8:14 | LL | fn foo(value: &T) -> Box { | -- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/issues/issue-16922.nll.stderr b/src/test/ui/issues/issue-16922.nll.stderr index 9d9f32a97c065..00a42e6724250 100644 --- a/src/test/ui/issues/issue-16922.nll.stderr +++ b/src/test/ui/issues/issue-16922.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-16922.rs:4:5 + --> $DIR/issue-16922.rs:8:5 | LL | fn foo(value: &T) -> Box { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/issues/issue-16922.rs b/src/test/ui/issues/issue-16922.rs index f048ccd2427cb..1767017eb3db5 100644 --- a/src/test/ui/issues/issue-16922.rs +++ b/src/test/ui/issues/issue-16922.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::any::Any; fn foo(value: &T) -> Box { - Box::new(value) as Box //~ ERROR E0759 + Box::new(value) as Box + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/issues/issue-17728.stderr b/src/test/ui/issues/issue-17728.base.stderr similarity index 96% rename from src/test/ui/issues/issue-17728.stderr rename to src/test/ui/issues/issue-17728.base.stderr index 943c63667e05f..b52dc444593ab 100644 --- a/src/test/ui/issues/issue-17728.stderr +++ b/src/test/ui/issues/issue-17728.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-17728.rs:15:28 + --> $DIR/issue-17728.rs:19:28 | LL | fn attemptTraverse(&self, room: &Room, directionStr: &str) -> Result<&Room, &str> { | ----- ------------------- @@ -16,7 +16,7 @@ LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> | ++++ ++ ++ error[E0308]: `match` arms have incompatible types - --> $DIR/issue-17728.rs:109:14 + --> $DIR/issue-17728.rs:113:14 | LL | / match to_parse { LL | | "w" | "west" => RoomDirection::West, diff --git a/src/test/ui/issues/issue-17728.nll.stderr b/src/test/ui/issues/issue-17728.nll.stderr index a13d2dfa1fbaa..ddfb890eac36e 100644 --- a/src/test/ui/issues/issue-17728.nll.stderr +++ b/src/test/ui/issues/issue-17728.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/issue-17728.rs:109:14 + --> $DIR/issue-17728.rs:113:14 | LL | / match to_parse { LL | | "w" | "west" => RoomDirection::West, diff --git a/src/test/ui/issues/issue-17728.rs b/src/test/ui/issues/issue-17728.rs index bec52d87d2983..91b71ad6d0be2 100644 --- a/src/test/ui/issues/issue-17728.rs +++ b/src/test/ui/issues/issue-17728.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::fmt::{Debug, Formatter, Error}; use std::collections::HashMap; @@ -13,7 +17,7 @@ trait TraversesWorld { let maybe_room = room.direction_to_room.get(&direction); match maybe_room { Some(entry) => Ok(entry), - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] _ => Err("Direction does not exist in room.") } } diff --git a/src/test/ui/issues/issue-17758.stderr b/src/test/ui/issues/issue-17758.base.stderr similarity index 83% rename from src/test/ui/issues/issue-17758.stderr rename to src/test/ui/issues/issue-17758.base.stderr index 711217033a1f7..202238a49cbf5 100644 --- a/src/test/ui/issues/issue-17758.stderr +++ b/src/test/ui/issues/issue-17758.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/issue-17758.rs:7:14 + --> $DIR/issue-17758.rs:11:14 | LL | self.foo(); | ^^^ | note: first, the lifetime cannot outlive the anonymous lifetime defined here... - --> $DIR/issue-17758.rs:6:12 + --> $DIR/issue-17758.rs:10:12 | LL | fn bar(&self) { | ^^^^^ note: ...so that reference does not outlive borrowed content - --> $DIR/issue-17758.rs:7:9 + --> $DIR/issue-17758.rs:11:9 | LL | self.foo(); | ^^^^ note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/issue-17758.rs:4:11 + --> $DIR/issue-17758.rs:8:11 | LL | trait Foo<'a> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-17758.rs:7:14 + --> $DIR/issue-17758.rs:11:14 | LL | self.foo(); | ^^^ diff --git a/src/test/ui/issues/issue-17758.nll.stderr b/src/test/ui/issues/issue-17758.nll.stderr index 613ef6b907c54..32030540a8456 100644 --- a/src/test/ui/issues/issue-17758.nll.stderr +++ b/src/test/ui/issues/issue-17758.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-17758.rs:7:9 + --> $DIR/issue-17758.rs:11:9 | LL | trait Foo<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-17758.rs b/src/test/ui/issues/issue-17758.rs index d0dbd3455df78..8090022b6d074 100644 --- a/src/test/ui/issues/issue-17758.rs +++ b/src/test/ui/issues/issue-17758.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that regionck suggestions in a provided method of a trait // don't ICE @@ -5,7 +9,8 @@ trait Foo<'a> { fn foo(&'a self); fn bar(&self) { self.foo(); - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/issues/issue-26217.stderr b/src/test/ui/issues/issue-26217.base.stderr similarity index 88% rename from src/test/ui/issues/issue-26217.stderr rename to src/test/ui/issues/issue-26217.base.stderr index f5c641be2d47c..8b1ef806abb4a 100644 --- a/src/test/ui/issues/issue-26217.stderr +++ b/src/test/ui/issues/issue-26217.base.stderr @@ -1,5 +1,5 @@ error[E0477]: the type `&'a i32` does not fulfill the required lifetime - --> $DIR/issue-26217.rs:4:5 + --> $DIR/issue-26217.rs:8:5 | LL | foo::<&'a i32>(); | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-26217.nll.stderr b/src/test/ui/issues/issue-26217.nll.stderr index c7601caacdca3..c8b7d6205577d 100644 --- a/src/test/ui/issues/issue-26217.nll.stderr +++ b/src/test/ui/issues/issue-26217.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-26217.rs:4:5 + --> $DIR/issue-26217.rs:8:5 | LL | fn bar<'a>() { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-26217.rs b/src/test/ui/issues/issue-26217.rs index 05e0462190906..6cc60b05dc623 100644 --- a/src/test/ui/issues/issue-26217.rs +++ b/src/test/ui/issues/issue-26217.rs @@ -1,8 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo() where for<'a> T: 'a {} fn bar<'a>() { foo::<&'a i32>(); - //~^ ERROR the type `&'a i32` does not fulfill the required lifetime + //[base]~^ ERROR the type `&'a i32` does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/issues/issue-40000.stderr b/src/test/ui/issues/issue-40000.base.stderr similarity index 91% rename from src/test/ui/issues/issue-40000.stderr rename to src/test/ui/issues/issue-40000.base.stderr index 00543c5fff400..a8518dde22e66 100644 --- a/src/test/ui/issues/issue-40000.stderr +++ b/src/test/ui/issues/issue-40000.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/issue-40000.rs:10:9 | LL | foo(bar); | ^^^ one type is more general than the other diff --git a/src/test/ui/issues/issue-40000.nll.stderr b/src/test/ui/issues/issue-40000.nll.stderr index e6f0b5fbfba1d..81df9969a4f79 100644 --- a/src/test/ui/issues/issue-40000.nll.stderr +++ b/src/test/ui/issues/issue-40000.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/issue-40000.rs:10:9 | LL | foo(bar); | ^^^ one type is more general than the other @@ -8,7 +8,7 @@ LL | foo(bar); found trait object `dyn Fn(&i32)` error[E0308]: mismatched types - --> $DIR/issue-40000.rs:6:9 + --> $DIR/issue-40000.rs:10:9 | LL | foo(bar); | ^^^ one type is more general than the other diff --git a/src/test/ui/issues/issue-40000.rs b/src/test/ui/issues/issue-40000.rs index 9d5ef481afc37..3639413bfafc2 100644 --- a/src/test/ui/issues/issue-40000.rs +++ b/src/test/ui/issues/issue-40000.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn main() { let bar: fn(&mut u32) = |_| {}; fn foo(x: Box) {} let bar = Box::new(|x: &i32| {}) as Box; - foo(bar); //~ ERROR E0308 + foo(bar); + //~^ ERROR E0308 + //[nll]~^^ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-46983.stderr b/src/test/ui/issues/issue-46983.base.stderr similarity index 93% rename from src/test/ui/issues/issue-46983.stderr rename to src/test/ui/issues/issue-46983.base.stderr index ed9f1884c42fb..97ed4d6509385 100644 --- a/src/test/ui/issues/issue-46983.stderr +++ b/src/test/ui/issues/issue-46983.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-46983.rs:2:5 + --> $DIR/issue-46983.rs:6:5 | LL | fn foo(x: &u32) -> &'static u32 { | ---- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/issues/issue-46983.nll.stderr b/src/test/ui/issues/issue-46983.nll.stderr index 38a219bbd7b52..1327ff80c8012 100644 --- a/src/test/ui/issues/issue-46983.nll.stderr +++ b/src/test/ui/issues/issue-46983.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-46983.rs:2:5 + --> $DIR/issue-46983.rs:6:5 | LL | fn foo(x: &u32) -> &'static u32 { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/issues/issue-46983.rs b/src/test/ui/issues/issue-46983.rs index 87ed892894479..e3ecdc8deac45 100644 --- a/src/test/ui/issues/issue-46983.rs +++ b/src/test/ui/issues/issue-46983.rs @@ -1,6 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x: &u32) -> &'static u32 { &*x - //~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/issues/issue-52533.stderr b/src/test/ui/issues/issue-52533.base.stderr similarity index 84% rename from src/test/ui/issues/issue-52533.stderr rename to src/test/ui/issues/issue-52533.base.stderr index ccedbcfec7a28..6556a52de14f2 100644 --- a/src/test/ui/issues/issue-52533.stderr +++ b/src/test/ui/issues/issue-52533.base.stderr @@ -1,16 +1,16 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/issue-52533.rs:5:16 + --> $DIR/issue-52533.rs:9:16 | LL | foo(|a, b| b) | ^ | note: ...the reference is valid for the anonymous lifetime #1 defined here... - --> $DIR/issue-52533.rs:5:9 + --> $DIR/issue-52533.rs:9:9 | LL | foo(|a, b| b) | ^^^^^^^^ note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined here - --> $DIR/issue-52533.rs:5:9 + --> $DIR/issue-52533.rs:9:9 | LL | foo(|a, b| b) | ^^^^^^^^ diff --git a/src/test/ui/issues/issue-52533.nll.stderr b/src/test/ui/issues/issue-52533.nll.stderr index c764736d79878..75fe5a5b862bb 100644 --- a/src/test/ui/issues/issue-52533.nll.stderr +++ b/src/test/ui/issues/issue-52533.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-52533.rs:5:16 + --> $DIR/issue-52533.rs:9:16 | LL | foo(|a, b| b) | - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` diff --git a/src/test/ui/issues/issue-52533.rs b/src/test/ui/issues/issue-52533.rs index a35f5a80a87fe..bc6264d0e2fc9 100644 --- a/src/test/ui/issues/issue-52533.rs +++ b/src/test/ui/issues/issue-52533.rs @@ -1,7 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(_: impl for<'a> FnOnce(&'a u32, &u32) -> &'a u32) { } fn main() { foo(|a, b| b) - //~^ ERROR lifetime of reference outlives lifetime of borrowed content... + //[base]~^ ERROR lifetime of reference outlives lifetime of borrowed content... + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/issues/issue-54302-cases.stderr b/src/test/ui/issues/issue-54302-cases.base.stderr similarity index 91% rename from src/test/ui/issues/issue-54302-cases.stderr rename to src/test/ui/issues/issue-54302-cases.base.stderr index baa75f28d37f3..db91edf51e337 100644 --- a/src/test/ui/issues/issue-54302-cases.stderr +++ b/src/test/ui/issues/issue-54302-cases.base.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:63:5 + --> $DIR/issue-54302-cases.rs:67:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | >::ref_foo(a) = note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:69:5 + --> $DIR/issue-54302-cases.rs:73:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -17,7 +17,7 @@ LL | >::ref_foo(a) = note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:75:5 + --> $DIR/issue-54302-cases.rs:79:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -26,7 +26,7 @@ LL | >::ref_foo(a) = note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:81:5 + --> $DIR/issue-54302-cases.rs:85:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/issues/issue-54302-cases.nll.stderr b/src/test/ui/issues/issue-54302-cases.nll.stderr index 6e8b69c4beebb..89725d3b03ac2 100644 --- a/src/test/ui/issues/issue-54302-cases.nll.stderr +++ b/src/test/ui/issues/issue-54302-cases.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:63:5 + --> $DIR/issue-54302-cases.rs:67:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -8,7 +8,7 @@ LL | >::ref_foo(a) = note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:69:5 + --> $DIR/issue-54302-cases.rs:73:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -17,7 +17,7 @@ LL | >::ref_foo(a) = note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:75:5 + --> $DIR/issue-54302-cases.rs:79:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough @@ -26,7 +26,7 @@ LL | >::ref_foo(a) = note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1` error: implementation of `Foo` is not general enough - --> $DIR/issue-54302-cases.rs:81:5 + --> $DIR/issue-54302-cases.rs:85:5 | LL | >::ref_foo(a) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough diff --git a/src/test/ui/issues/issue-54302-cases.rs b/src/test/ui/issues/issue-54302-cases.rs index faa116269ee96..f712d9b7718c5 100644 --- a/src/test/ui/issues/issue-54302-cases.rs +++ b/src/test/ui/issues/issue-54302-cases.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Mirror { type Image; fn coerce(self) -> Self::Image; diff --git a/src/test/ui/issues/issue-54943.stderr b/src/test/ui/issues/issue-54943.base.stderr similarity index 86% rename from src/test/ui/issues/issue-54943.stderr rename to src/test/ui/issues/issue-54943.base.stderr index e917958c05e40..ebd679996d052 100644 --- a/src/test/ui/issues/issue-54943.stderr +++ b/src/test/ui/issues/issue-54943.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'a u32` does not fulfill the required lifetime - --> $DIR/issue-54943.rs:6:13 + --> $DIR/issue-54943.rs:10:13 | LL | let x = foo::<&'a u32>(); | ^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/issue-54943.rs:1:11 + --> $DIR/issue-54943.rs:5:11 | LL | fn foo() { } | ^^^^^^^ diff --git a/src/test/ui/issues/issue-54943.nll.stderr b/src/test/ui/issues/issue-54943.nll.stderr index 59be0f983b907..2c86a5a3390cd 100644 --- a/src/test/ui/issues/issue-54943.nll.stderr +++ b/src/test/ui/issues/issue-54943.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-54943.rs:6:13 + --> $DIR/issue-54943.rs:10:13 | LL | fn boo<'a>() { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-54943.rs b/src/test/ui/issues/issue-54943.rs index 85722300bf006..ad463e7a466f2 100644 --- a/src/test/ui/issues/issue-54943.rs +++ b/src/test/ui/issues/issue-54943.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo() { } fn boo<'a>() { diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.base.stderr similarity index 94% rename from src/test/ui/issues/issue-55731.stderr rename to src/test/ui/issues/issue-55731.base.stderr index de327cd3cc23c..26b1c9ec4689a 100644 --- a/src/test/ui/issues/issue-55731.stderr +++ b/src/test/ui/issues/issue-55731.base.stderr @@ -1,5 +1,5 @@ error: implementation of `DistributedIteratorMulti` is not general enough - --> $DIR/issue-55731.rs:48:5 + --> $DIR/issue-55731.rs:52:5 | LL | multi(Map { | ^^^^^ implementation of `DistributedIteratorMulti` is not general enough diff --git a/src/test/ui/issues/issue-55731.nll.stderr b/src/test/ui/issues/issue-55731.nll.stderr index 97fd6678c997e..168a2cbccd7cb 100644 --- a/src/test/ui/issues/issue-55731.nll.stderr +++ b/src/test/ui/issues/issue-55731.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `DistributedIteratorMulti` is not general enough - --> $DIR/issue-55731.rs:48:5 + --> $DIR/issue-55731.rs:52:5 | LL | / multi(Map { LL | | i: Cloned(PhantomData), diff --git a/src/test/ui/issues/issue-55731.rs b/src/test/ui/issues/issue-55731.rs index 7b4f4e2cd3b40..c6a0ee12589df 100644 --- a/src/test/ui/issues/issue-55731.rs +++ b/src/test/ui/issues/issue-55731.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker::PhantomData; trait DistributedIterator { diff --git a/src/test/ui/issues/issue-55796.stderr b/src/test/ui/issues/issue-55796.base.stderr similarity index 84% rename from src/test/ui/issues/issue-55796.stderr rename to src/test/ui/issues/issue-55796.base.stderr index 569a13f45bce8..a4c5d68472ded 100644 --- a/src/test/ui/issues/issue-55796.stderr +++ b/src/test/ui/issues/issue-55796.base.stderr @@ -1,22 +1,22 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:20:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-55796.rs:5:17 + --> $DIR/issue-55796.rs:9:17 | LL | pub trait Graph<'a> { | ^^ -note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:16:40: 16:54]>` will meet its required lifetime bounds - --> $DIR/issue-55796.rs:16:9 +note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:20:40: 20:54]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:20:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:20:9 | LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,24 +24,24 @@ LL | Box::new(self.out_edges(u).map(|e| e.target())) found `Box>::Node>>` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:26:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-55796.rs:5:17 + --> $DIR/issue-55796.rs:9:17 | LL | pub trait Graph<'a> { | ^^ -note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:21:39: 21:53]>` will meet its required lifetime bounds - --> $DIR/issue-55796.rs:21:9 +note: ...so that the type `Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:26:39: 26:53]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:26:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:26:9 | LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-55796.nll.stderr b/src/test/ui/issues/issue-55796.nll.stderr index 5809a56cd4b6b..2b7d231871a04 100644 --- a/src/test/ui/issues/issue-55796.nll.stderr +++ b/src/test/ui/issues/issue-55796.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-55796.rs:16:9 + --> $DIR/issue-55796.rs:20:9 | LL | pub trait Graph<'a> { | -- lifetime `'a` defined here @@ -8,7 +8,7 @@ LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/issue-55796.rs:21:9 + --> $DIR/issue-55796.rs:26:9 | LL | pub trait Graph<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index d802ce3b6cfbf..a0bc63dd2a731 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait EdgeTrait { fn target(&self) -> N; } @@ -14,12 +18,14 @@ pub trait Graph<'a> { fn out_neighbors(&'a self, u: &Self::Node) -> Box> { Box::new(self.out_edges(u).map(|e| e.target())) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn in_neighbors(&'a self, u: &Self::Node) -> Box> { Box::new(self.in_edges(u).map(|e| e.target())) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/issues/issue-75777.stderr b/src/test/ui/issues/issue-75777.base.stderr similarity index 89% rename from src/test/ui/issues/issue-75777.stderr rename to src/test/ui/issues/issue-75777.base.stderr index f440d7d193215..d2c6738cb590f 100644 --- a/src/test/ui/issues/issue-75777.stderr +++ b/src/test/ui/issues/issue-75777.base.stderr @@ -1,16 +1,16 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-75777.rs:11:14 + --> $DIR/issue-75777.rs:15:14 | LL | Box::new(move |_| fut) | ^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-75777.rs:9:11 + --> $DIR/issue-75777.rs:13:11 | LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box BoxFuture<'a, A>> { | ^^ note: ...so that the types are compatible - --> $DIR/issue-75777.rs:11:14 + --> $DIR/issue-75777.rs:15:14 | LL | Box::new(move |_| fut) | ^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | Box::new(move |_| fut) found `(Pin + Send + 'a)>>,)` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible - --> $DIR/issue-75777.rs:11:5 + --> $DIR/issue-75777.rs:15:5 | LL | Box::new(move |_| fut) | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-75777.nll.stderr b/src/test/ui/issues/issue-75777.nll.stderr index 370cd72fd558d..d1f8d3886763d 100644 --- a/src/test/ui/issues/issue-75777.nll.stderr +++ b/src/test/ui/issues/issue-75777.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-75777.rs:11:5 + --> $DIR/issue-75777.rs:15:5 | LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box BoxFuture<'a, A>> { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-75777.rs b/src/test/ui/issues/issue-75777.rs index 357c07c7cec91..930cd7ad37ba2 100644 --- a/src/test/ui/issues/issue-75777.rs +++ b/src/test/ui/issues/issue-75777.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #75777. // Checks that a boxed future can be properly constructed. @@ -9,7 +13,8 @@ type BoxFuture<'a, T> = Pin + 'a + Send>>; fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box BoxFuture<'a, A>> { let fut: BoxFuture<'a, A> = Box::pin(future::ready(v)); Box::new(move |_| fut) - //~^ ERROR: cannot infer an appropriate lifetime + //[base]~^ ERROR: cannot infer an appropriate lifetime + //[nll]~^^ ERROR: lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.base.stderr similarity index 87% rename from src/test/ui/kindck/kindck-impl-type-params.stderr rename to src/test/ui/kindck/kindck-impl-type-params.base.stderr index f227ac2477e6c..2fa8993b71afe 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.base.stderr @@ -1,11 +1,11 @@ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -16,13 +16,13 @@ LL | fn f(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -33,13 +33,13 @@ LL | fn f(val: T) { | +++++++++++++++++++ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable = &t; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -50,13 +50,13 @@ LL | fn g(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable = &t; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -67,7 +67,7 @@ LL | fn g(val: T) { | +++++++++++++++++++ error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/kindck-impl-type-params.rs:32:13 + --> $DIR/kindck-impl-type-params.rs:34:13 | LL | let a = &t as &dyn Gettable<&'a isize>; | ^^ @@ -75,28 +75,28 @@ LL | let a = &t as &dyn Gettable<&'a isize>; = note: type must satisfy the static lifetime error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:38:13 + --> $DIR/kindck-impl-type-params.rs:40:13 | LL | let a = t as Box>; | ^ the trait `Copy` is not implemented for `String` | = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `Foo: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:37 + --> $DIR/kindck-impl-type-params.rs:48:37 | LL | let a: Box> = t; | ^ the trait `Copy` is not implemented for `Foo` | = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index 1772d353fe427..c6f5e17fb6971 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -1,11 +1,11 @@ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -16,13 +16,13 @@ LL | fn f(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:18:13 + --> $DIR/kindck-impl-type-params.rs:20:13 | LL | let a = &t as &dyn Gettable; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -33,13 +33,13 @@ LL | fn f(val: T) { | +++++++++++++++++++ error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable = &t; | ^^ `T` cannot be sent between threads safely | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -50,13 +50,13 @@ LL | fn g(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:31 + --> $DIR/kindck-impl-type-params.rs:27:31 | LL | let a: &dyn Gettable = &t; | ^^ the trait `Copy` is not implemented for `T` | note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ @@ -67,28 +67,28 @@ LL | fn g(val: T) { | +++++++++++++++++++ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:38:13 + --> $DIR/kindck-impl-type-params.rs:40:13 | LL | let a = t as Box>; | ^ the trait `Copy` is not implemented for `String` | = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ = note: required for the cast to the object type `dyn Gettable` error[E0277]: the trait bound `Foo: Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:37 + --> $DIR/kindck-impl-type-params.rs:48:37 | LL | let a: Box> = t; | ^ the trait `Copy` is not implemented for `Foo` | = help: the trait `Gettable` is implemented for `S` note: required because of the requirements on the impl of `Gettable` for `S` - --> $DIR/kindck-impl-type-params.rs:14:32 + --> $DIR/kindck-impl-type-params.rs:16:32 | LL | impl Gettable for S {} | ^^^^^^^^^^^ ^^^^ diff --git a/src/test/ui/kindck/kindck-impl-type-params.rs b/src/test/ui/kindck/kindck-impl-type-params.rs index 5622d65cb175b..1a56387258579 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.rs +++ b/src/test/ui/kindck/kindck-impl-type-params.rs @@ -1,8 +1,10 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Issue #14061: tests the interaction between generic implementation // parameter bounds and trait objects. - - use std::marker; struct S(marker::PhantomData); @@ -30,7 +32,7 @@ fn g(val: T) { fn foo<'a>() { let t: S<&'a isize> = S(marker::PhantomData); let a = &t as &dyn Gettable<&'a isize>; - //~^ ERROR does not fulfill + //[base]~^ ERROR does not fulfill } fn foo2<'a>() { diff --git a/src/test/ui/kindck/kindck-send-object1.stderr b/src/test/ui/kindck/kindck-send-object1.base.stderr similarity index 89% rename from src/test/ui/kindck/kindck-send-object1.stderr rename to src/test/ui/kindck/kindck-send-object1.base.stderr index 58397b7f597f6..5976c7119c7e6 100644 --- a/src/test/ui/kindck/kindck-send-object1.stderr +++ b/src/test/ui/kindck/kindck-send-object1.base.stderr @@ -1,5 +1,5 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely - --> $DIR/kindck-send-object1.rs:10:5 + --> $DIR/kindck-send-object1.rs:14:5 | LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -7,25 +7,25 @@ LL | assert_send::<&'a dyn Dummy>(); = help: the trait `Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `Send` for `&'a (dyn Dummy + 'a)` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send() { } | ^^^^ required by this bound in `assert_send` error[E0477]: the type `&'a (dyn Dummy + Sync + 'a)` does not fulfill the required lifetime - --> $DIR/kindck-send-object1.rs:14:5 + --> $DIR/kindck-send-object1.rs:18:5 | LL | assert_send::<&'a (dyn Dummy + Sync)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/kindck-send-object1.rs:5:23 + --> $DIR/kindck-send-object1.rs:9:23 | LL | fn assert_send() { } | ^^^^^^^ error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely - --> $DIR/kindck-send-object1.rs:29:5 + --> $DIR/kindck-send-object1.rs:33:5 | LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely @@ -34,7 +34,7 @@ LL | assert_send::>(); = note: required because of the requirements on the impl of `Send` for `Unique<(dyn Dummy + 'a)>` = note: required because it appears within the type `Box<(dyn Dummy + 'a)>` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send() { } | ^^^^ required by this bound in `assert_send` diff --git a/src/test/ui/kindck/kindck-send-object1.nll.stderr b/src/test/ui/kindck/kindck-send-object1.nll.stderr index fa190449b6438..f34374dcc542d 100644 --- a/src/test/ui/kindck/kindck-send-object1.nll.stderr +++ b/src/test/ui/kindck/kindck-send-object1.nll.stderr @@ -1,5 +1,5 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely - --> $DIR/kindck-send-object1.rs:10:5 + --> $DIR/kindck-send-object1.rs:14:5 | LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -7,13 +7,13 @@ LL | assert_send::<&'a dyn Dummy>(); = help: the trait `Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `Send` for `&'a (dyn Dummy + 'a)` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send() { } | ^^^^ required by this bound in `assert_send` error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely - --> $DIR/kindck-send-object1.rs:29:5 + --> $DIR/kindck-send-object1.rs:33:5 | LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely @@ -22,7 +22,7 @@ LL | assert_send::>(); = note: required because of the requirements on the impl of `Send` for `Unique<(dyn Dummy + 'a)>` = note: required because it appears within the type `Box<(dyn Dummy + 'a)>` note: required by a bound in `assert_send` - --> $DIR/kindck-send-object1.rs:5:18 + --> $DIR/kindck-send-object1.rs:9:18 | LL | fn assert_send() { } | ^^^^ required by this bound in `assert_send` diff --git a/src/test/ui/kindck/kindck-send-object1.rs b/src/test/ui/kindck/kindck-send-object1.rs index 0e198395c26fb..26894dc2ce4a6 100644 --- a/src/test/ui/kindck/kindck-send-object1.rs +++ b/src/test/ui/kindck/kindck-send-object1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test which object types are considered sendable. This test // is broken into two parts because some errors occur in distinct // phases in the compiler. See kindck-send-object2.rs as well! @@ -12,7 +16,7 @@ fn test51<'a>() { } fn test52<'a>() { assert_send::<&'a (dyn Dummy + Sync)>(); - //~^ ERROR does not fulfill the required lifetime + //[base]~^ ERROR does not fulfill the required lifetime } // ...unless they are properly bounded diff --git a/src/test/ui/lifetimes/issue-79187-2.stderr b/src/test/ui/lifetimes/issue-79187-2.base.stderr similarity index 83% rename from src/test/ui/lifetimes/issue-79187-2.stderr rename to src/test/ui/lifetimes/issue-79187-2.base.stderr index 2aca8faff9f2c..95591412f7eab 100644 --- a/src/test/ui/lifetimes/issue-79187-2.stderr +++ b/src/test/ui/lifetimes/issue-79187-2.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:8:5 + --> $DIR/issue-79187-2.rs:12:5 | LL | take_foo(|a| a); | ^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | take_foo(|a| a); = note: expected type `for<'r> Fn<(&'r i32,)>` found type `Fn<(&i32,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-79187-2.rs:8:14 + --> $DIR/issue-79187-2.rs:12:14 | LL | take_foo(|a| a); | ^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:9:5 + --> $DIR/issue-79187-2.rs:16:5 | LL | take_foo(|a: &i32| a); | ^^^^^^^^ lifetime mismatch @@ -26,18 +26,18 @@ LL | take_foo(|a: &i32| a); = note: expected reference `&i32` found reference `&i32` note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements - --> $DIR/issue-79187-2.rs:9:14 + --> $DIR/issue-79187-2.rs:16:14 | LL | take_foo(|a: &i32| a); | ^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:10:5 + --> $DIR/issue-79187-2.rs:20:5 | LL | take_foo(|a: &i32| -> &i32 { a }); | ^^^^^^^^ lifetime mismatch @@ -45,12 +45,12 @@ LL | take_foo(|a: &i32| -> &i32 { a }); = note: expected reference `&i32` found reference `&i32` note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements - --> $DIR/issue-79187-2.rs:10:14 + --> $DIR/issue-79187-2.rs:20:14 | LL | take_foo(|a: &i32| -> &i32 { a }); | ^^^^^^^^^^^^^^^^^^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ diff --git a/src/test/ui/lifetimes/issue-79187-2.nll.stderr b/src/test/ui/lifetimes/issue-79187-2.nll.stderr index 04d9b64d64fdd..3cbce7600f956 100644 --- a/src/test/ui/lifetimes/issue-79187-2.nll.stderr +++ b/src/test/ui/lifetimes/issue-79187-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-79187-2.rs:9:24 + --> $DIR/issue-79187-2.rs:16:24 | LL | take_foo(|a: &i32| a); | - - ^ returning this value requires that `'1` must outlive `'2` @@ -8,7 +8,7 @@ LL | take_foo(|a: &i32| a); | let's call the lifetime of this reference `'1` error: lifetime may not live long enough - --> $DIR/issue-79187-2.rs:10:34 + --> $DIR/issue-79187-2.rs:20:34 | LL | take_foo(|a: &i32| -> &i32 { a }); | - - ^ returning this value requires that `'1` must outlive `'2` @@ -17,7 +17,7 @@ LL | take_foo(|a: &i32| -> &i32 { a }); | let's call the lifetime of this reference `'1` error: implementation of `FnOnce` is not general enough - --> $DIR/issue-79187-2.rs:8:5 + --> $DIR/issue-79187-2.rs:12:5 | LL | take_foo(|a| a); | ^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough @@ -26,7 +26,7 @@ LL | take_foo(|a| a); = note: ...but it actually implements `FnOnce<(&'2 i32,)>`, for some specific lifetime `'2` error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:8:5 + --> $DIR/issue-79187-2.rs:12:5 | LL | take_foo(|a| a); | ^^^^^^^^^^^^^^^ one type is more general than the other @@ -34,18 +34,18 @@ LL | take_foo(|a| a); = note: expected type `for<'r> Fn<(&'r i32,)>` found type `Fn<(&i32,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-79187-2.rs:8:14 + --> $DIR/issue-79187-2.rs:12:14 | LL | take_foo(|a| a); | ^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:9:5 + --> $DIR/issue-79187-2.rs:16:5 | LL | take_foo(|a: &i32| a); | ^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -53,13 +53,13 @@ LL | take_foo(|a: &i32| a); = note: expected reference `&i32` found reference `&i32` note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ error[E0308]: mismatched types - --> $DIR/issue-79187-2.rs:10:5 + --> $DIR/issue-79187-2.rs:20:5 | LL | take_foo(|a: &i32| -> &i32 { a }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -67,7 +67,7 @@ LL | take_foo(|a: &i32| -> &i32 { a }); = note: expected reference `&i32` found reference `&i32` note: the lifetime requirement is introduced here - --> $DIR/issue-79187-2.rs:5:21 + --> $DIR/issue-79187-2.rs:9:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ diff --git a/src/test/ui/lifetimes/issue-79187-2.rs b/src/test/ui/lifetimes/issue-79187-2.rs index 29d108facab3f..d122b92f74b23 100644 --- a/src/test/ui/lifetimes/issue-79187-2.rs +++ b/src/test/ui/lifetimes/issue-79187-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl Foo for F where F: Fn(&i32) -> &i32 {} @@ -5,9 +9,18 @@ impl Foo for F where F: Fn(&i32) -> &i32 {} fn take_foo(_: impl Foo) {} fn main() { - take_foo(|a| a); //~ ERROR mismatched types - take_foo(|a: &i32| a); //~ ERROR mismatched types - take_foo(|a: &i32| -> &i32 { a }); //~ ERROR mismatched types + take_foo(|a| a); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR implementation of `FnOnce` is not general enough + //[nll]~| ERROR mismatched types + take_foo(|a: &i32| a); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR mismatched types + take_foo(|a: &i32| -> &i32 { a }); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR mismatched types // OK take_foo(identity(|a| a)); diff --git a/src/test/ui/lifetimes/issue-79187.stderr b/src/test/ui/lifetimes/issue-79187.base.stderr similarity index 92% rename from src/test/ui/lifetimes/issue-79187.stderr rename to src/test/ui/lifetimes/issue-79187.base.stderr index 3c0439fb660e5..c4654ca1517ed 100644 --- a/src/test/ui/lifetimes/issue-79187.stderr +++ b/src/test/ui/lifetimes/issue-79187.base.stderr @@ -1,5 +1,5 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/issue-79187.rs:5:5 + --> $DIR/issue-79187.rs:9:5 | LL | thing(f); | ^^^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/issue-79187.nll.stderr b/src/test/ui/lifetimes/issue-79187.nll.stderr index 3a993e88d8a92..54dce9b4bacf0 100644 --- a/src/test/ui/lifetimes/issue-79187.nll.stderr +++ b/src/test/ui/lifetimes/issue-79187.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-79187.rs:5:5 + --> $DIR/issue-79187.rs:9:5 | LL | thing(f); | ^^^^^^^^ one type is more general than the other @@ -7,18 +7,18 @@ LL | thing(f); = note: expected type `for<'r> FnOnce<(&'r u32,)>` found type `FnOnce<(&u32,)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-79187.rs:4:13 + --> $DIR/issue-79187.rs:8:13 | LL | let f = |_| (); | ^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/issue-79187.rs:1:18 + --> $DIR/issue-79187.rs:5:18 | LL | fn thing(x: impl FnOnce(&u32)) {} | ^^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/issue-79187.rs:5:5 + --> $DIR/issue-79187.rs:9:5 | LL | thing(f); | ^^^^^^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/issue-79187.rs b/src/test/ui/lifetimes/issue-79187.rs index 2ee69ee2234ee..b97890d94e97a 100644 --- a/src/test/ui/lifetimes/issue-79187.rs +++ b/src/test/ui/lifetimes/issue-79187.rs @@ -1,6 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn thing(x: impl FnOnce(&u32)) {} fn main() { let f = |_| (); - thing(f); //~ERROR implementation of `FnOnce` is not general enough + thing(f); + //[nll]~^ ERROR mismatched types + //~^^ ERROR implementation of `FnOnce` is not general enough } diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed new file mode 100644 index 0000000000000..4b417afb03836 --- /dev/null +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed @@ -0,0 +1,15 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `issue-90170-elision-mismatch.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs new file mode 100644 index 0000000000000..ec50e8e1d9ac5 --- /dev/null +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs @@ -0,0 +1,15 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `issue-90170-elision-mismatch.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.stderr similarity index 92% rename from src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr rename to src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.stderr index 48fb3fb4a2293..144fe3bf9dabf 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-90170-elision-mismatch.rs:3:40 + --> $DIR/issue-90170-elision-mismatch-nll.rs:9:40 | LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/issue-90170-elision-mismatch.rs:5:44 + --> $DIR/issue-90170-elision-mismatch-nll.rs:11:44 | LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ~~ ++ error: lifetime may not live long enough - --> $DIR/issue-90170-elision-mismatch.rs:7:63 + --> $DIR/issue-90170-elision-mismatch-nll.rs:13:63 | LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed b/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed index 0bc889ee721dc..f05943284f7c8 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `issue-90170-elision-mismatch-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs b/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs index 1d6573c00ad4f..fee2b461ef9aa 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `issue-90170-elision-mismatch-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr b/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr index 7fa092ca220c2..28f3957041c1e 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-90170-elision-mismatch.rs:3:47 + --> $DIR/issue-90170-elision-mismatch.rs:8:47 | LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } | --- --- ^ ...but data from `y` flows into `x` here @@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ++ ++ error[E0623]: lifetime mismatch - --> $DIR/issue-90170-elision-mismatch.rs:5:51 + --> $DIR/issue-90170-elision-mismatch.rs:10:51 | LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } | ------ --- ^ ...but data from `y` flows into `x` here @@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++++ ~~ ++ error[E0623]: lifetime mismatch - --> $DIR/issue-90170-elision-mismatch.rs:7:70 + --> $DIR/issue-90170-elision-mismatch.rs:12:70 | LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | --- --- ^ ...but data from `y` flows into `x` here diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.base.stderr similarity index 89% rename from src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr rename to src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.base.stderr index e06255e4ea3ff..b20ce7b07ff32 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/issue-90600-expected-return-static-indirect.rs:7:32 + --> $DIR/issue-90600-expected-return-static-indirect.rs:11:32 | LL | fn inner(mut foo: &[u8]) { | ----- this data with an anonymous lifetime `'_`... diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr index 99e1e7217b45c..b35505ac8c54f 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.nll.stderr @@ -1,9 +1,9 @@ error[E0597]: `foo` does not live long enough - --> $DIR/issue-90600-expected-return-static-indirect.rs:7:32 + --> $DIR/issue-90600-expected-return-static-indirect.rs:11:32 | LL | let refcell = RefCell::new(&mut foo); | ^^^^^^^^ borrowed value does not live long enough -LL | +... LL | let read = &refcell as &RefCell; | -------- cast requires that `foo` is borrowed for `'static` ... @@ -11,7 +11,7 @@ LL | } | - `foo` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/issue-90600-expected-return-static-indirect.rs:9:16 + --> $DIR/issue-90600-expected-return-static-indirect.rs:14:16 | LL | fn inner(mut foo: &[u8]) { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs index 39996bbf43b3c..fa44be9a912ad 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::cell::RefCell; use std::io::Read; @@ -5,8 +9,10 @@ fn main() {} fn inner(mut foo: &[u8]) { let refcell = RefCell::new(&mut foo); - //~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[base]~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR `foo` does not live long enough let read = &refcell as &RefCell; + //[nll]~^ ERROR lifetime may not live long enough read_thing(read); } diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.base.stderr similarity index 80% rename from src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr rename to src/test/ui/lifetimes/lifetime-bound-will-change-warning.base.stderr index bb691fc072b5a..54fa49b47f680 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/lifetime-bound-will-change-warning.rs:34:13 + --> $DIR/lifetime-bound-will-change-warning.rs:38:13 | LL | ref_obj(x) | ^ lifetime mismatch @@ -7,14 +7,14 @@ LL | ref_obj(x) = note: expected reference `&Box<(dyn Fn() + 'static)>` found reference `&Box<(dyn Fn() + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/lifetime-bound-will-change-warning.rs:32:10 + --> $DIR/lifetime-bound-will-change-warning.rs:36:10 | LL | fn test2<'a>(x: &'a Box) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/lifetime-bound-will-change-warning.rs:39:18 + --> $DIR/lifetime-bound-will-change-warning.rs:45:18 | LL | lib::ref_obj(x) | ^ lifetime mismatch @@ -22,7 +22,7 @@ LL | lib::ref_obj(x) = note: expected reference `&Box<(dyn Fn() + 'static)>` found reference `&Box<(dyn Fn() + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/lifetime-bound-will-change-warning.rs:37:12 + --> $DIR/lifetime-bound-will-change-warning.rs:43:12 | LL | fn test2cc<'a>(x: &'a Box) { | ^^ diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr index 6f3f84096e400..10105c5ccecbb 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/lifetime-bound-will-change-warning.rs:34:5 + --> $DIR/lifetime-bound-will-change-warning.rs:38:5 | LL | fn test2<'a>(x: &'a Box) { | -- - `x` is a reference that is only valid in the function body @@ -13,7 +13,7 @@ LL | ref_obj(x) | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/lifetime-bound-will-change-warning.rs:39:5 + --> $DIR/lifetime-bound-will-change-warning.rs:45:5 | LL | fn test2cc<'a>(x: &'a Box) { | -- - `x` is a reference that is only valid in the function body diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs index 3c6d92234c4fa..0a082e1bae8bf 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // aux-build:lifetime_bound_will_change_warning_lib.rs // Test that various corner cases cause an error. These are tests @@ -31,12 +35,16 @@ fn test1cc<'a>(x: &'a Box) { fn test2<'a>(x: &'a Box) { // but ref_obj will not, so warn. - ref_obj(x) //~ ERROR mismatched types + ref_obj(x) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes } fn test2cc<'a>(x: &'a Box) { // same as test2, but cross crate - lib::ref_obj(x) //~ ERROR mismatched types + lib::ref_obj(x) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes } fn test3<'a>(x: &'a Box) { diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.base.stderr similarity index 88% rename from src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.base.stderr index e9f5fc311dfc2..60cd34938750a 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:11:20 + --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:15:20 | LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { | ---- ------- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr index 4c78821157670..f8e275e9b14c8 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:11:20 + --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:15:20 | LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { | -- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs index 12024bd10800b..fbb523daa1f51 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32; @@ -8,7 +12,9 @@ impl Foo for () { fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { - if x > y { x } else { y } //~ ERROR lifetime mismatch + if x > y { x } else { y } + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.base.stderr similarity index 86% rename from src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.base.stderr index 0d506f2b9fcb4..697950a00fb24 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5 + --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:12:5 | LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { | ------- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr index 11e7fa96d7ee9..97af4b58cbf65 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5 + --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:12:5 | LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { | -- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs index ef5dd1160fb34..704db7dc8b405 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32 } @@ -5,7 +9,9 @@ struct Foo { impl Foo { fn foo<'a>(&self, x: &'a i32) -> &i32 { - x //~ ERROR lifetime mismatch + x + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.base.stderr similarity index 88% rename from src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.base.stderr index 98a23613c3635..65644d03cdc1b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:8:30 + --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:12:30 | LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | ----- ------- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr index c41f08e691ac2..00a348de4bc30 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:8:30 + --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:12:30 | LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | -- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs index 597d20dbacd43..a846c115c0638 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32, } @@ -5,7 +9,9 @@ struct Foo { impl Foo { fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { - if true { x } else { self } //~ ERROR lifetime mismatch + if true { x } else { self } + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.base.stderr similarity index 88% rename from src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.base.stderr index 412cac4356368..9203d6603bd7a 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/ex2a-push-one-existing-name-2.rs:6:12 + --> $DIR/ex2a-push-one-existing-name-2.rs:10:12 | LL | fn foo<'a>(x: Ref, y: &mut Vec>) { | -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr index 90d4754ebab82..5ab8b449816cc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/ex2a-push-one-existing-name-2.rs:6:5 + --> $DIR/ex2a-push-one-existing-name-2.rs:10:5 | LL | fn foo<'a>(x: Ref, y: &mut Vec>) { | -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs index 998a48ce20c26..7e776baa6a91d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.base.stderr similarity index 86% rename from src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.base.stderr index 30826c3613c58..ec1ab19d5a43c 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:12 + --> $DIR/ex2a-push-one-existing-name-early-bound.rs:12:12 | LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr index a03e16b3b7919..bd5864bae3202 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:5 + --> $DIR/ex2a-push-one-existing-name-early-bound.rs:12:5 | LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs index d18b50d0d0cd7..73613a9bf3507 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo<'a> {} impl<'a, T> Foo<'a> for T {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.base.stderr similarity index 89% rename from src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.base.stderr index 13d0835287d04..ab0e202a32eff 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.base.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name.rs:6:12 + --> $DIR/ex2a-push-one-existing-name.rs:10:12 | LL | fn foo<'a>(x: &mut Vec>, y: Ref) { | -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr index 487b34e3d18f4..01b7f45d81b58 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name.rs:6:5 + --> $DIR/ex2a-push-one-existing-name.rs:10:5 | LL | fn foo<'a>(x: &mut Vec>, y: Ref) { | -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs index 5188ea1cc9cb0..5773e13304c15 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.base.stderr similarity index 88% rename from src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.base.stderr index e505c9c0dc262..58a2088df5e77 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2b-push-no-existing-names.rs:6:12 + --> $DIR/ex2b-push-no-existing-names.rs:10:12 | LL | fn foo(x: &mut Vec>, y: Ref) { | -------- -------- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr index 1622ce4229052..afe413bcca5cc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2b-push-no-existing-names.rs:6:5 + --> $DIR/ex2b-push-no-existing-names.rs:10:5 | LL | fn foo(x: &mut Vec>, y: Ref) { | - - has type `Ref<'1, i32>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs index 82e0c9bc26e89..8d830343b08be 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo(x: &mut Vec>, y: Ref) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.base.stderr similarity index 90% rename from src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.base.stderr index 63b1c6db28f14..63033b8d16e8b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2c-push-inference-variable.rs:7:12 + --> $DIR/ex2c-push-inference-variable.rs:11:12 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { | ------------ ------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr index 99fab4631a216..63a0f2409d9b4 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2c-push-inference-variable.rs:7:5 + --> $DIR/ex2c-push-inference-variable.rs:11:5 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs index 7f15aee5f08e4..f676eb403a8aa 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { let z = Ref { data: y.data }; - x.push(z); //~ ERROR lifetime mismatch + x.push(z); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.base.stderr similarity index 90% rename from src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.base.stderr index 2f669efcf1eb4..a50985ca704c7 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2d-push-inference-variable-2.rs:6:33 + --> $DIR/ex2d-push-inference-variable-2.rs:10:33 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { | ------------ ------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr index 52c5752f6ea1e..0d7461fa68262 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2d-push-inference-variable-2.rs:8:5 + --> $DIR/ex2d-push-inference-variable-2.rs:13:5 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs index ee77d9e7fde1a..e65638fb0df13 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.rs @@ -1,11 +1,17 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { - let a: &mut Vec> = x; //~ ERROR lifetime mismatch + let a: &mut Vec> = x; + //[base]~^ ERROR lifetime mismatch let b = Ref { data: y.data }; a.push(b); + //[nll]~^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.base.stderr similarity index 90% rename from src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.base.stderr index 258b6805acd5c..dbe965a340c40 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex2e-push-inference-variable-3.rs:6:33 + --> $DIR/ex2e-push-inference-variable-3.rs:10:33 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { | ------------ ------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr index e90c81ee3e1af..74b2739b2c3fb 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex2e-push-inference-variable-3.rs:8:5 + --> $DIR/ex2e-push-inference-variable-3.rs:13:5 | LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs index e2a795a071ced..036afe09be6ef 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.rs @@ -1,11 +1,17 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, T: 'a> { data: &'a T } fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { - let a: &mut Vec> = x; //~ ERROR lifetime mismatch + let a: &mut Vec> = x; + //[base]~^ ERROR lifetime mismatch let b = Ref { data: y.data }; Vec::push(a, b); + //[nll]~^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.base.stderr similarity index 93% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.base.stderr index 5c793636778ea..459f18dcc3d77 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-2.rs:2:10 + --> $DIR/ex3-both-anon-regions-2.rs:6:10 | LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr index 5a23f1e0e9d99..b072c12ea3bcb 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-2.rs:2:5 + --> $DIR/ex3-both-anon-regions-2.rs:6:5 | LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs index 1ff96aadd9387..668cadd614b59 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.rs @@ -1,5 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { - *v = x; //~ ERROR lifetime mismatch + *v = x; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.base.stderr similarity index 93% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.base.stderr index 1a7b4fca1ba78..28df5f1836955 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-3.rs:2:13 + --> $DIR/ex3-both-anon-regions-3.rs:6:13 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | --- --- these two types are declared with different lifetimes... @@ -13,7 +13,7 @@ LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) { | ++++ ++ ++ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-3.rs:2:15 + --> $DIR/ex3-both-anon-regions-3.rs:6:15 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr index 6ba130308a33a..c1d809abad5b9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-3.rs:2:5 + --> $DIR/ex3-both-anon-regions-3.rs:6:5 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) { | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-3.rs:2:5 + --> $DIR/ex3-both-anon-regions-3.rs:6:5 | LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | - - let's call the lifetime of this reference `'3` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs index c483f59f9d98c..4d7fd63e5b932 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.rs @@ -1,6 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - z.push((x,y)); //~ ERROR lifetime mismatch - //~^ ERROR lifetime mismatch + z.push((x,y)); + //[base]~^ ERROR lifetime mismatch + //[base]~| ERROR lifetime mismatch + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.base.stderr similarity index 85% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.base.stderr index 8e41d7c54e68d..32263cd56ee72 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:11 + --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:11:11 | LL | fn foo(mut x: Ref, y: Ref) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr index 4c0ffe5c0901a..bfde4025194ae 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:11:5 | LL | fn foo(mut x: Ref, y: Ref) { | ----- - has type `Ref<'_, '1>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs index 94bb80924073b..30764e2ad17c0 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32, } fn foo(mut x: Ref, y: Ref) { - x.b = y.b; //~ ERROR lifetime mismatch + x.b = y.b; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.base.stderr similarity index 84% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.base.stderr index d659c88f69ef7..fb4a2f8f6fe5d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:11 + --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:11:11 | LL | fn foo(mut x: Ref) { | --- this type is declared with multiple lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr index 97c665347f6ec..9ba2c38d6fece 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:11:5 | LL | fn foo(mut x: Ref) { | ----- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs index 3b22aef6f3242..665be2aa2c8d6 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32, } fn foo(mut x: Ref) { - x.a = x.b; //~ ERROR lifetime mismatch + x.a = x.b; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.base.stderr similarity index 97% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.base.stderr index 374bbd93d0874..66a993e034044 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:9:12 + --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:13:12 | LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) | ------- ------- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr index b3d0bc2b882f9..ddf878ba9f914 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:9:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:13:5 | LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) | -- -- lifetime `'b` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs index 87f9cc17726cd..6e151879f4df1 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a> { x: &'a u32, } @@ -6,7 +10,9 @@ fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) where &'a (): Sized, &'b u32: Sized { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.base.stderr similarity index 97% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.base.stderr index 94798d1ce2ab6..5453dbb08f181 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:6:12 + --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:10:12 | LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) { | ------- ------- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr index fbe98a4263ec1..cfd3186c80982 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:6:5 + --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:10:5 | LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs index 4be76c2a0da54..ecc04fbc8adc1 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a> { x: &'a u32, } fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.base.stderr similarity index 85% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.base.stderr index 9f5a79ed333dc..23e752e4a0e9d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs.rs:6:12 + --> $DIR/ex3-both-anon-regions-both-are-structs.rs:10:12 | LL | fn foo(mut x: Vec, y: Ref) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr index 9630729d0ee6a..fa906a90ccc6f 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-both-are-structs.rs:6:5 + --> $DIR/ex3-both-anon-regions-both-are-structs.rs:10:5 | LL | fn foo(mut x: Vec, y: Ref) { | ----- - has type `Ref<'1>` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs index 8fbb405a23d95..f002dfc208f11 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a> { x: &'a u32, } fn foo(mut x: Vec, y: Ref) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.base.stderr similarity index 86% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.base.stderr index 2c87f8dbd2c2b..b5fbc091ebc51 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-latebound-regions.rs:2:12 + --> $DIR/ex3-both-anon-regions-latebound-regions.rs:6:12 | LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { | ------ ------ these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr index 1e24032fc1ce2..d59bee087489d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-latebound-regions.rs:2:5 + --> $DIR/ex3-both-anon-regions-latebound-regions.rs:6:5 | LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs index 7938d11a90532..f0a81eba41239 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.rs @@ -1,5 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.base.stderr similarity index 87% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.base.stderr index 60b92ed2b3247..3d9138f02c67b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:9 + --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:9 | LL | fn foo(mut x: Ref, y: &u32) { | --- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr index bbd62902d9f44..cac2a9470a8be 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:5 | LL | fn foo(mut x: Ref, y: &u32) { | ----- - let's call the lifetime of this reference `'2` @@ -9,7 +9,7 @@ LL | y = x.b; | ^^^^^^^ assignment requires that `'1` must outlive `'2` error[E0384]: cannot assign to immutable argument `y` - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:5 | LL | fn foo(mut x: Ref, y: &u32) { | - help: consider making this binding mutable: `mut y` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs index 1e6425cf5ca9d..31ef28e726d2c 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.rs @@ -1,7 +1,14 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 } fn foo(mut x: Ref, y: &u32) { - y = x.b; //~ ERROR lifetime mismatch + y = x.b; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot assign to immutable argument } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.base.stderr similarity index 85% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.base.stderr index a220c8ddb2be6..77e035562a809 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:4:11 + --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:8:11 | LL | fn foo(mut y: Ref, x: &u32) { | --- ---- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr index 79e7e8e157d95..ba41cc3e908c5 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:8:5 | LL | fn foo(mut y: Ref, x: &u32) { | ----- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs index 02838362c80a7..9a5ac0a976946 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 } fn foo(mut y: Ref, x: &u32) { - y.b = x; //~ ERROR lifetime mismatch + y.b = x; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.base.stderr similarity index 85% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.base.stderr index 73472a8d02252..6cbbabb150a64 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:4:11 + --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:8:11 | LL | fn foo(mut y: Ref, x: &u32) { | --- ---- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr index 53615fd1aba69..c9570aa720620 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:4:5 + --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:8:5 | LL | fn foo(mut y: Ref, x: &u32) { | ----- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs index 02838362c80a7..9a5ac0a976946 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.rs @@ -1,7 +1,13 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 } fn foo(mut y: Ref, x: &u32) { - y.b = x; //~ ERROR lifetime mismatch + y.b = x; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.base.stderr similarity index 86% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.base.stderr index eb6e6f2e95e78..7caf19e89357c 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-one-is-struct.rs:7:11 + --> $DIR/ex3-both-anon-regions-one-is-struct.rs:11:11 | LL | fn foo(mut x: Ref, y: &u32) { | --- ---- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr index 6ff4411673756..9b295248fc99e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-one-is-struct.rs:7:5 + --> $DIR/ex3-both-anon-regions-one-is-struct.rs:11:5 | LL | fn foo(mut x: Ref, y: &u32) { | ----- - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs index 7c827510be8ae..0b4ee5adacc07 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Ref<'a, 'b> { a: &'a u32, b: &'b u32, } fn foo(mut x: Ref, y: &u32) { - x.b = y; //~ ERROR lifetime mismatch + x.b = y; + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.base.stderr similarity index 91% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.base.stderr index 636904aefb47e..add05a11193a3 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5 + --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:11:5 | LL | fn foo<'a>(&self, x: &i32) -> &i32 { | ---- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr index 5601335d275c3..188ff4d77e025 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5 + --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:11:5 | LL | fn foo<'a>(&self, x: &i32) -> &i32 { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs index 286cb6dc90e1b..a4f838c074749 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32 } impl Foo { fn foo<'a>(&self, x: &i32) -> &i32 { - x //~ ERROR lifetime mismatch + x + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.base.stderr similarity index 93% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.base.stderr index 474eadb7f9236..365a0ab3b1027 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19 + --> $DIR/ex3-both-anon-regions-self-is-anon.rs:11:19 | LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | ---- ---- diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr index e221902c4a907..ed9b81f7d0199 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19 + --> $DIR/ex3-both-anon-regions-self-is-anon.rs:11:19 | LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs index 79d7d63c8bb1e..c5854537a5ff4 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo { field: i32, } impl Foo { fn foo<'a>(&self, x: &Foo) -> &Foo { - if true { x } else { self } //~ ERROR lifetime mismatch + if true { x } else { self } + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.base.stderr similarity index 91% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.base.stderr index 6ed3528bb9faa..755e9798170cc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:10 + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:10 | LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr index a909c5fa82351..904a09610fcec 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:3 | LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) { | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:3 | LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | - help: consider changing this to be mutable: `mut y` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs index f9f1a75df5863..4b2280b66f288 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs @@ -1,5 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { - y.push(z); //~ ERROR lifetime mismatch + y.push(z); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot borrow } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.base.stderr similarity index 91% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.base.stderr index 68893781dc291..6a8b07dbec873 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-using-impl-items.rs:6:16 + --> $DIR/ex3-both-anon-regions-using-impl-items.rs:10:16 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr index 9661f1e5144b4..46b9e98907d15 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-using-impl-items.rs:6:9 + --> $DIR/ex3-both-anon-regions-using-impl-items.rs:10:9 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs index 6f95d5a710dfb..242a2d6fd4f69 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.rs @@ -1,9 +1,15 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn foo<'a>(x: &mut Vec<&u8>, y: &u8); } impl Foo for () { fn foo(x: &mut Vec<&u8>, y: &u8) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.base.stderr similarity index 91% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.base.stderr index ede1631db271c..e38dd0fc6eefc 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:10 + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:10 | LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr index cce0a31bfbbf1..54172a845d77e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:3 | LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn foo<'a>(x:Box , y: Vec<&u8>, z: &u8) { | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 + --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:3 | LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { | - help: consider changing this to be mutable: `mut y` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs index 6625d41c7de2a..b93d75b156d5a 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs @@ -1,5 +1,12 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x:Box , y: Vec<&u8>, z: &u8) { - y.push(z); //~ ERROR lifetime mismatch + y.push(z); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot borrow } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.base.stderr similarity index 93% rename from src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.stderr rename to src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.base.stderr index cf405c0de3f0b..dd96c6eef68e7 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions.rs:2:12 + --> $DIR/ex3-both-anon-regions.rs:6:12 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | --- --- these two types are declared with different lifetimes... diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr index ec9fac0c288e0..48e09e37241da 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions.rs:2:5 + --> $DIR/ex3-both-anon-regions.rs:6:5 | LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | - - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs index 44195dadbb9f1..b1d30e83b6213 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.rs @@ -1,5 +1,11 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn foo(x: &mut Vec<&u8>, y: &u8) { - x.push(y); //~ ERROR lifetime mismatch + x.push(y); + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.base.stderr similarity index 92% rename from src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr rename to src/test/ui/lifetimes/lifetime-errors/issue_74400.base.stderr index d972861a2b567..ba672f2971820 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.base.stderr @@ -1,5 +1,5 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr index 2906c05864bae..645d14cd54b89 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds @@ -10,7 +10,7 @@ LL | fn g(data: &[T]) { | +++++++++ error[E0308]: mismatched types - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -18,13 +18,13 @@ LL | f(data, identity) = note: expected type `for<'r> Fn<(&'r T,)>` found type `Fn<(&T,)>` note: the lifetime requirement is introduced here - --> $DIR/issue_74400.rs:8:34 + --> $DIR/issue_74400.rs:12:34 | LL | fn f(data: &[T], key: impl Fn(&T) -> S) { | ^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/issue_74400.rs:12:5 + --> $DIR/issue_74400.rs:16:5 | LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs index f83384524f718..fdaf2f8a591c9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.rs @@ -1,6 +1,10 @@ //! Regression test for #74400: Type mismatch in function arguments E0631, E0271 are falsely //! recognized as E0308 mismatched types. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::convert::identity; fn main() {} @@ -9,5 +13,9 @@ fn f(data: &[T], key: impl Fn(&T) -> S) { } fn g(data: &[T]) { - f(data, identity) //~ ERROR implementation of `FnOnce` is not general + f(data, identity) + //[base]~^ ERROR implementation of `FnOnce` is not general + //[nll]~^^ ERROR the parameter type + //[nll]~| ERROR mismatched types + //[nll]~| ERROR implementation of `FnOnce` is not general } diff --git a/src/test/ui/lifetimes/re-empty-in-error.stderr b/src/test/ui/lifetimes/re-empty-in-error.base.stderr similarity index 84% rename from src/test/ui/lifetimes/re-empty-in-error.stderr rename to src/test/ui/lifetimes/re-empty-in-error.base.stderr index 227e3ca613961..7dfe23f4f01cc 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.stderr +++ b/src/test/ui/lifetimes/re-empty-in-error.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `&'b ()` does not fulfill the required lifetime - --> $DIR/re-empty-in-error.rs:8:5 + --> $DIR/re-empty-in-error.rs:12:5 | LL | foo(&10); | ^^^ | note: type must outlive the empty lifetime as required by this binding - --> $DIR/re-empty-in-error.rs:3:47 + --> $DIR/re-empty-in-error.rs:7:47 | LL | fn foo<'a>(_a: &'a u32) where for<'b> &'b (): 'a { | ^^ diff --git a/src/test/ui/lifetimes/re-empty-in-error.nll.stderr b/src/test/ui/lifetimes/re-empty-in-error.nll.stderr index 9becdab918675..cddb5732f9868 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.nll.stderr +++ b/src/test/ui/lifetimes/re-empty-in-error.nll.stderr @@ -1,5 +1,5 @@ error: higher-ranked lifetime error - --> $DIR/re-empty-in-error.rs:8:5 + --> $DIR/re-empty-in-error.rs:12:5 | LL | foo(&10); | ^^^^^^^^ diff --git a/src/test/ui/lifetimes/re-empty-in-error.rs b/src/test/ui/lifetimes/re-empty-in-error.rs index 41c3718592dee..fdb0a3002c4d9 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.rs +++ b/src/test/ui/lifetimes/re-empty-in-error.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // We didn't have a single test mentioning // `ReEmpty` and this test changes that. fn foo<'a>(_a: &'a u32) where for<'b> &'b (): 'a { - //~^ NOTE type must outlive the empty lifetime as required by this binding + //[base]~^ NOTE type must outlive the empty lifetime as required by this binding } fn main() { foo(&10); - //~^ ERROR the type `&'b ()` does not fulfill the required lifetime + //[base]~^ ERROR the type `&'b ()` does not fulfill the required lifetime + //[nll]~^^ ERROR higher-ranked lifetime error + //[nll]~| NOTE could not prove } diff --git a/src/test/ui/lub-glb/old-lub-glb-object.stderr b/src/test/ui/lub-glb/old-lub-glb-object.base.stderr similarity index 89% rename from src/test/ui/lub-glb/old-lub-glb-object.stderr rename to src/test/ui/lub-glb/old-lub-glb-object.base.stderr index 6eabe5eaeeeeb..da98483906f15 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-object.base.stderr @@ -1,11 +1,13 @@ error[E0308]: mismatched types - --> $DIR/old-lub-glb-object.rs:7:13 + --> $DIR/old-lub-glb-object.rs:11:13 | LL | let z = match 22 { | _____________^ LL | | LL | | 0 => x, LL | | _ => y, +LL | | +LL | | LL | | }; | |_____^ one type is more general than the other | diff --git a/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr b/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr index 355f0754ab1b8..8f19133be4475 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-object.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/old-lub-glb-object.rs:10:14 + --> $DIR/old-lub-glb-object.rs:14:14 | LL | _ => y, | ^ one type is more general than the other @@ -8,7 +8,7 @@ LL | _ => y, found trait object `dyn for<'a> Foo<&'a u8, &'a u8>` error[E0308]: mismatched types - --> $DIR/old-lub-glb-object.rs:10:14 + --> $DIR/old-lub-glb-object.rs:14:14 | LL | _ => y, | ^ one type is more general than the other diff --git a/src/test/ui/lub-glb/old-lub-glb-object.rs b/src/test/ui/lub-glb/old-lub-glb-object.rs index 39d351c235574..b4dbb0caae6c9 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.rs +++ b/src/test/ui/lub-glb/old-lub-glb-object.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that we give a note when the old LUB/GLB algorithm would have // succeeded but the new code (which is stricter) gives an error. @@ -5,9 +9,11 @@ trait Foo {} fn foo(x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, y: &dyn for<'a> Foo<&'a u8, &'a u8>) { let z = match 22 { - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types 0 => x, _ => y, + //[nll]~^ ERROR mismatched types + //[nll]~| ERROR mismatched types }; } diff --git a/src/test/ui/match/match-ref-mut-invariance.stderr b/src/test/ui/match/match-ref-mut-invariance.base.stderr similarity index 81% rename from src/test/ui/match/match-ref-mut-invariance.stderr rename to src/test/ui/match/match-ref-mut-invariance.base.stderr index f9271cb3d068c..060c823797484 100644 --- a/src/test/ui/match/match-ref-mut-invariance.stderr +++ b/src/test/ui/match/match-ref-mut-invariance.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/match-ref-mut-invariance.rs:10:37 + --> $DIR/match-ref-mut-invariance.rs:14:37 | LL | match self.0 { ref mut x => x } | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | match self.0 { ref mut x => x } = note: expected mutable reference `&'a mut &'a i32` found mutable reference `&'a mut &'b i32` note: the lifetime `'a` as defined here... - --> $DIR/match-ref-mut-invariance.rs:9:12 + --> $DIR/match-ref-mut-invariance.rs:13:12 | LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/match-ref-mut-invariance.rs:8:6 + --> $DIR/match-ref-mut-invariance.rs:12:6 | LL | impl<'b> S<'b> { | ^^ diff --git a/src/test/ui/match/match-ref-mut-invariance.nll.stderr b/src/test/ui/match/match-ref-mut-invariance.nll.stderr index 3b7e53cd52724..b98539d91b695 100644 --- a/src/test/ui/match/match-ref-mut-invariance.nll.stderr +++ b/src/test/ui/match/match-ref-mut-invariance.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/match-ref-mut-invariance.rs:10:9 + --> $DIR/match-ref-mut-invariance.rs:14:9 | LL | impl<'b> S<'b> { | -- lifetime `'b` defined here diff --git a/src/test/ui/match/match-ref-mut-invariance.rs b/src/test/ui/match/match-ref-mut-invariance.rs index 50b0ede09c22f..f876a4e2498fe 100644 --- a/src/test/ui/match/match-ref-mut-invariance.rs +++ b/src/test/ui/match/match-ref-mut-invariance.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Check that when making a ref mut binding with type `&mut T`, the // type `T` must match precisely the type `U` of the value being // matched, and in particular cannot be some supertype of `U`. Issue @@ -7,7 +11,9 @@ struct S<'b>(&'b i32); impl<'b> S<'b> { fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { - match self.0 { ref mut x => x } //~ ERROR mismatched types + match self.0 { ref mut x => x } + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/match/match-ref-mut-let-invariance.stderr b/src/test/ui/match/match-ref-mut-let-invariance.base.stderr similarity index 78% rename from src/test/ui/match/match-ref-mut-let-invariance.stderr rename to src/test/ui/match/match-ref-mut-let-invariance.base.stderr index c021a5a91f5c0..7b6dd5af539ef 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.stderr +++ b/src/test/ui/match/match-ref-mut-let-invariance.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/match-ref-mut-let-invariance.rs:11:9 + --> $DIR/match-ref-mut-let-invariance.rs:15:9 | LL | x | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | x = note: expected mutable reference `&'a mut &'a i32` found mutable reference `&'a mut &'b i32` note: the lifetime `'a` as defined here... - --> $DIR/match-ref-mut-let-invariance.rs:9:12 + --> $DIR/match-ref-mut-let-invariance.rs:13:12 | LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/match-ref-mut-let-invariance.rs:8:6 + --> $DIR/match-ref-mut-let-invariance.rs:12:6 | LL | impl<'b> S<'b> { | ^^ diff --git a/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr b/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr index f4d1cea670ba6..4b8bdd157c204 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr +++ b/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/match-ref-mut-let-invariance.rs:11:9 + --> $DIR/match-ref-mut-let-invariance.rs:15:9 | LL | impl<'b> S<'b> { | -- lifetime `'b` defined here diff --git a/src/test/ui/match/match-ref-mut-let-invariance.rs b/src/test/ui/match/match-ref-mut-let-invariance.rs index a62eb714a4d3d..0a8daed569ff7 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.rs +++ b/src/test/ui/match/match-ref-mut-let-invariance.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Check that when making a ref mut binding with type `&mut T`, the // type `T` must match precisely the type `U` of the value being // matched, and in particular cannot be some supertype of `U`. Issue @@ -8,7 +12,9 @@ struct S<'b>(&'b i32); impl<'b> S<'b> { fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { let ref mut x = self.0; - x //~ ERROR mismatched types + x + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.base.stderr similarity index 86% rename from src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr rename to src/test/ui/mismatched_types/closure-arg-type-mismatch.base.stderr index f34ac35c75713..dfc6ef567f0fa 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.base.stderr @@ -1,5 +1,5 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:3:14 + --> $DIR/closure-arg-type-mismatch.rs:7:14 | LL | a.iter().map(|_: (u32, u32)| 45); | ^^^ ------------------ found signature of `fn((u32, u32)) -> _` @@ -13,7 +13,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:4:14 + --> $DIR/closure-arg-type-mismatch.rs:8:14 | LL | a.iter().map(|_: &(u16, u16)| 45); | ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _` @@ -27,7 +27,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:5:14 + --> $DIR/closure-arg-type-mismatch.rs:9:14 | LL | a.iter().map(|_: (u16, u16)| 45); | ^^^ ------------------ found signature of `fn((u16, u16)) -> _` @@ -41,7 +41,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0308]: mismatched types - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ lifetime mismatch @@ -49,18 +49,18 @@ LL | baz(f); = note: expected type `for<'r> Fn<(*mut &'r u32,)>` found type `Fn<(*mut &'a u32,)>` note: the required lifetime does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/closure-arg-type-mismatch.rs:9:10 + --> $DIR/closure-arg-type-mismatch.rs:13:10 | LL | fn _test<'a>(f: fn(*mut &'a u32)) { | ^^ note: the lifetime requirement is introduced here - --> $DIR/closure-arg-type-mismatch.rs:8:11 + --> $DIR/closure-arg-type-mismatch.rs:12:11 | LL | fn baz(_: F) {} | ^^^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ implementation of `FnOnce` is not general enough @@ -69,7 +69,7 @@ LL | baz(f); = note: ...but it actually implements `FnOnce<(*mut &'a u32,)>` error[E0308]: mismatched types - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ lifetime mismatch @@ -77,18 +77,18 @@ LL | baz(f); = note: expected type `for<'r> Fn<(*mut &'r u32,)>` found type `Fn<(*mut &'a u32,)>` note: the lifetime `'a` as defined here doesn't meet the lifetime requirements - --> $DIR/closure-arg-type-mismatch.rs:9:10 + --> $DIR/closure-arg-type-mismatch.rs:13:10 | LL | fn _test<'a>(f: fn(*mut &'a u32)) { | ^^ note: the lifetime requirement is introduced here - --> $DIR/closure-arg-type-mismatch.rs:8:11 + --> $DIR/closure-arg-type-mismatch.rs:12:11 | LL | fn baz(_: F) {} | ^^^^^^^^^^^^^ error: implementation of `FnOnce` is not general enough - --> $DIR/closure-arg-type-mismatch.rs:10:5 + --> $DIR/closure-arg-type-mismatch.rs:14:5 | LL | baz(f); | ^^^ implementation of `FnOnce` is not general enough diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr index 1f46229cb5a6a..314000e88483d 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.nll.stderr @@ -1,5 +1,5 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:3:14 + --> $DIR/closure-arg-type-mismatch.rs:7:14 | LL | a.iter().map(|_: (u32, u32)| 45); | ^^^ ------------------ found signature of `fn((u32, u32)) -> _` @@ -13,7 +13,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:4:14 + --> $DIR/closure-arg-type-mismatch.rs:8:14 | LL | a.iter().map(|_: &(u16, u16)| 45); | ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _` @@ -27,7 +27,7 @@ LL | F: FnMut(Self::Item) -> B, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map` error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch.rs:5:14 + --> $DIR/closure-arg-type-mismatch.rs:9:14 | LL | a.iter().map(|_: (u16, u16)| 45); | ^^^ ------------------ found signature of `fn((u16, u16)) -> _` diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs b/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs index 2d485d14a8d6b..da8011cc92b62 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn main() { let a = [(1u32, 2u32)]; a.iter().map(|_: (u32, u32)| 45); //~ ERROR type mismatch @@ -8,8 +12,8 @@ fn main() { fn baz(_: F) {} fn _test<'a>(f: fn(*mut &'a u32)) { baz(f); - //~^ ERROR implementation of `FnOnce` is not general enough - //~| ERROR implementation of `FnOnce` is not general enough - //~| ERROR mismatched types - //~| ERROR mismatched types + //[base]~^ ERROR implementation of `FnOnce` is not general enough + //[base]~| ERROR implementation of `FnOnce` is not general enough + //[base]~| ERROR mismatched types + //[base]~| ERROR mismatched types } diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.base.stderr similarity index 82% rename from src/test/ui/mismatched_types/closure-mismatch.stderr rename to src/test/ui/mismatched_types/closure-mismatch.base.stderr index c41bece3c196f..7c81ebdf49078 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/closure-mismatch.rs:8:5 + --> $DIR/closure-mismatch.rs:12:5 | LL | baz(|_| ()); | ^^^ lifetime mismatch @@ -7,12 +7,12 @@ LL | baz(|_| ()); = note: expected type `for<'r> Fn<(&'r (),)>` found type `Fn<(&(),)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/closure-mismatch.rs:8:9 + --> $DIR/closure-mismatch.rs:12:9 | LL | baz(|_| ()); | ^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/closure-mismatch.rs:5:11 + --> $DIR/closure-mismatch.rs:9:11 | LL | fn baz(_: T) {} | ^^^ diff --git a/src/test/ui/mismatched_types/closure-mismatch.nll.stderr b/src/test/ui/mismatched_types/closure-mismatch.nll.stderr index bd36fab92886d..9508fc8a9be23 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.nll.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.nll.stderr @@ -1,5 +1,5 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/closure-mismatch.rs:8:5 + --> $DIR/closure-mismatch.rs:12:5 | LL | baz(|_| ()); | ^^^^^^^^^^^ implementation of `FnOnce` is not general enough @@ -8,7 +8,7 @@ LL | baz(|_| ()); = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error[E0308]: mismatched types - --> $DIR/closure-mismatch.rs:8:5 + --> $DIR/closure-mismatch.rs:12:5 | LL | baz(|_| ()); | ^^^^^^^^^^^ one type is more general than the other @@ -16,12 +16,12 @@ LL | baz(|_| ()); = note: expected type `for<'r> Fn<(&'r (),)>` found type `Fn<(&(),)>` note: this closure does not fulfill the lifetime requirements - --> $DIR/closure-mismatch.rs:8:9 + --> $DIR/closure-mismatch.rs:12:9 | LL | baz(|_| ()); | ^^^^^^ note: the lifetime requirement is introduced here - --> $DIR/closure-mismatch.rs:5:11 + --> $DIR/closure-mismatch.rs:9:11 | LL | fn baz(_: T) {} | ^^^ diff --git a/src/test/ui/mismatched_types/closure-mismatch.rs b/src/test/ui/mismatched_types/closure-mismatch.rs index d2b78b4b7dba5..5bf3aef9bb07a 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.rs +++ b/src/test/ui/mismatched_types/closure-mismatch.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl Foo for T {} @@ -5,5 +9,8 @@ impl Foo for T {} fn baz(_: T) {} fn main() { - baz(|_| ()); //~ ERROR mismatched types + baz(|_| ()); + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR implementation of `FnOnce` is not general enough + //[nll]~| ERROR mismatched types } diff --git a/src/test/ui/nll/continue-after-missing-main.stderr b/src/test/ui/nll/continue-after-missing-main.base.stderr similarity index 90% rename from src/test/ui/nll/continue-after-missing-main.stderr rename to src/test/ui/nll/continue-after-missing-main.base.stderr index 29e7dc1e56c73..9d1fa66813d26 100644 --- a/src/test/ui/nll/continue-after-missing-main.stderr +++ b/src/test/ui/nll/continue-after-missing-main.base.stderr @@ -1,11 +1,11 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main` - --> $DIR/continue-after-missing-main.rs:30:2 + --> $DIR/continue-after-missing-main.rs:34:2 | LL | } | ^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs` error[E0623]: lifetime mismatch - --> $DIR/continue-after-missing-main.rs:28:56 + --> $DIR/continue-after-missing-main.rs:32:56 | LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>, | ------------------------------------------------------------------ these two types are declared with different lifetimes... diff --git a/src/test/ui/nll/continue-after-missing-main.nll.stderr b/src/test/ui/nll/continue-after-missing-main.nll.stderr index ebebabe349b85..2bad3be8b4ebe 100644 --- a/src/test/ui/nll/continue-after-missing-main.nll.stderr +++ b/src/test/ui/nll/continue-after-missing-main.nll.stderr @@ -1,5 +1,5 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main` - --> $DIR/continue-after-missing-main.rs:30:2 + --> $DIR/continue-after-missing-main.rs:34:2 | LL | } | ^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs` diff --git a/src/test/ui/nll/continue-after-missing-main.rs b/src/test/ui/nll/continue-after-missing-main.rs index 1019cacce6421..ddead7dc2330a 100644 --- a/src/test/ui/nll/continue-after-missing-main.rs +++ b/src/test/ui/nll/continue-after-missing-main.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(dead_code)] struct Tableau<'a, MP> { @@ -26,5 +30,5 @@ fn create_and_solve_subproblems<'data_provider, 'original_data, MP>( tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>, ) { let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound(); - //~^ ERROR lifetime mismatch + //[base]~^ ERROR lifetime mismatch } //~ ERROR `main` function not found in crate diff --git a/src/test/ui/nll/issue-52213.stderr b/src/test/ui/nll/issue-52213.base.stderr similarity index 84% rename from src/test/ui/nll/issue-52213.stderr rename to src/test/ui/nll/issue-52213.base.stderr index aef5e258a1b06..fb758ca17a8ef 100644 --- a/src/test/ui/nll/issue-52213.stderr +++ b/src/test/ui/nll/issue-52213.base.stderr @@ -1,28 +1,28 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/issue-52213.rs:2:11 + --> $DIR/issue-52213.rs:6:11 | LL | match (&t,) { | ^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/issue-52213.rs:1:23 + --> $DIR/issue-52213.rs:5:23 | LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { | ^^ note: ...so that the types are compatible - --> $DIR/issue-52213.rs:2:11 + --> $DIR/issue-52213.rs:6:11 | LL | match (&t,) { | ^^^^^ = note: expected `(&&(T,),)` found `(&&'a (T,),)` note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/issue-52213.rs:1:27 + --> $DIR/issue-52213.rs:5:27 | LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/issue-52213.rs:3:20 + --> $DIR/issue-52213.rs:8:20 | LL | ((u,),) => u, | ^ diff --git a/src/test/ui/nll/issue-52213.nll.stderr b/src/test/ui/nll/issue-52213.nll.stderr index da31bcd547507..a7553de691093 100644 --- a/src/test/ui/nll/issue-52213.nll.stderr +++ b/src/test/ui/nll/issue-52213.nll.stderr @@ -1,11 +1,11 @@ error: lifetime may not live long enough - --> $DIR/issue-52213.rs:3:20 + --> $DIR/issue-52213.rs:8:20 | LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | match (&t,) { +... LL | ((u,),) => u, | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | diff --git a/src/test/ui/nll/issue-52213.rs b/src/test/ui/nll/issue-52213.rs index c4ce4946b2e28..c5918b47f5710 100644 --- a/src/test/ui/nll/issue-52213.rs +++ b/src/test/ui/nll/issue-52213.rs @@ -1,6 +1,12 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { - match (&t,) { //~ ERROR cannot infer an appropriate lifetime + match (&t,) { + //[base]~^ ERROR cannot infer an appropriate lifetime ((u,),) => u, + //[nll]~^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/nll/issue-52533-1.stderr b/src/test/ui/nll/issue-52533-1.base.stderr similarity index 84% rename from src/test/ui/nll/issue-52533-1.stderr rename to src/test/ui/nll/issue-52533-1.base.stderr index 475c7d0b48bfb..ddcb01b8f468d 100644 --- a/src/test/ui/nll/issue-52533-1.stderr +++ b/src/test/ui/nll/issue-52533-1.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-52533-1.rs:9:18 + --> $DIR/issue-52533-1.rs:13:18 | LL | gimme(|x, y| y) | ^ lifetime mismatch @@ -7,12 +7,12 @@ LL | gimme(|x, y| y) = note: expected reference `&Foo<'_, '_, u32>` found reference `&Foo<'_, '_, u32>` note: the anonymous lifetime #3 defined here... - --> $DIR/issue-52533-1.rs:9:11 + --> $DIR/issue-52533-1.rs:13:11 | LL | gimme(|x, y| y) | ^^^^^^^^ note: ...does not necessarily outlive the anonymous lifetime #2 defined here - --> $DIR/issue-52533-1.rs:9:11 + --> $DIR/issue-52533-1.rs:13:11 | LL | gimme(|x, y| y) | ^^^^^^^^ diff --git a/src/test/ui/nll/issue-52533-1.nll.stderr b/src/test/ui/nll/issue-52533-1.nll.stderr index 20f19b2596716..5554339eb7c62 100644 --- a/src/test/ui/nll/issue-52533-1.nll.stderr +++ b/src/test/ui/nll/issue-52533-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-52533-1.rs:9:18 + --> $DIR/issue-52533-1.rs:13:18 | LL | gimme(|x, y| y) | - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` diff --git a/src/test/ui/nll/issue-52533-1.rs b/src/test/ui/nll/issue-52533-1.rs index c80f43237fc76..3ee7dd556a583 100644 --- a/src/test/ui/nll/issue-52533-1.rs +++ b/src/test/ui/nll/issue-52533-1.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + #![allow(warnings)] struct Foo<'a, 'b, T: 'a + 'b> { x: &'a T, y: &'b T } @@ -7,5 +11,6 @@ fn gimme(_: impl for<'a, 'b, 'c> FnOnce(&'a Foo<'a, 'b, u32>, fn main() { gimme(|x, y| y) - //~^ ERROR mismatched types [E0308] + //[base]~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/nll/lint-no-err.rs b/src/test/ui/nll/lint-no-err.rs index f5f7bf0a758e1..2d1d5cb26d32c 100644 --- a/src/test/ui/nll/lint-no-err.rs +++ b/src/test/ui/nll/lint-no-err.rs @@ -4,11 +4,6 @@ // when buffering lints, which resulted in ICE later on, // see #94502. -// Errors with `nll` which is already tested in enough other tests, -// so we ignore it here. -// -// ignore-compare-mode-nll - struct Repro; impl Repro { fn get(&self) -> &i32 { diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.base.stderr similarity index 81% rename from src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr rename to src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.base.stderr index 88253bad194c9..c7710146ea40f 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-bound.rs:15:5 + --> $DIR/projection-where-clause-env-wrong-bound.rs:19:5 | LL | bar::() | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | bar::() = help: consider adding an explicit lifetime bound `>::Output: 'a`... = note: ...so that the type `>::Output` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/projection-where-clause-env-wrong-bound.rs:29:8 + --> $DIR/projection-where-clause-env-wrong-bound.rs:33:8 | LL | T: 'a, | ^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr index b4435fe06bccc..d235dee6444ff 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-bound.rs:15:5 + --> $DIR/projection-where-clause-env-wrong-bound.rs:19:5 | LL | bar::() | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs index dce88b88c7530..22edb22a5363e 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that we are able to establish that `>::Output` outlives `'b` here. We need to prove however // that `>::Output` outlives `'a`, so we also have to diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.base.stderr similarity index 81% rename from src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr rename to src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.base.stderr index 9f7fc030aa981..c3e2301bd66fb 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.base.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:18:5 | LL | bar::<>::Output>() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | bar::<>::Output>() = help: consider adding an explicit lifetime bound `>::Output: 'a`... = note: ...so that the type `>::Output` will meet its required lifetime bounds... note: ...that is required by this bound - --> $DIR/projection-where-clause-env-wrong-lifetime.rs:20:8 + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:25:8 | LL | T: 'a, | ^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr index ddeaf3c1f9e8c..82fe2fad9f71c 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the associated type `>::Output` may not live long enough - --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:18:5 | LL | bar::<>::Output>() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs index 9e3590ca71545..d89b065673b59 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Test that if we need to prove that `>::Output: // 'a`, but we only know that `>::Output: 'a`, that // doesn't suffice. @@ -12,7 +16,8 @@ where >::Output: 'a, { bar::<>::Output>() - //~^ ERROR the associated type `>::Output` may not live long enough + //[base]~^ ERROR the associated type `>::Output` may not live long enough + //[nll]~^^ ERROR the associated type `>::Output` may not live long enough } fn bar<'a, T>() -> &'a () diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr similarity index 75% rename from src/test/ui/object-lifetime/object-lifetime-default-elision.stderr rename to src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr index 5af4c5bdfaed3..c402d1fefad65 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:10 + --> $DIR/object-lifetime-default-elision.rs:58:10 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:13 + --> $DIR/object-lifetime-default-elision.rs:58:13 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the types are compatible - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ @@ -28,28 +28,28 @@ LL | ss found `&dyn SomeTrait` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:10 + --> $DIR/object-lifetime-default-elision.rs:58:10 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:13 + --> $DIR/object-lifetime-default-elision.rs:58:13 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the types are compatible - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr index 61e96f59fed91..49bbadf7224ba 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs index dc42edfba2cc1..16b4df7bad5ed 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test various cases where the old rules under lifetime elision // yield slightly different results than the new rules. @@ -69,8 +73,9 @@ fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { // which fails to type check. ss - //~^ ERROR cannot infer - //~| ERROR cannot infer + //[base]~^ ERROR cannot infer + //[base]~| ERROR cannot infer + //[nll]~^^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr similarity index 88% rename from src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr rename to src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr index 1708700f77aaa..5a8cba175e93f 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `ss` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | fn load(ss: &mut SomeStruct) -> Box { | --------------- this data with an anonymous lifetime `'_`... @@ -8,7 +8,7 @@ LL | ss.r | ^^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/object-lifetime-default-from-box-error.rs:14:37 + --> $DIR/object-lifetime-default-from-box-error.rs:18:37 | LL | fn load(ss: &mut SomeStruct) -> Box { | ^^^^^^^^^^^^^ `'static` requirement introduced here @@ -21,7 +21,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box { | ++++ error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:12 + --> $DIR/object-lifetime-default-from-box-error.rs:38:12 | LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr index 43695a7511d27..7907813f2674e 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | fn load(ss: &mut SomeStruct) -> Box { | -- has type `&mut SomeStruct<'1>` @@ -13,13 +13,13 @@ LL | fn load(ss: &mut SomeStruct) -> Box { | ++++ error[E0507]: cannot move out of `ss.r` which is behind a mutable reference - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | ss.r | ^^^^ move occurs because `ss.r` has type `Box`, which does not implement the `Copy` trait error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:5 + --> $DIR/object-lifetime-default-from-box-error.rs:38:5 | LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs index 4a2665d8e1694..1cb9834913cab 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test various cases where the defaults should lead to errors being // reported. @@ -15,7 +19,10 @@ fn load(ss: &mut SomeStruct) -> Box { // `Box` defaults to a `'static` bound, so this return // is illegal. - ss.r //~ ERROR E0759 + ss.r + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot move out of } fn store(ss: &mut SomeStruct, b: Box) { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr similarity index 80% rename from src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr rename to src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr index e7fab9ecefcd1..7e88aa32357d7 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:12 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:12 | LL | ss.t = t; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | ss.t = t; = note: expected reference `&'a Box<(dyn Test + 'static)>` found reference `&'a Box<(dyn Test + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:14:6 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:18:6 | LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr index 7d6f9f39d13ed..a07cc0718f11f 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:5 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:5 | LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs index bf9e0beb57cdf..8cdd64be193e2 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that the lifetime from the enclosing `&` is "inherited" // through the `Box` struct. @@ -12,7 +16,9 @@ struct SomeStruct<'a> { } fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types + ss.t = t; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr similarity index 80% rename from src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr rename to src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr index 1649841c18685..b97a7d2254995 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:12 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:12 | LL | ss.t = t; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | ss.t = t; = note: expected reference `&'a MyBox<(dyn Test + 'static)>` found reference `&'a MyBox<(dyn Test + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:19:6 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:23:6 | LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr index 2bc8e097859d3..63d51b5c28c6c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:5 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:5 | LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs index dc0b86903c9e5..2d9a148a389c4 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that the lifetime from the enclosing `&` is "inherited" // through the `MyBox` struct. @@ -17,7 +21,9 @@ struct MyBox { } fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types + ss.t = t; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr similarity index 87% rename from src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr rename to src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr index 4c5fb452ebe42..6a72fab307b6f 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/object-lifetime-default-mybox.rs:27:5 + --> $DIR/object-lifetime-default-mybox.rs:31:5 | LL | fn load1<'a,'b>(a: &'a MyBox, | ------------------------ this parameter and the return type are declared with different lifetimes... @@ -11,7 +11,7 @@ LL | a | ^ ...but data from `a` is returned here error[E0308]: mismatched types - --> $DIR/object-lifetime-default-mybox.rs:31:11 + --> $DIR/object-lifetime-default-mybox.rs:37:11 | LL | load0(ss) | ^^ lifetime mismatch @@ -19,7 +19,7 @@ LL | load0(ss) = note: expected reference `&MyBox<(dyn SomeTrait + 'static)>` found reference `&MyBox<(dyn SomeTrait + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-mybox.rs:30:10 + --> $DIR/object-lifetime-default-mybox.rs:36:10 | LL | fn load2<'a>(ss: &MyBox) -> MyBox { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index af20c5e5fc0da..aa454cb99315c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-mybox.rs:27:5 + --> $DIR/object-lifetime-default-mybox.rs:31:5 | LL | fn load1<'a,'b>(a: &'a MyBox, | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | a = help: consider adding the following bound: `'a: 'b` error[E0521]: borrowed data escapes outside of function - --> $DIR/object-lifetime-default-mybox.rs:31:5 + --> $DIR/object-lifetime-default-mybox.rs:37:5 | LL | fn load2<'a>(ss: &MyBox) -> MyBox { | -- -- `ss` is a reference that is only valid in the function body diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs index eb27fe90f47ce..874556dafebf1 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test a "pass-through" object-lifetime-default that produces errors. #![allow(dead_code)] @@ -24,11 +28,15 @@ fn load1<'a,'b>(a: &'a MyBox, b: &'b MyBox) -> &'b MyBox { - a //~ ERROR lifetime mismatch + a + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn load2<'a>(ss: &MyBox) -> MyBox { - load0(ss) //~ ERROR mismatched types + load0(ss) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes outside of function } fn main() { diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr similarity index 94% rename from src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr rename to src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr index b125eacfb6cf4..12c7c8f9b7e12 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr @@ -1,23 +1,23 @@ error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:66:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:70:13 | LL | fn use_it<'a>(val: Box + 'a>) -> &'a () { | -------------------------------------- this data with lifetime `'a`... @@ -25,7 +25,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:60:30 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:64:30 | LL | impl MyTrait for Box> { | ^^^^^^^^^^^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr index 2dc300ac76f27..db790049c6f44 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr @@ -1,17 +1,17 @@ error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function error[E0515]: cannot return reference to function parameter `val` - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9 | LL | val.use_self() | ^^^^^^^^^^^^^^ returns a reference to data owned by the current function diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs index 0045d3fcf1c7b..ec90a0987f0a3 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // FIXME: the following cases need to suggest more things to make users reach a working end state. mod bav { @@ -63,7 +67,7 @@ mod bay { impl Bar for i32 {} fn use_it<'a>(val: Box + 'a>) -> &'a () { - val.use_self() //~ ERROR E0772 + val.use_self() //[base]~ ERROR E0772 } } diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs new file mode 100644 index 0000000000000..37be629e77c5d --- /dev/null +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.rs @@ -0,0 +1,118 @@ +// FIXME(nll): On NLL stabilization, this should replace +// `impl-on-dyn-trait-with-implicit-static-bound.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +#![allow(dead_code)] + +mod foo { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self::() //~ ERROR borrowed data escapes + } +} + +mod bar { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { + val.use_self() + } +} + +mod baz { + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &(); + } + trait Irrelevant {} + + impl MyTrait for Box { + fn use_self(&self) -> &() { panic!() } + } + impl Irrelevant for Box {} + + fn use_it<'a>(val: &'a Box) -> &'a () { + val.use_self() + } +} + +mod bat { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + + impl dyn ObjectTrait { + fn use_self(&self) -> &() { panic!() } + } + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + val.use_self() + //~^ ERROR borrowed data escapes + } +} + +mod ban { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant { + fn use_self(&self) -> &() { panic!() } + } + + impl MyTrait for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { + val.use_self() //~ ERROR borrowed data escapes + } +} + +mod bal { + trait OtherTrait<'a> {} + impl<'a> OtherTrait<'a> for &'a () {} + + trait ObjectTrait {} + trait MyTrait { + fn use_self(&self) -> &() { panic!() } + } + trait Irrelevant { + fn use_self(&self) -> &() { panic!() } + } + + impl MyTrait for dyn ObjectTrait {} + impl Irrelevant for dyn ObjectTrait {} + + fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { + MyTrait::use_self(val) //~ ERROR borrowed data escapes + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr similarity index 88% rename from src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr rename to src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr index a1ef32c5445b5..38731ea895533 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:25:9 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body @@ -12,7 +12,7 @@ LL | val.use_self::() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:74:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body @@ -25,7 +25,7 @@ LL | val.use_self() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:94:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | -- --- `val` is a reference that is only valid in the function body @@ -38,7 +38,7 @@ LL | val.use_self() | argument requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:114:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | -- --- `val` is a reference that is only valid in the function body diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed index 3c10f85d9423a..74da1cbfea54e 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix #![allow(dead_code)] diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs index 88ab03dfc1ef1..e0058b181b423 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix #![allow(dead_code)] diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr index ed094c1365caa..fbe7ac94a0aa6 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -1,5 +1,5 @@ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:25:13 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ---------------------- this data with lifetime `'a`... @@ -7,7 +7,7 @@ LL | val.use_self::() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:19:32 | LL | impl MyTrait for dyn ObjectTrait { | ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -19,7 +19,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ { | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:74:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... @@ -27,7 +27,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl` | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:14 | LL | impl dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -39,7 +39,7 @@ LL | impl dyn ObjectTrait + '_ { | ++++ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:93:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | ------------------- this data with lifetime `'a`... @@ -47,7 +47,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:26 | LL | fn use_self(&self) -> &() { panic!() } | -------- calling this method introduces the `impl`'s 'static` requirement @@ -64,7 +64,7 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ++++ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:27 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... @@ -72,12 +72,12 @@ LL | MyTrait::use_self(val) | ^^^ ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:9 | LL | MyTrait::use_self(val) | ^^^^^^^^^^^^^^^^^ note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:109:26 | LL | fn use_self(&self) -> &() { panic!() } | -------- calling this method introduces the `impl`'s 'static` requirement @@ -90,7 +90,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ {} | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:42:13 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { | ------------------- this data with lifetime `'a`... @@ -98,7 +98,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:36:26 | LL | impl MyTrait for dyn ObjectTrait { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement @@ -110,7 +110,7 @@ LL | impl MyTrait for dyn ObjectTrait + '_ { | ++++ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:59:13 | LL | fn use_it<'a>(val: &'a Box) -> &'a () { | ----------------------------- this data with lifetime `'a`... @@ -118,7 +118,7 @@ LL | val.use_self() | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement - --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30 + --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:53:30 | LL | impl MyTrait for Box { | ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr similarity index 70% rename from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr rename to src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr index 5d195e5ff32f7..4e0e6675e5a28 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr @@ -1,21 +1,21 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:9 | LL | foo.bar(move |_| { | ^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 + --> $DIR/missing-lifetimes-in-signature-2.rs:23:24 | LL | fn func(foo: &Foo, t: T) { | ^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds... - --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:24:13: 27:6]` will meet its required lifetime bounds... + --> $DIR/missing-lifetimes-in-signature-2.rs:24:9 | LL | foo.bar(move |_| { | ^^^ note: ...that is required by this bound - --> $DIR/missing-lifetimes-in-signature-2.rs:11:12 + --> $DIR/missing-lifetimes-in-signature-2.rs:15:12 | LL | F: 'a, | ^^ diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr index 0212c2d712cb3..9f35175c08d8c 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:5 | LL | / foo.bar(move |_| { LL | | @@ -8,12 +8,12 @@ LL | | }); | |______^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 + --> $DIR/missing-lifetimes-in-signature-2.rs:23:24 | LL | fn func(foo: &Foo, t: T) { | ^^^ note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 + --> $DIR/missing-lifetimes-in-signature-2.rs:24:5 | LL | / foo.bar(move |_| { LL | | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs index c6802ac6cc704..3e3b440330491 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // Regression test for #81650 struct Foo<'a> { diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr similarity index 81% rename from src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr rename to src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr index ae9a020a099f4..d51d12b909d0b 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.base.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:37:11 + --> $DIR/missing-lifetimes-in-signature.rs:42:11 | LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -7,10 +7,10 @@ LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | help: consider introducing lifetime `'a` here: `'a,` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/missing-lifetimes-in-signature.rs:19:5 + --> $DIR/missing-lifetimes-in-signature.rs:23:5 | LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:23:5: 26:6]` captures the anonymous lifetime defined here ... LL | / move || { LL | | @@ -24,18 +24,18 @@ LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:26:37 + --> $DIR/missing-lifetimes-in-signature.rs:30:37 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 + --> $DIR/missing-lifetimes-in-signature.rs:30:26 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:31:5: 33:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:26:37 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:35:5: 38:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:30:37 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ @@ -48,18 +48,18 @@ LL ~ G: Get + 'a, | error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:48:45 + --> $DIR/missing-lifetimes-in-signature.rs:53:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:48:34 + --> $DIR/missing-lifetimes-in-signature.rs:53:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:53:5: 55:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:48:45 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:58:5: 61:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:53:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ @@ -69,18 +69,18 @@ LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + ' | +++ ++++ ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:60:58 + --> $DIR/missing-lifetimes-in-signature.rs:66:58 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:60:47 + --> $DIR/missing-lifetimes-in-signature.rs:66:47 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:62:9: 64:10]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:60:58 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:68:9: 71:10]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:66:58 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | fn qux<'c, 'b, G: Get + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOn | +++ ++++ ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:69:45 + --> $DIR/missing-lifetimes-in-signature.rs:76:45 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required @@ -98,10 +98,10 @@ LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:80:44 + --> $DIR/missing-lifetimes-in-signature.rs:89:44 | LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a - | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:85:5: 87:6]` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:94:5: 97:6]` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr index 24eac64d334da..63932cb6ba042 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:37:11 + --> $DIR/missing-lifetimes-in-signature.rs:42:11 | LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -7,10 +7,10 @@ LL | fn baz(g: G, dest: &mut T) -> impl FnOnce() + '_ | help: consider introducing lifetime `'a` here: `'a,` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/missing-lifetimes-in-signature.rs:19:5 + --> $DIR/missing-lifetimes-in-signature.rs:23:5 | LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here + | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:23:5: 26:6]` captures the anonymous lifetime defined here ... LL | / move || { LL | | @@ -24,22 +24,24 @@ LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:31:5 + --> $DIR/missing-lifetimes-in-signature.rs:35:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 + --> $DIR/missing-lifetimes-in-signature.rs:30:26 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:31:5 + --> $DIR/missing-lifetimes-in-signature.rs:35:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -49,22 +51,24 @@ LL | G: Get + 'a, | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:53:5 + --> $DIR/missing-lifetimes-in-signature.rs:58:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:48:34 + --> $DIR/missing-lifetimes-in-signature.rs:53:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:53:5 + --> $DIR/missing-lifetimes-in-signature.rs:58:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -74,22 +78,24 @@ LL | fn qux<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:62:9 + --> $DIR/missing-lifetimes-in-signature.rs:68:9 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_________^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:60:47 + --> $DIR/missing-lifetimes-in-signature.rs:66:47 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:62:9 + --> $DIR/missing-lifetimes-in-signature.rs:68:9 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_________^ @@ -99,22 +105,26 @@ LL | fn qux<'b, G: Get + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOnce() | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:69:34 + --> $DIR/missing-lifetimes-in-signature.rs:76:34 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ @@ -124,20 +134,23 @@ LL | fn bat<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:74:5 + --> $DIR/missing-lifetimes-in-signature.rs:81:5 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ... LL | / move || { +LL | | +LL | | LL | | *dest = g.get(); LL | | } | |_____^ lifetime `'a` required error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:85:5 + --> $DIR/missing-lifetimes-in-signature.rs:94:5 | LL | / move || { +LL | | LL | | *dest = g.get(); LL | | } | |_____^ ...so that the type `G` will meet its required lifetime bounds diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index 0a3e6b481632d..2036620126955 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + pub trait Get { fn get(self) -> T; } @@ -24,11 +28,12 @@ where // After applying suggestion for `foo`: fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -46,11 +51,12 @@ where // After applying suggestion for `baz`: fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -58,8 +64,9 @@ where // Same as above, but show that we pay attention to lifetime names from parent item impl<'a> Foo { fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - //~^ ERROR the parameter type `G` may not live long enough + //[base]~^ ERROR the parameter type `G` may not live long enough move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } @@ -67,22 +74,25 @@ impl<'a> Foo { // After applying suggestion for `qux`: fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a -//~^ ERROR explicit lifetime required in the type of `dest` +//[base]~^ ERROR explicit lifetime required in the type of `dest` where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough + //[nll]~| ERROR explicit lifetime required *dest = g.get(); } } // Potential incorrect attempt: fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a -//~^ ERROR the parameter type `G` may not live long enough +//[base]~^ ERROR the parameter type `G` may not live long enough where G: Get, { move || { + //[nll]~^ ERROR the parameter type `G` may not live long enough *dest = g.get(); } } diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr similarity index 90% rename from src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr rename to src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr index a5b50634c71ea..0bd7f289340f3 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:30:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:35:31 | LL | fn iter(&self) -> impl Iterator> { | ----- this data with an anonymous lifetime `'_`... @@ -10,7 +10,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:27:23 + --> $DIR/trait-object-nested-in-impl-trait.rs:31:23 | LL | fn iter(&self) -> impl Iterator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | fn iter(&self) -> impl Iterator> { | ++++ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:41:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:48:31 | LL | fn iter(&self) -> impl Iterator> + '_ { | ----- this data with an anonymous lifetime `'_`... @@ -35,7 +35,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:38:23 + --> $DIR/trait-object-nested-in-impl-trait.rs:44:23 | LL | fn iter(&self) -> impl Iterator> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | fn iter(&self) -> impl Iterator> + '_ { | ++++ error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:52:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:61:31 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | -------- this data with lifetime `'a`... @@ -56,7 +56,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:49:30 + --> $DIR/trait-object-nested-in-impl-trait.rs:57:30 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ++++ error[E0759]: `self` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/trait-object-nested-in-impl-trait.rs:63:31 + --> $DIR/trait-object-nested-in-impl-trait.rs:74:31 | LL | fn iter<'a>(&'a self) -> impl Iterator> { | -------- this data with lifetime `'a`... @@ -77,7 +77,7 @@ LL | remaining: self.0.iter(), | ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/trait-object-nested-in-impl-trait.rs:60:30 + --> $DIR/trait-object-nested-in-impl-trait.rs:70:30 | LL | fn iter<'a>(&'a self) -> impl Iterator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr index 6c65e4f017542..989f18e7182a0 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.nll.stderr @@ -1,11 +1,13 @@ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:28:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:32:9 | LL | fn iter(&self) -> impl Iterator> { | - let's call the lifetime of this reference `'1` LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'1` must outlive `'static` | @@ -19,13 +21,15 @@ LL | fn iter(&self) -> impl Iterator> { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:39:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:45:9 | LL | fn iter(&self) -> impl Iterator> + '_ { | - let's call the lifetime of this reference `'1` LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'1` must outlive `'static` | @@ -35,13 +39,15 @@ LL | fn iter(&self) -> impl Iterator> + '_ { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:50:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:58:9 | LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | -- lifetime `'a` defined here LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'a` must outlive `'static` | @@ -51,13 +57,15 @@ LL | fn iter<'a>(&'a self) -> impl Iterator> + 'a { | ++++ error: lifetime may not live long enough - --> $DIR/trait-object-nested-in-impl-trait.rs:61:9 + --> $DIR/trait-object-nested-in-impl-trait.rs:71:9 | LL | fn iter<'a>(&'a self) -> impl Iterator> { | -- lifetime `'a` defined here LL | / Iter { +LL | | LL | | current: None, LL | | remaining: self.0.iter(), +LL | | LL | | } | |_________^ returning this value requires that `'a` must outlive `'static` | diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs index d8446e58dbb63..5d868a58c0f35 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<'a, T: Foo> Foo for &'a T {} impl Foo for Box {} @@ -26,8 +30,10 @@ struct Bar(Vec>); impl Bar { fn iter(&self) -> impl Iterator> { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -37,8 +43,10 @@ struct Baz(Vec>); impl Baz { fn iter(&self) -> impl Iterator> + '_ { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -48,8 +56,10 @@ struct Bat(Vec>); impl Bat { fn iter<'a>(&'a self) -> impl Iterator> + 'a { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } @@ -59,8 +69,10 @@ struct Ban(Vec>); impl Ban { fn iter<'a>(&'a self) -> impl Iterator> { Iter { + //[nll]~^ ERROR lifetime may not live long enough current: None, - remaining: self.0.iter(), //~ ERROR E0759 + remaining: self.0.iter(), + //[base]~^ ERROR E0759 } } } diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed new file mode 100644 index 0000000000000..c363cc2d0e105 --- /dev/null +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.fixed @@ -0,0 +1,24 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `suggest-impl-trait-lifetime.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +use std::fmt::Debug; + +fn foo(d: impl Debug + 'static) { +//~^ HELP consider adding an explicit lifetime bound... + bar(d); +//~^ ERROR the parameter type `impl Debug` may not live long enough +//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds +} + +fn bar(d: impl Debug + 'static) { + println!("{:?}", d) +} + +fn main() { + foo("hi"); +} diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs new file mode 100644 index 0000000000000..dd275f6630b86 --- /dev/null +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.rs @@ -0,0 +1,24 @@ +// FIXME(nll): On NLL stabilization, this should be replace +// `suggest-impl-trait-lifetime.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll +// compile-flags: -Zborrowck=mir + +// run-rustfix + +use std::fmt::Debug; + +fn foo(d: impl Debug) { +//~^ HELP consider adding an explicit lifetime bound... + bar(d); +//~^ ERROR the parameter type `impl Debug` may not live long enough +//~| NOTE ...so that the type `impl Debug` will meet its required lifetime bounds +} + +fn bar(d: impl Debug + 'static) { + println!("{:?}", d) +} + +fn main() { + foo("hi"); +} diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr similarity index 89% rename from src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr rename to src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr index cf912f4aac201..41226fdf9fed1 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime-nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `impl Debug` may not live long enough - --> $DIR/suggest-impl-trait-lifetime.rs:7:5 + --> $DIR/suggest-impl-trait-lifetime-nll.rs:13:5 | LL | bar(d); | ^^^^^^ ...so that the type `impl Debug` will meet its required lifetime bounds diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed index 65aab97d3d716..75ff26c04352b 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.fixed @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `suggest-impl-trait-lifetime-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix use std::fmt::Debug; diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs index fb1848d130f77..b93fe103a4abf 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.rs @@ -1,3 +1,8 @@ +// FIXME(nll): On NLL stabilization, this should be replaced by +// `suggest-impl-trait-lifetime-nll.rs`. Compiletest has +// problems with rustfix and revisions. +// ignore-compare-mode-nll + // run-rustfix use std::fmt::Debug; diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr index 4a99c3a14d7bb..85f36ea78aa1d 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr @@ -1,11 +1,11 @@ error[E0310]: the parameter type `impl Debug` may not live long enough - --> $DIR/suggest-impl-trait-lifetime.rs:7:5 + --> $DIR/suggest-impl-trait-lifetime.rs:12:5 | LL | bar(d); | ^^^ ...so that the type `impl Debug` will meet its required lifetime bounds... | note: ...that is required by this bound - --> $DIR/suggest-impl-trait-lifetime.rs:12:24 + --> $DIR/suggest-impl-trait-lifetime.rs:17:24 | LL | fn bar(d: impl Debug + 'static) { | ^^^^^^^ diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.stderr b/src/test/ui/traits/object/supertrait-lifetime-bound.base.stderr similarity index 83% rename from src/test/ui/traits/object/supertrait-lifetime-bound.stderr rename to src/test/ui/traits/object/supertrait-lifetime-bound.base.stderr index c3d7f8cd0c1cd..8d1ef324c817a 100644 --- a/src/test/ui/traits/object/supertrait-lifetime-bound.stderr +++ b/src/test/ui/traits/object/supertrait-lifetime-bound.base.stderr @@ -1,11 +1,11 @@ error[E0477]: the type `(dyn Bar<&'a u32> + 'static)` does not fulfill the required lifetime - --> $DIR/supertrait-lifetime-bound.rs:10:5 + --> $DIR/supertrait-lifetime-bound.rs:14:5 | LL | test1::, _>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must satisfy the static lifetime as required by this binding - --> $DIR/supertrait-lifetime-bound.rs:5:22 + --> $DIR/supertrait-lifetime-bound.rs:9:22 | LL | fn test1, S>() { } | ^^^^^^ diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr b/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr index ed2f8624357bb..271c6a10998b7 100644 --- a/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr +++ b/src/test/ui/traits/object/supertrait-lifetime-bound.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/supertrait-lifetime-bound.rs:10:5 + --> $DIR/supertrait-lifetime-bound.rs:14:5 | LL | fn test2<'a>() { | -- lifetime `'a` defined here diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.rs b/src/test/ui/traits/object/supertrait-lifetime-bound.rs index 5349771693a2a..a57151853e003 100644 --- a/src/test/ui/traits/object/supertrait-lifetime-bound.rs +++ b/src/test/ui/traits/object/supertrait-lifetime-bound.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + trait Foo: 'static { } trait Bar: Foo { } @@ -8,7 +12,8 @@ fn test2<'a>() { // Here: the type `dyn Bar<&'a u32>` references `'a`, // and so it does not outlive `'static`. test1::, _>(); - //~^ ERROR the type `(dyn Bar<&'a u32> + 'static)` does not fulfill the required lifetime + //[base]~^ ERROR the type `(dyn Bar<&'a u32> + 'static)` does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr similarity index 85% rename from src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr rename to src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr index 641e5c97c10fb..e1831c5617fcf 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-checking-test-3.rs:13:13 + --> $DIR/type-checking-test-3.rs:16:13 | LL | let _ = x as &dyn Bar<'a>; // Error | ^ lifetime mismatch @@ -7,14 +7,14 @@ LL | let _ = x as &dyn Bar<'a>; // Error = note: expected trait object `dyn Bar<'a>` found trait object `dyn Bar<'static>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-3.rs:12:16 + --> $DIR/type-checking-test-3.rs:15:16 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/type-checking-test-3.rs:18:13 + --> $DIR/type-checking-test-3.rs:22:13 | LL | let _ = x as &dyn Bar<'static>; // Error | ^ lifetime mismatch @@ -22,7 +22,7 @@ LL | let _ = x as &dyn Bar<'static>; // Error = note: expected trait object `dyn Bar<'static>` found trait object `dyn Bar<'a>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-3.rs:17:16 + --> $DIR/type-checking-test-3.rs:21:16 | LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { | ^^ diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr new file mode 100644 index 0000000000000..983027d9b164b --- /dev/null +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.nll.stderr @@ -0,0 +1,18 @@ +error: lifetime may not live long enough + --> $DIR/type-checking-test-3.rs:16: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` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-3.rs:22: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` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs index 49c24e404dc6e..89e8821d34e69 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-3.rs @@ -1,4 +1,7 @@ +// revisions: base nll // ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![feature(trait_upcasting)] #![allow(incomplete_features)] @@ -11,12 +14,14 @@ fn test_correct(x: &dyn Foo<'static>) { fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'a>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong2<'a>(x: &dyn Foo<'a>) { let _ = x as &dyn Bar<'static>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr similarity index 88% rename from src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr rename to src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr index d4bb9350b0b4e..c343698f27fb5 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-checking-test-4.rs:17:13 + --> $DIR/type-checking-test-4.rs:20:13 | LL | let _ = x as &dyn Bar<'static, 'a>; // Error | ^ lifetime mismatch @@ -7,14 +7,14 @@ LL | let _ = x as &dyn Bar<'static, 'a>; // Error = note: expected trait object `dyn Bar<'static, 'a>` found trait object `dyn Bar<'static, 'static>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-4.rs:16:16 + --> $DIR/type-checking-test-4.rs:19:16 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types - --> $DIR/type-checking-test-4.rs:22:13 + --> $DIR/type-checking-test-4.rs:26:13 | LL | let _ = x as &dyn Bar<'a, 'static>; // Error | ^ lifetime mismatch @@ -22,14 +22,14 @@ LL | let _ = x as &dyn Bar<'a, 'static>; // Error = note: expected trait object `dyn Bar<'a, 'static>` found trait object `dyn Bar<'static, 'static>` note: the lifetime `'a` as defined here... - --> $DIR/type-checking-test-4.rs:21:16 + --> $DIR/type-checking-test-4.rs:25:16 | LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { | ^^ = note: ...does not necessarily outlive the static lifetime error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:27:27 + --> $DIR/type-checking-test-4.rs:32:27 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -42,12 +42,12 @@ LL | y.get_b() // ERROR | - ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/type-checking-test-4.rs:29:5 + --> $DIR/type-checking-test-4.rs:34:5 | LL | y.get_b() // ERROR | ^^^^^^^^^ note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:26:48 + --> $DIR/type-checking-test-4.rs:31:48 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here @@ -56,7 +56,7 @@ LL | y.get_b() // ERROR | --------- because of this returned expression error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:33:5 + --> $DIR/type-checking-test-4.rs:39:5 | LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -64,7 +64,7 @@ LL | <_ as Bar>::get_b(x) // ERROR | ^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:32:48 + --> $DIR/type-checking-test-4.rs:38:48 | LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here @@ -72,7 +72,7 @@ LL | <_ as Bar>::get_b(x) // ERROR | -------------------- because of this returned expression error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:38:15 + --> $DIR/type-checking-test-4.rs:45:15 | LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -80,7 +80,7 @@ LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR | ----------^^------------- ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:37:48 + --> $DIR/type-checking-test-4.rs:44:48 | LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here @@ -88,7 +88,7 @@ LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR | ---------------------------- because of this returned expression error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/type-checking-test-4.rs:43:27 + --> $DIR/type-checking-test-4.rs:51:27 | LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ------------ this data with lifetime `'a`... @@ -104,12 +104,12 @@ LL | z.get_b() // ERROR | - ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/type-checking-test-4.rs:47:5 + --> $DIR/type-checking-test-4.rs:55:5 | LL | z.get_b() // ERROR | ^^^^^^^^^ note: `'static` lifetime requirement introduced by the return type - --> $DIR/type-checking-test-4.rs:42:48 + --> $DIR/type-checking-test-4.rs:50:48 | LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | ^^^^^^^ `'static` requirement introduced here diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr new file mode 100644 index 0000000000000..9b69bab56aec3 --- /dev/null +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.nll.stderr @@ -0,0 +1,52 @@ +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:20: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` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:26: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` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:34: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` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:39:5 + | +LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +LL | <_ as Bar>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:45:5 + | +LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/type-checking-test-4.rs:55:5 + | +LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | -- lifetime `'a` defined here +... +LL | z.get_b() // ERROR + | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs index 95698fd1e1a80..575d60a5e56d4 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs @@ -1,4 +1,7 @@ +// revisions: base nll // ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![feature(trait_upcasting)] #![allow(incomplete_features)] @@ -15,36 +18,42 @@ fn test_correct(x: &dyn Foo<'static>) { fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'static, 'a>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { let _ = x as &dyn Bar<'a, 'static>; // Error - //~^ ERROR mismatched types + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { let y = x as &dyn Bar<'_, '_>; - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement y.get_b() // ERROR + //[nll]~^ ERROR lifetime may not live long enough } fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { <_ as Bar>::get_b(x) // ERROR - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { <_ as Bar<'_, '_>>::get_b(x) // ERROR - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[nll]~^^ ERROR lifetime may not live long enough } fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { let y = x as &dyn Bar<'_, '_>; - //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + //[base]~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement y.get_b(); // ERROR let z = y; z.get_b() // ERROR + //[nll]~^ ERROR lifetime may not live long enough } fn main() {}