-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #118891 - compiler-errors:async-gen-blocks, r=eholk
Actually parse async gen blocks correctly 1. I got the control flow in `parse_expr_bottom` messed up, and obviously forgot a test for `async gen`, so we weren't actually ever parsing it correctly. 2. I forgot to gate the span for `async gen {}`, so even if we did parse it, we wouldn't have correctly denied it in `cfg(FALSE)`. r? eholk
- Loading branch information
Showing
5 changed files
with
87 additions
and
15 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,14 @@ | ||
// compile-flags: --edition 2024 -Zunstable-options | ||
// check-pass | ||
|
||
#![feature(async_iterator, gen_blocks)] | ||
|
||
use std::async_iter::AsyncIterator; | ||
|
||
fn deduce() -> impl AsyncIterator<Item = ()> { | ||
async gen { | ||
yield Default::default(); | ||
} | ||
} | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` | ||
--> $DIR/feature-gate-gen_blocks.rs:12:11 | ||
| | ||
LL | async gen {}; | ||
| ^^^ expected one of 8 possible tokens | ||
|
||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` | ||
--> $DIR/feature-gate-gen_blocks.rs:25:11 | ||
| | ||
LL | async gen {}; | ||
| ^^^ expected one of 8 possible tokens | ||
|
||
error[E0422]: cannot find struct, variant or union type `gen` in this scope | ||
--> $DIR/feature-gate-gen_blocks.rs:5:5 | ||
| | ||
LL | gen {}; | ||
| ^^^ not found in this scope | ||
|
||
error: aborting due to 1 previous error | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0422`. |
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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
// revisions: e2024 none | ||
//[e2024] compile-flags: --edition 2024 -Zunstable-options | ||
|
||
fn main() { | ||
fn test_gen() { | ||
gen {}; | ||
//[none]~^ ERROR: cannot find struct, variant or union type `gen` | ||
//[e2024]~^^ ERROR: gen blocks are experimental | ||
//[e2024]~| ERROR: type annotations needed | ||
} | ||
|
||
fn test_async_gen() { | ||
async gen {}; | ||
//[none]~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` | ||
//[e2024]~^^ ERROR: gen blocks are experimental | ||
//[e2024]~| ERROR: type annotations needed | ||
} | ||
|
||
fn main() {} | ||
|
||
#[cfg(FALSE)] | ||
fn foo() { | ||
gen {}; | ||
//[e2024]~^ ERROR: gen blocks are experimental | ||
|
||
async gen {}; | ||
//[e2024]~^ ERROR: gen blocks are experimental | ||
//[none]~^^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` | ||
} |