This code:
fn main() {}
async fn func<'a>() -> Result<(), &'a str> {
let s = String::new();
let b = &s[..];
Err(b)?;
Ok(())
}
Returns this error:
error[E0597]: `s` does not live long enough
--> src/main.rs:6:14
|
6 | let b = &s[..];
| ^ borrowed value does not live long enough
...
11 | }
| - `s` dropped here while still borrowed
Which is very unhelpful; it should at least in some way point to the line with the ?. This happens on rustc 1.40.0 (73528e3 2019-12-16).
For reference, this is the equivalent non-async error message (much more helpful):
error[E0515]: cannot return value referencing local variable `s`
--> src/main.rs:8:11
|
6 | let b = &s[..];
| - `s` is borrowed here
7 |
8 | Err(b)?;
| ^ returns a value referencing data owned by the current function
This code:
Returns this error:
Which is very unhelpful; it should at least in some way point to the line with the
?. This happens on rustc 1.40.0 (73528e3 2019-12-16).For reference, this is the equivalent non-async error message (much more helpful):