diff options
Diffstat (limited to '')
45 files changed, 468 insertions, 145 deletions
diff --git a/tests/ui/nll/closure-malformed-projection-input-issue-102800.stderr b/tests/ui/nll/closure-malformed-projection-input-issue-102800.stderr index 46dba0064..aeb0a1394 100644 --- a/tests/ui/nll/closure-malformed-projection-input-issue-102800.stderr +++ b/tests/ui/nll/closure-malformed-projection-input-issue-102800.stderr @@ -15,6 +15,7 @@ LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; | = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... = note: ...but `Trait` is actually implemented for the type `&'static ()` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 2 previous errors diff --git a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 1aa7de1e1..a20f885fe 100644 --- a/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/tests/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -25,10 +25,13 @@ LL | | T: Trait<'a>, error[E0309]: the parameter type `T` may not live long enough --> $DIR/propagate-from-trait-match.rs:43:9 | +LL | fn supply<'a, T>(value: T) + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | require(value); | ^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: Trait<'a> + 'a, | ++++ diff --git a/tests/ui/nll/coroutine-distinct-lifetime.rs b/tests/ui/nll/coroutine-distinct-lifetime.rs new file mode 100644 index 000000000..0483b8858 --- /dev/null +++ b/tests/ui/nll/coroutine-distinct-lifetime.rs @@ -0,0 +1,25 @@ +#![feature(coroutines)] + +// Test for issue #47189. Here, both `s` and `t` are live for the +// coroutine's lifetime, but within the coroutine they have distinct +// lifetimes. We accept this code -- even though the borrow extends +// over a yield -- because the data that is borrowed (`*x`) is not +// stored on the stack. + +// check-pass + +fn foo(x: &mut u32) { + move || { + let s = &mut *x; + yield; + *s += 1; + + let t = &mut *x; + yield; + *t += 1; + }; +} + +fn main() { + foo(&mut 0); +} diff --git a/tests/ui/nll/coroutine-upvar-mutability.rs b/tests/ui/nll/coroutine-upvar-mutability.rs new file mode 100644 index 000000000..12853b16b --- /dev/null +++ b/tests/ui/nll/coroutine-upvar-mutability.rs @@ -0,0 +1,14 @@ +// Check that coroutines respect the muatability of their upvars. + +#![feature(coroutines)] + +fn mutate_upvar() { + let x = 0; + move || { + x = 1; + //~^ ERROR + yield; + }; +} + +fn main() {} diff --git a/tests/ui/nll/coroutine-upvar-mutability.stderr b/tests/ui/nll/coroutine-upvar-mutability.stderr new file mode 100644 index 000000000..464bbc769 --- /dev/null +++ b/tests/ui/nll/coroutine-upvar-mutability.stderr @@ -0,0 +1,12 @@ +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/coroutine-upvar-mutability.rs:8:9 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +LL | move || { +LL | x = 1; + | ^^^^^ cannot assign + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/nll/extra-unused-mut.rs b/tests/ui/nll/extra-unused-mut.rs index 340f2952a..b04e39542 100644 --- a/tests/ui/nll/extra-unused-mut.rs +++ b/tests/ui/nll/extra-unused-mut.rs @@ -2,7 +2,7 @@ // check-pass -#![feature(generators)] +#![feature(coroutines)] #![deny(unused_mut)] fn ref_argument(ref _y: i32) {} @@ -16,7 +16,7 @@ fn mutable_upvar() { } // #50897 -fn generator_mutable_upvar() { +fn coroutine_mutable_upvar() { let mut x = 0; move || { x = 1; diff --git a/tests/ui/nll/generator-distinct-lifetime.rs b/tests/ui/nll/generator-distinct-lifetime.rs deleted file mode 100644 index 90fe6b569..000000000 --- a/tests/ui/nll/generator-distinct-lifetime.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![feature(generators)] - -// Test for issue #47189. Here, both `s` and `t` are live for the -// generator's lifetime, but within the generator they have distinct -// lifetimes. We accept this code -- even though the borrow extends -// over a yield -- because the data that is borrowed (`*x`) is not -// stored on the stack. - -// check-pass - -fn foo(x: &mut u32) { - move || { - let s = &mut *x; - yield; - *s += 1; - - let t = &mut *x; - yield; - *t += 1; - }; -} - -fn main() { - foo(&mut 0); -} diff --git a/tests/ui/nll/generator-upvar-mutability.rs b/tests/ui/nll/generator-upvar-mutability.rs deleted file mode 100644 index c49ea15b8..000000000 --- a/tests/ui/nll/generator-upvar-mutability.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Check that generators respect the muatability of their upvars. - -#![feature(generators)] - -fn mutate_upvar() { - let x = 0; - move || { - x = 1; - //~^ ERROR - yield; - }; -} - -fn main() {} diff --git a/tests/ui/nll/generator-upvar-mutability.stderr b/tests/ui/nll/generator-upvar-mutability.stderr deleted file mode 100644 index 31b061b61..000000000 --- a/tests/ui/nll/generator-upvar-mutability.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/generator-upvar-mutability.rs:8:9 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -LL | move || { -LL | x = 1; - | ^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/nll/issue-48623-coroutine.rs b/tests/ui/nll/issue-48623-coroutine.rs new file mode 100644 index 000000000..bd11aaf14 --- /dev/null +++ b/tests/ui/nll/issue-48623-coroutine.rs @@ -0,0 +1,18 @@ +// run-pass +#![allow(path_statements)] +#![allow(dead_code)] + +#![feature(coroutines, coroutine_trait)] + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +fn reborrow_from_coroutine(r: &mut ()) { + let d = WithDrop; + move || { d; yield; &mut *r }; //~ WARN unused coroutine that must be used +} + +fn main() {} diff --git a/tests/ui/nll/issue-48623-coroutine.stderr b/tests/ui/nll/issue-48623-coroutine.stderr new file mode 100644 index 000000000..1b7b1735a --- /dev/null +++ b/tests/ui/nll/issue-48623-coroutine.stderr @@ -0,0 +1,11 @@ +warning: unused coroutine that must be used + --> $DIR/issue-48623-coroutine.rs:15:5 + | +LL | move || { d; yield; &mut *r }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: coroutines are lazy and do nothing unless resumed + = note: `#[warn(unused_must_use)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/nll/issue-48623-generator.rs b/tests/ui/nll/issue-48623-generator.rs deleted file mode 100644 index 08d2584ee..000000000 --- a/tests/ui/nll/issue-48623-generator.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass -#![allow(path_statements)] -#![allow(dead_code)] - -#![feature(generators, generator_trait)] - -struct WithDrop; - -impl Drop for WithDrop { - fn drop(&mut self) {} -} - -fn reborrow_from_generator(r: &mut ()) { - let d = WithDrop; - move || { d; yield; &mut *r }; //~ WARN unused generator that must be used -} - -fn main() {} diff --git a/tests/ui/nll/issue-48623-generator.stderr b/tests/ui/nll/issue-48623-generator.stderr deleted file mode 100644 index bfdfca210..000000000 --- a/tests/ui/nll/issue-48623-generator.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: unused generator that must be used - --> $DIR/issue-48623-generator.rs:15:5 - | -LL | move || { d; yield; &mut *r }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/nll/issue-55850.rs b/tests/ui/nll/issue-55850.rs index e6279bd02..fc873af94 100644 --- a/tests/ui/nll/issue-55850.rs +++ b/tests/ui/nll/issue-55850.rs @@ -1,16 +1,16 @@ #![allow(unused_mut)] -#![feature(generators, generator_trait)] +#![feature(coroutines, coroutine_trait)] use std::marker::Unpin; -use std::ops::Generator; -use std::ops::GeneratorState::Yielded; +use std::ops::Coroutine; +use std::ops::CoroutineState::Yielded; use std::pin::Pin; pub struct GenIter<G>(G); impl <G> Iterator for GenIter<G> where - G: Generator + Unpin, + G: Coroutine + Unpin, { type Item = G::Yield; @@ -26,7 +26,7 @@ fn bug<'a>() -> impl Iterator<Item = &'a str> { GenIter(move || { let mut s = String::new(); yield &s[..] //~ ERROR cannot yield value referencing local variable `s` [E0515] - //~| ERROR borrow may still be in use when generator yields + //~| ERROR borrow may still be in use when coroutine yields }) } diff --git a/tests/ui/nll/issue-55850.stderr b/tests/ui/nll/issue-55850.stderr index 86a8cdc42..3d43817f4 100644 --- a/tests/ui/nll/issue-55850.stderr +++ b/tests/ui/nll/issue-55850.stderr @@ -7,7 +7,7 @@ LL | yield &s[..] | | `s` is borrowed here | yields a value referencing data owned by the current function -error[E0626]: borrow may still be in use when generator yields +error[E0626]: borrow may still be in use when coroutine yields --> $DIR/issue-55850.rs:28:16 | LL | yield &s[..] diff --git a/tests/ui/nll/issue-97997.stderr b/tests/ui/nll/issue-97997.stderr index 46440c021..89eaf77ad 100644 --- a/tests/ui/nll/issue-97997.stderr +++ b/tests/ui/nll/issue-97997.stderr @@ -15,6 +15,7 @@ LL | <fn(&u8) as Foo>::ASSOC; | = note: `Foo` would have to be implemented for the type `for<'a> fn(&'a u8)` = note: ...but `Foo` is actually implemented for the type `fn(&'0 u8)`, for some specific lifetime `'0` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 2 previous errors diff --git a/tests/ui/nll/issue-98589-closures-relate-named-regions.stderr b/tests/ui/nll/issue-98589-closures-relate-named-regions.stderr index d8b26f0b0..4e741abc2 100644 --- a/tests/ui/nll/issue-98589-closures-relate-named-regions.stderr +++ b/tests/ui/nll/issue-98589-closures-relate-named-regions.stderr @@ -37,10 +37,12 @@ LL | || { None::<&'a &'b ()>; }; error[E0309]: the parameter type `T` may not live long enough --> $DIR/issue-98589-closures-relate-named-regions.rs:26:10 | +LL | fn test_early_type<'a: 'a, T>() { + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | || { None::<&'a T>; }; | ^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test_early_type<'a: 'a, T: 'a>() { | ++++ @@ -48,10 +50,12 @@ LL | fn test_early_type<'a: 'a, T: 'a>() { error[E0309]: the parameter type `T` may not live long enough --> $DIR/issue-98589-closures-relate-named-regions.rs:32:10 | +LL | fn test_late_type<'a, T>() { + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | || { None::<&'a T>; }; | ^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test_late_type<'a, T: 'a>() { | ++++ diff --git a/tests/ui/nll/issue-98693.stderr b/tests/ui/nll/issue-98693.stderr index 15ca38aa2..a3d87d74a 100644 --- a/tests/ui/nll/issue-98693.stderr +++ b/tests/ui/nll/issue-98693.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/issue-98693.rs:16:9 | LL | assert_static::<T>(); - | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test<T: 'static>() { | +++++++++ diff --git a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr b/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr index e0d476a33..cab75e630 100644 --- a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr +++ b/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/min-choice-reject-ambiguous.rs:17:5 | +LL | fn test_b<'a, 'b, 'c, T>() -> impl Cap<'a> + Cap<'b> + Cap<'c> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | type_test::<'_, T>() // This should pass if we pick 'b. | ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: 'b + 'a, | ++++ @@ -12,10 +15,13 @@ LL | T: 'b + 'a, error[E0309]: the parameter type `T` may not live long enough --> $DIR/min-choice-reject-ambiguous.rs:28:5 | +LL | fn test_c<'a, 'b, 'c, T>() -> impl Cap<'a> + Cap<'b> + Cap<'c> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | type_test::<'_, T>() // This should pass if we pick 'c. | ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: 'c + 'a, | ++++ diff --git a/tests/ui/nll/missing-universe-cause-issue-114907.stderr b/tests/ui/nll/missing-universe-cause-issue-114907.stderr index c3dd4257a..988eee610 100644 --- a/tests/ui/nll/missing-universe-cause-issue-114907.stderr +++ b/tests/ui/nll/missing-universe-cause-issue-114907.stderr @@ -38,6 +38,7 @@ LL | accept(callback); | = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types --> $DIR/missing-universe-cause-issue-114907.rs:33:5 @@ -73,6 +74,8 @@ error: higher-ranked subtype error | LL | accept(callback); | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors diff --git a/tests/ui/nll/move-errors.stderr b/tests/ui/nll/move-errors.stderr index 58b8aa31d..0d994ef29 100644 --- a/tests/ui/nll/move-errors.stderr +++ b/tests/ui/nll/move-errors.stderr @@ -186,7 +186,7 @@ help: consider borrowing the pattern binding LL | F(s, ref mut t) => (), | +++ -error[E0507]: cannot move out of `x` as enum variant `Err` which is behind a shared reference +error[E0507]: cannot move out of `x` as enum variant `Ok` which is behind a shared reference --> $DIR/move-errors.rs:110:11 | LL | match *x { diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr new file mode 100644 index 000000000..6f9b33031 --- /dev/null +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.nll.stderr @@ -0,0 +1,36 @@ +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/location-insensitive-scopes-issue-116657.rs:18:1 + | +LL | fn call(x: Self) -> Self::Output; + | --------------------------------- `call` from trait +... +LL | impl<T: PlusOne> Callable for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + +error: unconstrained opaque type + --> $DIR/location-insensitive-scopes-issue-116657.rs:22:19 + | +LL | type Output = impl PlusOne; + | ^^^^^^^^^^^^ + | + = note: `Output` must be used in combination with a concrete type within the same impl + +error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds + --> $DIR/location-insensitive-scopes-issue-116657.rs:28:5 + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { + | -- ------------ opaque type defined here + | | + | hidden type `<&'a mut i32 as Callable>::Output` captures the lifetime `'a` as defined here +LL | <&mut i32 as Callable>::call(y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a { + | ++++ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0046, E0700. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr new file mode 100644 index 000000000..6f9b33031 --- /dev/null +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.polonius.stderr @@ -0,0 +1,36 @@ +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/location-insensitive-scopes-issue-116657.rs:18:1 + | +LL | fn call(x: Self) -> Self::Output; + | --------------------------------- `call` from trait +... +LL | impl<T: PlusOne> Callable for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + +error: unconstrained opaque type + --> $DIR/location-insensitive-scopes-issue-116657.rs:22:19 + | +LL | type Output = impl PlusOne; + | ^^^^^^^^^^^^ + | + = note: `Output` must be used in combination with a concrete type within the same impl + +error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds + --> $DIR/location-insensitive-scopes-issue-116657.rs:28:5 + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { + | -- ------------ opaque type defined here + | | + | hidden type `<&'a mut i32 as Callable>::Output` captures the lifetime `'a` as defined here +LL | <&mut i32 as Callable>::call(y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a` lifetime bound + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a { + | ++++ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0046, E0700. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.rs b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.rs new file mode 100644 index 000000000..ec17e0b09 --- /dev/null +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-116657.rs @@ -0,0 +1,33 @@ +// This is a non-regression test for issue #116657, where NLL and `-Zpolonius=next` computed +// different loan scopes when a member constraint was not ultimately applied. + +// revisions: nll polonius +// [polonius] compile-flags: -Zpolonius=next + +#![feature(impl_trait_in_assoc_type)] + +trait Callable { + type Output; + fn call(x: Self) -> Self::Output; +} + +trait PlusOne {} + +impl<'a> PlusOne for &'a mut i32 {} + +impl<T: PlusOne> Callable for T { + //[nll]~^ ERROR not all trait items implemented + //[polonius]~^^ ERROR not all trait items implemented + + type Output = impl PlusOne; + //[nll]~^ ERROR unconstrained opaque type + //[polonius]~^^ ERROR unconstrained opaque type +} + +fn test<'a>(y: &'a mut i32) -> impl PlusOne { + <&mut i32 as Callable>::call(y) + //[nll]~^ ERROR hidden type for `impl PlusOne` captures lifetime + //[polonius]~^^ ERROR hidden type for `impl PlusOne` captures lifetime +} + +fn main() {} diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr new file mode 100644 index 000000000..5227ca8ec --- /dev/null +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr @@ -0,0 +1,40 @@ +error[E0597]: `a` does not live long enough + --> $DIR/location-insensitive-scopes-issue-117146.rs:10:18 + | +LL | let b = |_| &a; + | --- -^ + | | || + | | |borrowed value does not live long enough + | | returning this value requires that `a` is borrowed for `'static` + | value captured here +... +LL | } + | - `a` dropped here while still borrowed + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/location-insensitive-scopes-issue-117146.rs:20:22 + | +LL | fn bad<F: Fn(&()) -> &()>(_: F) {} + | ^^^ + +error: implementation of `Fn` is not general enough + --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 + | +LL | bad(&b); + | ^^^^^^^ implementation of `Fn` is not general enough + | + = note: closure with signature `fn(&'2 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`... + = note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2` + +error: implementation of `FnOnce` is not general enough + --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 + | +LL | bad(&b); + | ^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr new file mode 100644 index 000000000..5227ca8ec --- /dev/null +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr @@ -0,0 +1,40 @@ +error[E0597]: `a` does not live long enough + --> $DIR/location-insensitive-scopes-issue-117146.rs:10:18 + | +LL | let b = |_| &a; + | --- -^ + | | || + | | |borrowed value does not live long enough + | | returning this value requires that `a` is borrowed for `'static` + | value captured here +... +LL | } + | - `a` dropped here while still borrowed + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/location-insensitive-scopes-issue-117146.rs:20:22 + | +LL | fn bad<F: Fn(&()) -> &()>(_: F) {} + | ^^^ + +error: implementation of `Fn` is not general enough + --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 + | +LL | bad(&b); + | ^^^^^^^ implementation of `Fn` is not general enough + | + = note: closure with signature `fn(&'2 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`... + = note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2` + +error: implementation of `FnOnce` is not general enough + --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 + | +LL | bad(&b); + | ^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.rs b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.rs new file mode 100644 index 000000000..c165e7a1d --- /dev/null +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.rs @@ -0,0 +1,20 @@ +// This is a non-regression test for issue #117146, where NLL and `-Zpolonius=next` computed +// different loan scopes when a region flowed into an SCC whose representative was an existential +// region. + +// revisions: nll polonius +// [polonius] compile-flags: -Zpolonius=next + +fn main() { + let a = (); + let b = |_| &a; + //[nll]~^ ERROR `a` does not live long enough + //[polonius]~^^ ERROR `a` does not live long enough + bad(&b); + //[nll]~^ ERROR implementation of `Fn` + //[nll]~| ERROR implementation of `FnOnce` + //[polonius]~^^^ ERROR implementation of `Fn` + //[polonius]~| ERROR implementation of `FnOnce` +} + +fn bad<F: Fn(&()) -> &()>(_: F) {} diff --git a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr index b945ffedd..804071a3e 100644 --- a/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr +++ b/tests/ui/nll/relate_tys/impl-fn-ignore-binder-via-bottom.stderr @@ -15,6 +15,7 @@ LL | let _x = <fn(&())>::make_f(); | = note: `Y` would have to be implemented for the type `for<'a> fn(&'a ())` = note: ...but `Y` is actually implemented for the type `fn(&'0 ())`, for some specific lifetime `'0` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Y` is not general enough --> $DIR/impl-fn-ignore-binder-via-bottom.rs:30:14 @@ -24,6 +25,7 @@ LL | let _x = <fn(&())>::make_f(); | = note: `Y` would have to be implemented for the type `for<'a> fn(&'a ())` = note: ...but `Y` is actually implemented for the type `fn(&'0 ())`, for some specific lifetime `'0` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 3 previous errors diff --git a/tests/ui/nll/ty-outlives/impl-trait-outlives.stderr b/tests/ui/nll/ty-outlives/impl-trait-outlives.stderr index 64b08a9b3..ff9d75057 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-outlives.stderr +++ b/tests/ui/nll/ty-outlives/impl-trait-outlives.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/impl-trait-outlives.rs:11:5 | +LL | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: Debug + 'a, | ++++ @@ -12,10 +15,13 @@ LL | T: Debug + 'a, error[E0309]: the parameter type `T` may not live long enough --> $DIR/impl-trait-outlives.rs:26:5 | +LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: 'b + Debug + 'a, | ++++ diff --git a/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr b/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr index d949e29b2..6de023ffd 100644 --- a/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr +++ b/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/projection-implied-bounds.rs:30:36 | LL | twice(value, |value_ref, item| invoke2(value_ref, item)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn generic2<T: Iterator + 'static>(value: T) { | +++++++++ diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 433024c30..4f93fb4ea 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -25,11 +25,16 @@ LL | | T: Iterator, error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough --> $DIR/projection-no-regions-closure.rs:25:31 | +LL | fn no_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a> + | -- the associated type `<T as Iterator>::Item` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds | - = help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... - = note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds +help: consider adding an explicit lifetime bound + | +LL | T: Iterator, <T as Iterator>::Item: 'a + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ note: external requirements --> $DIR/projection-no-regions-closure.rs:34:23 @@ -82,11 +87,16 @@ LL | | T: 'b + Iterator, error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough --> $DIR/projection-no-regions-closure.rs:42:31 | +LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a> + | -- the associated type `<T as Iterator>::Item` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(x, |mut y| Box::new(y.next())) - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound | - = help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... - = note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds +LL | T: 'b + Iterator, <T as Iterator>::Item: 'a + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ note: external requirements --> $DIR/projection-no-regions-closure.rs:52:23 diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-fn.stderr b/tests/ui/nll/ty-outlives/projection-no-regions-fn.stderr index e0ff544fe..da76ac1c4 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-fn.stderr +++ b/tests/ui/nll/ty-outlives/projection-no-regions-fn.stderr @@ -1,20 +1,30 @@ error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough --> $DIR/projection-no-regions-fn.rs:13:5 | +LL | fn no_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a> + | -- the associated type `<T as Iterator>::Item` must be valid for the lifetime `'a` as defined here... +... LL | Box::new(x.next()) - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds | - = help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... - = note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds +help: consider adding an explicit lifetime bound + | +LL | T: Iterator, <T as Iterator>::Item: 'a + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0309]: the associated type `<T as Iterator>::Item` may not live long enough --> $DIR/projection-no-regions-fn.rs:28:5 | +LL | fn wrong_region<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a> + | -- the associated type `<T as Iterator>::Item` must be valid for the lifetime `'a` as defined here... +... LL | Box::new(x.next()) - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound | - = help: consider adding an explicit lifetime bound `<T as Iterator>::Item: 'a`... - = note: ...so that the type `<T as Iterator>::Item` will meet its required lifetime bounds +LL | T: 'b + Iterator, <T as Iterator>::Item: 'a + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr index ebdce7bc1..dda603981 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -27,10 +27,13 @@ LL | | T: Anything<'b>, error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:45:39 | +LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: Anything<'b> + 'a, | ++++ @@ -77,10 +80,13 @@ LL | | 'a: 'a, error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:56:39 | +LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: Anything<'b> + 'a, | ++++ diff --git a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index dbad8e478..c157e89ff 100644 --- a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -26,11 +26,13 @@ LL | | T: Anything<'b, 'c>, error[E0309]: the associated type `<T as Anything<'?5, '?6>>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:38:39 | +LL | fn no_relationships_late<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) + | -- the associated type `<T as Anything<'?5, '?6>>::AssocType` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ ...so that the type `<T as Anything<'?5, '?6>>::AssocType` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<T as Anything<'?5, '?6>>::AssocType: 'a`... - = note: ...so that the type `<T as Anything<'?5, '?6>>::AssocType` will meet its required lifetime bounds note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 @@ -60,11 +62,13 @@ LL | | 'a: 'a, error[E0309]: the associated type `<T as Anything<'?6, '?7>>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:48:39 | +LL | fn no_relationships_early<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) + | -- the associated type `<T as Anything<'?6, '?7>>::AssocType` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ ...so that the type `<T as Anything<'?6, '?7>>::AssocType` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<T as Anything<'?6, '?7>>::AssocType: 'a`... - = note: ...so that the type `<T as Anything<'?6, '?7>>::AssocType` will meet its required lifetime bounds note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr index b4435fe06..1fa74f67c 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr +++ b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr @@ -1,11 +1,13 @@ error[E0309]: the associated type `<T as MyTrait<'_>>::Output` may not live long enough --> $DIR/projection-where-clause-env-wrong-bound.rs:15:5 | +LL | fn foo1<'a, 'b, T>() -> &'a () + | -- the associated type `<T as MyTrait<'_>>::Output` must be valid for the lifetime `'a` as defined here... +... LL | bar::<T::Output>() - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ ...so that the type `<T as MyTrait<'_>>::Output` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<T as MyTrait<'_>>::Output: 'a`... - = note: ...so that the type `<T as MyTrait<'_>>::Output` will meet its required lifetime bounds error: aborting due to previous error diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr index ddeaf3c1f..c8dbe4ebc 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr +++ b/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr @@ -1,11 +1,13 @@ error[E0309]: the associated type `<T as MyTrait<'_>>::Output` may not live long enough --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 | +LL | fn foo1<'a, 'b, T>() -> &'a () + | -- the associated type `<T as MyTrait<'_>>::Output` must be valid for the lifetime `'a` as defined here... +... LL | bar::<<T as MyTrait<'a>>::Output>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `<T as MyTrait<'_>>::Output` will meet its required lifetime bounds | = help: consider adding an explicit lifetime bound `<T as MyTrait<'_>>::Output: 'a`... - = note: ...so that the type `<T as MyTrait<'_>>::Output` will meet its required lifetime bounds error: aborting due to previous error diff --git a/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr b/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr index 0df44644d..f78708dc4 100644 --- a/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr +++ b/tests/ui/nll/ty-outlives/projection-where-clause-none.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-where-clause-none.rs:14:5 | +LL | fn foo<'a, T>() -> &'a () + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | bar::<T::Output>() | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: MyTrait<'a> + 'a, | ++++ diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index f58d49d84..59e29e9a4 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -46,10 +46,12 @@ LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:31 | +LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | twice(cell, value, |a, b| invoke(a, b)); | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn generic_fail<'a, T: 'a>(cell: Cell<&'a ()>, value: T) { | ++++ diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index ddad1d205..3468c5ad3 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -25,10 +25,13 @@ LL | | T: Debug, error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:27 | +LL | fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | with_signature(x, |y| y) | ^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: Debug + 'a, | ++++ @@ -36,10 +39,13 @@ LL | T: Debug + 'a, error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:41:5 | +LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: 'b + Debug + 'a, | ++++ diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index bb455e9ae..cef4a0f1e 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -24,10 +24,13 @@ LL | fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:32:9 | +LL | fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | require(&x, &y) | ^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) { | ++++ @@ -84,10 +87,13 @@ LL | | T: 'b, error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:65:9 | +LL | fn wrong_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | require(&x, &y) | ^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: 'b + 'a, | ++++ diff --git a/tests/ui/nll/ty-outlives/ty-param-fn-body.stderr b/tests/ui/nll/ty-outlives/ty-param-fn-body.stderr index 5fb69255d..73f01ff15 100644 --- a/tests/ui/nll/ty-outlives/ty-param-fn-body.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-fn-body.stderr @@ -1,10 +1,12 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn-body.rs:17:5 | +LL | fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) { + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | outlives(cell, t) | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn region_static<'a, T: 'a>(cell: Cell<&'a usize>, t: T) { | ++++ diff --git a/tests/ui/nll/ty-outlives/ty-param-fn.stderr b/tests/ui/nll/ty-outlives/ty-param-fn.stderr index 825b26d2f..56bd41051 100644 --- a/tests/ui/nll/ty-outlives/ty-param-fn.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-fn.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn.rs:9:5 | +LL | fn no_region<'a, T>(x: Box<T>) -> Box<Debug + 'a> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: Debug + 'a, | ++++ @@ -12,10 +15,13 @@ LL | T: Debug + 'a, error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn.rs:24:5 | +LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a> + | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... +... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | T: 'b + Debug + 'a, | ++++ diff --git a/tests/ui/nll/type-check-pointer-comparisons.stderr b/tests/ui/nll/type-check-pointer-comparisons.stderr index 0d8480a42..37098b585 100644 --- a/tests/ui/nll/type-check-pointer-comparisons.stderr +++ b/tests/ui/nll/type-check-pointer-comparisons.stderr @@ -61,6 +61,8 @@ LL | x == y; = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance help: `'a` and `'b` must be the same: replace one with the other + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:16:5 @@ -93,6 +95,8 @@ LL | f == g; = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance help: `'a` and `'b` must be the same: replace one with the other + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors diff --git a/tests/ui/nll/user-annotations/normalization-2.stderr b/tests/ui/nll/user-annotations/normalization-2.stderr index 6b0dcb414..dcf049a7a 100644 --- a/tests/ui/nll/user-annotations/normalization-2.stderr +++ b/tests/ui/nll/user-annotations/normalization-2.stderr @@ -131,6 +131,7 @@ help: the following changes may resolve your lifetime errors | = help: replace `'a` with `'static` = help: replace `'b` with `'static` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: lifetime may not live long enough --> $DIR/normalization-2.rs:89:5 @@ -185,6 +186,7 @@ help: the following changes may resolve your lifetime errors | = help: replace `'a` with `'static` = help: replace `'b` with `'static` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: lifetime may not live long enough --> $DIR/normalization-2.rs:117:5 diff --git a/tests/ui/nll/user-annotations/normalization-infer.stderr b/tests/ui/nll/user-annotations/normalization-infer.stderr index 12854ab68..41d563a55 100644 --- a/tests/ui/nll/user-annotations/normalization-infer.stderr +++ b/tests/ui/nll/user-annotations/normalization-infer.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/normalization-infer.rs:11:12 | LL | let _: <(_,) as Tr>::Ty = a; - | ^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `A` must be valid for the static lifetime... + | ...so that the type `A` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test1<A: 'static, B, C, D>(a: A, b: B, c: C) { | +++++++++ @@ -13,9 +16,12 @@ error[E0310]: the parameter type `B` may not live long enough --> $DIR/normalization-infer.rs:12:5 | LL | Some::<<(_,) as Tr>::Ty>(b); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `B` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the parameter type `B` must be valid for the static lifetime... + | ...so that the type `B` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test1<A, B: 'static, C, D>(a: A, b: B, c: C) { | +++++++++ @@ -24,9 +30,12 @@ error[E0310]: the parameter type `C` may not live long enough --> $DIR/normalization-infer.rs:13:11 | LL | || -> <(_,) as Tr>::Ty { c }; - | ^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `C` must be valid for the static lifetime... + | ...so that the type `C` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test1<A, B, C: 'static, D>(a: A, b: B, c: C) { | +++++++++ @@ -35,9 +44,12 @@ error[E0310]: the parameter type `D` may not live long enough --> $DIR/normalization-infer.rs:14:6 | LL | |d: <(_,) as Tr>::Ty| -> D { d }; - | ^ ...so that the type `D` will meet its required lifetime bounds + | ^ + | | + | the parameter type `D` must be valid for the static lifetime... + | ...so that the type `D` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test1<A, B, C, D: 'static>(a: A, b: B, c: C) { | +++++++++ @@ -46,9 +58,12 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/normalization-infer.rs:28:12 | LL | let _: Alias<_, _> = (a, 0u8); - | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | ^^^^^^^^^^^ + | | + | the parameter type `A` must be valid for the static lifetime... + | ...so that the type `A` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test2<A: 'static, B, C>(a: A, b: B, c: C) { | +++++++++ @@ -57,9 +72,12 @@ error[E0310]: the parameter type `B` may not live long enough --> $DIR/normalization-infer.rs:29:5 | LL | Some::<Alias<_, _>>((b, 0u8)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `B` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the parameter type `B` must be valid for the static lifetime... + | ...so that the type `B` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test2<A, B: 'static, C>(a: A, b: B, c: C) { | +++++++++ @@ -68,9 +86,12 @@ error[E0310]: the parameter type `C` may not live long enough --> $DIR/normalization-infer.rs:30:11 | LL | || -> Alias<_, _> { (c, 0u8) }; - | ^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | ^^^^^^^^^^^ + | | + | the parameter type `C` must be valid for the static lifetime... + | ...so that the type `C` will meet its required lifetime bounds | -help: consider adding an explicit lifetime bound... +help: consider adding an explicit lifetime bound | LL | fn test2<A, B, C: 'static>(a: A, b: B, c: C) { | +++++++++ |