summaryrefslogtreecommitdiffstats
path: root/tests/ui/lifetimes
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/lifetimes
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/ui/lifetimes/borrowck-let-suggestion.stderr4
-rw-r--r--tests/ui/lifetimes/issue-105675.stderr1
-rw-r--r--tests/ui/lifetimes/issue-26638.stderr4
-rw-r--r--tests/ui/lifetimes/issue-76168-hr-outlives-3.rs19
-rw-r--r--tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr51
-rw-r--r--tests/ui/lifetimes/issue-77175.rs2
-rw-r--r--tests/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr49
-rw-r--r--tests/ui/lifetimes/lifetime-errors/issue_74400.stderr7
-rw-r--r--tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed2
-rw-r--r--tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr20
10 files changed, 124 insertions, 35 deletions
diff --git a/tests/ui/lifetimes/borrowck-let-suggestion.stderr b/tests/ui/lifetimes/borrowck-let-suggestion.stderr
index da0078698..621196647 100644
--- a/tests/ui/lifetimes/borrowck-let-suggestion.stderr
+++ b/tests/ui/lifetimes/borrowck-let-suggestion.stderr
@@ -10,6 +10,10 @@ LL | x.use_mut();
| - borrow later used here
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider consuming the `Vec<i32>` when turning it into an `Iterator`
+ |
+LL | let mut x = vec![1].into_iter();
+ | ~~~~~~~~~
help: consider using a `let` binding to create a longer lived value
|
LL ~ let binding = vec![1];
diff --git a/tests/ui/lifetimes/issue-105675.stderr b/tests/ui/lifetimes/issue-105675.stderr
index 66415f72b..54ecd35ed 100644
--- a/tests/ui/lifetimes/issue-105675.stderr
+++ b/tests/ui/lifetimes/issue-105675.stderr
@@ -81,6 +81,7 @@ note: the lifetime requirement is introduced here
|
LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider specifying the type of the closure parameters
|
LL | let f = |x: &_, y: &_, z: u32| ();
diff --git a/tests/ui/lifetimes/issue-26638.stderr b/tests/ui/lifetimes/issue-26638.stderr
index 30afcecf8..e61158a5d 100644
--- a/tests/ui/lifetimes/issue-26638.stderr
+++ b/tests/ui/lifetimes/issue-26638.stderr
@@ -44,6 +44,10 @@ LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.ne
|
= note: expected reference `&str`
found enum `Option<&str>`
+help: consider using `Option::expect` to unwrap the `Option<&str>` value, panicking if the value is an `Option::None`
+ |
+LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next().expect("REASON") }
+ | +++++++++++++++++
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/issue-26638.rs:5:47
diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
new file mode 100644
index 000000000..b0b6b318d
--- /dev/null
+++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
@@ -0,0 +1,19 @@
+// edition:2018
+
+#![feature(unboxed_closures)]
+use std::future::Future;
+
+async fn wrapper<F>(f: F)
+//~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+where
+ F:,
+ for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+{
+ //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+ let mut i = 41;
+ &mut i;
+}
+
+fn main() {}
diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
new file mode 100644
index 000000000..5b77051dc
--- /dev/null
+++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
@@ -0,0 +1,51 @@
+error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+ --> $DIR/issue-76168-hr-outlives-3.rs:6:1
+ |
+LL | / async fn wrapper<F>(f: F)
+LL | |
+LL | |
+LL | |
+LL | | where
+LL | | F:,
+LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+ | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+ |
+ = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
+
+error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+ --> $DIR/issue-76168-hr-outlives-3.rs:6:10
+ |
+LL | async fn wrapper<F>(f: F)
+ | ^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+ |
+ = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
+
+error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+ --> $DIR/issue-76168-hr-outlives-3.rs:13:1
+ |
+LL | / {
+LL | |
+LL | | let mut i = 41;
+LL | | &mut i;
+LL | | }
+ | |_^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+ |
+ = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
+
+error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+ --> $DIR/issue-76168-hr-outlives-3.rs:6:1
+ |
+LL | / async fn wrapper<F>(f: F)
+LL | |
+LL | |
+LL | |
+LL | | where
+LL | | F:,
+LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+ | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+ |
+ = help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/lifetimes/issue-77175.rs b/tests/ui/lifetimes/issue-77175.rs
index 2282752b6..8072691ae 100644
--- a/tests/ui/lifetimes/issue-77175.rs
+++ b/tests/ui/lifetimes/issue-77175.rs
@@ -5,7 +5,7 @@
// Prior to the fix, the compiler complained that the 'a lifetime was only used
// once. This was obviously wrong since the lifetime is used twice: For the s3
// parameter and the return type. The issue was caused by the compiler
-// desugaring the async function into a generator that uses only a single
+// desugaring the async function into a coroutine that uses only a single
// lifetime, which then the validator complained about becauase of the
// single_use_lifetimes constraints.
async fn bar<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str {
diff --git a/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
index affb4e8d0..235092e24 100644
--- a/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
+++ b/tests/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:19:10
|
LL | foo: &'static T
- | ^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the reference type `&'static T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | struct Foo<T: 'static> {
| +++++++++
@@ -13,20 +16,24 @@ error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
|
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
- | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
+ | -- ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
+ | |
+ | the parameter type `K` must be valid for the lifetime `'a` as defined here...
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
-LL | impl<K: 'a> Nested<K> {
- | ++++
+LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() where K: 'a {
+ | +++++++++++
error[E0309]: the parameter type `M` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
|
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
- | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
+ | -- ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
+ | |
+ | the parameter type `M` must be valid for the lifetime `'a` as defined here...
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b + 'a>() {
| ++++
@@ -35,29 +42,37 @@ error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
|
LL | fn foo<'a, L: X<&'a Nested<K>>>();
- | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
+ | -- ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
+ | |
+ | the parameter type `K` must be valid for the lifetime `'a` as defined here...
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
-LL | trait X<K: 'a>: Sized {
- | ++++
+LL | fn foo<'a, L: X<&'a Nested<K>>>() where K: 'a;
+ | +++++++++++
error[E0309]: the parameter type `Self` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:28:19
|
LL | fn bar<'a, L: X<&'a Nested<Self>>>();
- | ^^^^^^^^^^^^^^^^^^^
+ | -- ^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<Self>` does not outlive the data it points at
+ | |
+ | the parameter type `Self` must be valid for the lifetime `'a` as defined here...
|
- = help: consider adding an explicit lifetime bound `Self: 'a`...
- = note: ...so that the reference type `&'a Nested<Self>` does not outlive the data it points at
+help: consider adding an explicit lifetime bound
+ |
+LL | fn bar<'a, L: X<&'a Nested<Self>>>() where Self: 'a;
+ | ++++++++++++++
error[E0309]: the parameter type `L` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:22
|
LL | fn baz<'a, L, M: X<&'a Nested<L>>>() {
- | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<L>` does not outlive the data it points at
+ | -- ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<L>` does not outlive the data it points at
+ | |
+ | the parameter type `L` must be valid for the lifetime `'a` as defined here...
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn baz<'a, L: 'a, M: X<&'a Nested<L>>>() {
| ++++
diff --git a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr
index 7049f28e2..dbc587dd0 100644
--- a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/issue_74400.rs:12:5
|
LL | f(data, identity)
- | ^^^^^^^^^^^^^^^^^ ...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 g<T: 'static>(data: &[T]) {
| +++++++++
diff --git a/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed b/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed
index f977f0bd3..7c4154904 100644
--- a/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed
+++ b/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.fixed
@@ -2,7 +2,7 @@
#![allow(warnings)]
-fn no_restriction<'a, T: 'a>(x: &'a ()) -> &() {
+fn no_restriction<'a, T: 'a>(x: &'a ()) -> &'a () {
with_restriction::<T>(x) //~ ERROR the parameter type `T` may not live long enough
}
diff --git a/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr b/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr
index 2d58d3a02..79df2c8df 100644
--- a/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr
+++ b/tests/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr
@@ -1,23 +1,15 @@
error[E0311]: the parameter type `T` may not live long enough
--> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:6:5
|
-LL | with_restriction::<T>(x)
- | ^^^^^^^^^^^^^^^^^^^^^
- |
-note: the parameter type `T` must be valid for the anonymous lifetime defined here...
- --> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:5:25
- |
LL | fn no_restriction<T>(x: &()) -> &() {
- | ^^^
-note: ...so that the type `T` will meet its required lifetime bounds
- --> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:6:5
- |
+ | --- the parameter type `T` must be valid for the anonymous lifetime defined here...
LL | with_restriction::<T>(x)
- | ^^^^^^^^^^^^^^^^^^^^^
-help: consider adding an explicit lifetime bound...
+ | ^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound
|
-LL | fn no_restriction<'a, T: 'a>(x: &'a ()) -> &() {
- | +++ ++++ ++
+LL | fn no_restriction<'a, T: 'a>(x: &'a ()) -> &'a () {
+ | +++ ++++ ++ ++
error: aborting due to previous error