Uh oh!
There was an error while loading. Please reload this page.
Require explicitly marking closures as coroutines - #123792
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
rustbot
commented
Apr 11, 2024
Some changes occurred in tests/ui/sanitizer cc @rust-lang/project-exploit-mitigations, @rcvalle |
oli-obk
commented
Apr 11, 2024
| .. | ||
| }) => { | ||
| self.with_new_scopes(ident.span, |this| { | ||
| self.with_new_scopes(span, |this| { |
There was a problem hiding this comment.
I had to do this change as otherwise the span points to the identifier of functions instead of the fn, so adding gen would have resulted in fn gen foo instead of gen fn foo.
| if this.token.uninterpolated_span().at_least_rust_2024() | ||
| // check for `gen {}` and `gen move {}` | ||
| // or `async gen {}` and `async gen move {}` | ||
| && (this.is_gen_block(kw::Gen, 0) | ||
| || (this.check_keyword(kw::Async) && this.is_gen_block(kw::Gen, 1))) | ||
| { | ||
| // FIXME: (async) gen closures aren't yet parsed. | ||
| this.parse_gen_block() | ||
| } else if this.check_keyword(kw::Async) { | ||
| if this.check_keyword(kw::Async) { | ||
| // FIXME(gen_blocks): Parse `gen async` and suggest swap | ||
| if this.is_gen_block(kw::Async, 0) { | ||
| if this.is_gen_block(kw::Async, 0) || this.is_gen_block(kw::Gen, 1) { | ||
| // Check for `async {` and `async move {`, | ||
| this.parse_gen_block() | ||
| } else { | ||
| this.parse_expr_closure() | ||
| } | ||
| } else if this.check_keyword(kw::Gen) | ||
| && this.token.uninterpolated_span().at_least_rust_2024() | ||
| { | ||
| if this.is_gen_block(kw::Gen, 0) { |
There was a problem hiding this comment.
This deserves further cleanup, but I think it's already an improvement if all the async stuff always goes through the kw::Async arm.
Also we can now gate the edition check on the keyword check, yay
f0906f5 to
b692d5bComparerustbot
commented
Apr 11, 2024
Some changes occurred in tests/ui/sanitizer cc @rust-lang/project-exploit-mitigations, @rcvalle |
Let's not use gen as the keyword for this. That conflicts with gen closures, which we could have as a parallel to async closures, and is confusing given that gen fns and gen blocks also exist. |
compiler-errors
commented
Apr 11, 2024
Given that full/general coroutines still are not expected to land anytime soon, I'd rather if we don't add syntax for this at all, and just use an attr tbh |
b692d5b to
3c91020Comparerustbot
commented
Apr 12, 2024
Some changes occurred in compiler/rustc_codegen_gcc Some changes occurred in src/tools/clippy cc @rust-lang/clippy The Miri subtree was changed cc @rust-lang/miri Some changes occurred in coverage tests. cc @Zalathar Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
3c91020 to
d8ab6bfCompare
This comment has been minimized.
This comment has been minimized.
d8ab6bf to
2ddca19CompareUh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Cool -- I appreciate this new approach. I will review it in detail when I find some time soon... |
2ddca19 to
37af228Compare
This comment has been minimized.
This comment has been minimized.
bors
commented
Apr 16, 2024
☔ The latest upstream changes (presumably #123468) made this pull request unmergeable. Please resolve the merge conflicts. |
37af228 to
b32acf6Compare…er-errors Require explicitly marking closures as coroutines instead of relying on patching up the closure to be a coroutine if it happens to contain a `yield` expression. I only do this in the 2024 edition, as the `gen` keyword is only available there.
This comment has been minimized.
This comment has been minimized.
bors
commented
Apr 23, 2024
💔 Test failed - checks-actions |
2c39d20 to
bf436b5Compareoli-obk
commented
Apr 23, 2024
msvc -.- @bors r=compiler-errors rollup=iffy |
bors
commented
Apr 23, 2024
bors
commented
Apr 23, 2024
☔ The latest upstream changes (presumably #124295) made this pull request unmergeable. Please resolve the merge conflicts. |
…ing `yield` expressions
And suggest adding the `#[coroutine]` to the closure
bf436b5 to
aef0f40Compareoli-obk
commented
Apr 24, 2024
@bors r=compiler-errors rollup=iffy |
bors
commented
Apr 24, 2024
bors
commented
Apr 24, 2024
bors
commented
Apr 24, 2024
☀️ Test successful - checks-actions |
rust-timer
commented
Apr 24, 2024
Finished benchmarking commit (e936289): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.226s -> 672.79s (-0.06%) |
This is required with rust-lang/rust#123792
This is required with rust-lang/rust#123792
instead of relying on patching up the closure to be a coroutine if it happens to contain a
yieldexpression.I only do this in the 2024 edition, as the
genkeyword is only available there.