forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#120322 - compiler-errors:higher-ranked-asyn…
…c-closures, r=oli-obk Don't manually resolve async closures in `rustc_resolve` There's a comment here that talks about doing this "[so] closure [args] are detected as upvars rather than normal closure arg usages", but we do upvar analysis on the HIR now: https://github.com/rust-lang/rust/blob/cd6d8f2a04528f827ad3d399581c0f3502b15a72/compiler/rustc_passes/src/upvars.rs#L21-L29 Removing this ad-hoc logic makes it so that `async |x: &str|` now introduces an implicit binder, like regular closures. r? `@oli-obk`
- Loading branch information
Showing
3 changed files
with
29 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// edition:2021 | ||
|
||
#![feature(async_closure)] | ||
|
||
fn main() { | ||
let x = async move |x: &str| { | ||
//~^ ERROR lifetime may not live long enough | ||
// This error is proof that the `&str` type is higher-ranked. | ||
// This won't work until async closures are fully impl'd. | ||
println!("{x}"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/higher-ranked.rs:6:34 | ||
| | ||
LL | let x = async move |x: &str| { | ||
| ____________________________-___-_^ | ||
| | | | | ||
| | | return type of closure `{async closure body@$DIR/higher-ranked.rs:6:34: 11:6}` contains a lifetime `'2` | ||
| | let's call the lifetime of this reference `'1` | ||
LL | | | ||
LL | | // This error is proof that the `&str` type is higher-ranked. | ||
LL | | // This won't work until async closures are fully impl'd. | ||
LL | | println!("{x}"); | ||
LL | | }; | ||
| |_____^ returning this value requires that `'1` must outlive `'2` | ||
|
||
error: aborting due to 1 previous error | ||
|