diff options
| author | bors <bors@rust-lang.org> | 2022-02-12 21:42:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-12 21:42:10 +0000 |
| commit | 3cfa4def7c87d571bd46d92fed608edf8fad236e (patch) | |
| tree | 43fadb34acfa47419ac74221dbca1161938dbeee /src/test/ui/issues | |
| parent | 5d8767cb229b097fedb1dd4bd9420d463c37774f (diff) | |
| parent | 10cf626d0ea7be3eb971691772b5eb30013d4f02 (diff) | |
| download | rust-3cfa4def7c87d571bd46d92fed608edf8fad236e.tar.gz rust-3cfa4def7c87d571bd46d92fed608edf8fad236e.zip | |
Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk
Inherit lifetimes for async fn instead of duplicating them. The current desugaring of `async fn foo<'a>(&usize) -> &u8` is equivalent to ```rust fn foo<'a, '0>(&'0 usize) -> foo<'static, 'static>::Opaque<'a, '0, '_>; type foo<'_a, '_0>::Opaque<'a, '0, '1> = impl Future<Output = &'1 u8>; ``` following the RPIT model. Duplicating all the inherited lifetime parameters and setting the inherited version to `'static` makes lowering more complex and causes issues like #61949. This PR removes the duplication of inherited lifetimes to directly use ```rust fn foo<'a, '0>(&'0 usize) -> foo<'a, '0>::Opaque<'_>; type foo<'a, '0>::Opaque<'1> = impl Future<Output = &'1 u8>; ``` following the TAIT model. Fixes https://github.com/rust-lang/rust/issues/61949
Diffstat (limited to 'src/test/ui/issues')
| -rw-r--r-- | src/test/ui/issues/issue-13497-2.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-13497-2.stderr | 14 |
2 files changed, 7 insertions, 11 deletions
diff --git a/src/test/ui/issues/issue-13497-2.rs b/src/test/ui/issues/issue-13497-2.rs index c82da0f0096..32abe2b8543 100644 --- a/src/test/ui/issues/issue-13497-2.rs +++ b/src/test/ui/issues/issue-13497-2.rs @@ -1,7 +1,7 @@ fn read_lines_borrowed<'a>() -> Vec<&'a str> { let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()]; - rawLines //~ ERROR cannot return value referencing local variable `rawLines` - .iter().map(|l| l.trim()).collect() + rawLines.iter().map(|l| l.trim()).collect() + //~^ ERROR cannot return value referencing local variable `rawLines` } fn main() {} diff --git a/src/test/ui/issues/issue-13497-2.stderr b/src/test/ui/issues/issue-13497-2.stderr index 6f72b79f2a5..1b78e7ec1c6 100644 --- a/src/test/ui/issues/issue-13497-2.stderr +++ b/src/test/ui/issues/issue-13497-2.stderr @@ -1,14 +1,10 @@ error[E0515]: cannot return value referencing local variable `rawLines` - --> $DIR/issue-13497-2.rs:3:5 + --> $DIR/issue-13497-2.rs:3:29 | -LL | rawLines - | _____^ - | |_____| - | || -LL | || .iter().map(|l| l.trim()).collect() - | ||_______________-___________________________^ returns a value referencing data owned by the current function - | |________________| - | `rawLines` is borrowed here +LL | rawLines.iter().map(|l| l.trim()).collect() + | --------------- ^^^^^^^^ returns a value referencing data owned by the current function + | | + | `rawLines` is borrowed here error: aborting due to previous error |
