rust/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

127 lines
4.7 KiB
Plaintext
Raw Normal View History

error[E0506]: cannot assign to `*x` because it is borrowed
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:8:5
|
LL | pub async fn async_fn(x: &mut i32) -> &i32 {
| - let's call the lifetime of this reference `'1`
LL | let y = &*x;
2023-01-15 03:06:44 +00:00
| --- `*x` is borrowed here
LL | *x += 1;
2023-01-15 03:06:44 +00:00
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
error[E0506]: cannot assign to `*x` because it is borrowed
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:17:9
|
2024-06-27 18:56:57 +00:00
LL | (async move || {
| - return type of async closure is &'1 i32
...
LL | let y = &*x;
2023-01-15 03:06:44 +00:00
| --- `*x` is borrowed here
LL | *x += 1;
2023-01-15 03:06:44 +00:00
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
2024-01-25 03:50:23 +00:00
error: lifetime may not live long enough
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:13:20
|
LL | (async move || {
2024-01-25 03:50:23 +00:00
| ______-------------_^
| | | |
2024-11-06 17:53:59 +00:00
| | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:13:20: 19:6}` contains a lifetime `'2`
2024-01-25 03:50:23 +00:00
| | lifetime `'1` represents this closure's body
LL | |
LL | |
LL | | let y = &*x;
LL | | *x += 1;
LL | | y
LL | | })()
2024-01-25 03:50:23 +00:00
| |_____^ returning this value requires that `'1` must outlive `'2`
|
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
error[E0716]: temporary value dropped while borrowed
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:13:5
|
2024-01-25 03:50:23 +00:00
LL | pub fn async_closure(x: &mut i32) -> impl Future<Output=&i32> {
| - let's call the lifetime of this reference `'1`
LL | // (async move || {
LL | ||
LL | ||
LL | || let y = &*x;
LL | || *x += 1;
LL | || y
LL | || })()
| ||______^_- argument requires that borrow lasts for `'1`
| |_______|
| creates a temporary value which is freed while still in use
LL | }
| - temporary value is freed at the end of this statement
error[E0506]: cannot assign to `*x` because it is borrowed
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:27:9
|
2024-06-27 18:56:57 +00:00
LL | (async move || -> &i32 {
| - return type of async closure is &'1 i32
...
LL | let y = &*x;
2023-01-15 03:06:44 +00:00
| --- `*x` is borrowed here
LL | *x += 1;
2023-01-15 03:06:44 +00:00
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
2024-01-25 03:50:23 +00:00
error: lifetime may not live long enough
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:23:28
|
LL | (async move || -> &i32 {
2024-01-25 03:50:23 +00:00
| ______---------------------_^
| | | |
2024-11-06 17:53:59 +00:00
| | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:23:28: 29:6}` contains a lifetime `'2`
2024-01-25 03:50:23 +00:00
| | lifetime `'1` represents this closure's body
LL | |
LL | |
LL | | let y = &*x;
LL | | *x += 1;
LL | | y
LL | | })()
2024-01-25 03:50:23 +00:00
| |_____^ returning this value requires that `'1` must outlive `'2`
|
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
error[E0716]: temporary value dropped while borrowed
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:23:5
|
2024-01-25 03:50:23 +00:00
LL | pub fn async_closure_explicit_return_type(x: &mut i32) -> impl Future<Output=&i32> {
| - let's call the lifetime of this reference `'1`
LL | // (async move || -> &i32 {
LL | ||
LL | ||
LL | || let y = &*x;
LL | || *x += 1;
LL | || y
LL | || })()
| ||______^_- argument requires that borrow lasts for `'1`
| |_______|
| creates a temporary value which is freed while still in use
LL | }
| - temporary value is freed at the end of this statement
error[E0506]: cannot assign to `*x` because it is borrowed
2024-11-06 17:53:59 +00:00
--> $DIR/issue-74072-lifetime-name-annotations.rs:35:9
|
2024-06-27 18:56:57 +00:00
LL | async move {
| - return type of async block is &'1 i32
LL | let y = &*x;
2023-01-15 03:06:44 +00:00
| --- `*x` is borrowed here
LL | *x += 1;
2023-01-15 03:06:44 +00:00
| ^^^^^^^ `*x` is assigned to here but it was already borrowed
LL | y
| - returning this value requires that `*x` is borrowed for `'1`
2024-01-25 03:50:23 +00:00
error: aborting due to 8 previous errors
2024-01-25 03:50:23 +00:00
Some errors have detailed explanations: E0506, E0716.
For more information about an error, try `rustc --explain E0506`.