diff options
| author | bors <bors@rust-lang.org> | 2023-10-29 00:03:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-29 00:03:52 +0000 |
| commit | 2cad938a8173520f2bc39137b475f136be0aeeda (patch) | |
| tree | 668c1a104a33221cc0a6082cbe42e752d82690b3 /compiler/rustc_parse/src/errors.rs | |
| parent | e5cfc55477eceed1317a02189fdf77a4a98f2124 (diff) | |
| parent | eb66d10cc3a6947cad6b4b169ed86b8c07f464d3 (diff) | |
| download | rust-2cad938a8173520f2bc39137b475f136be0aeeda.tar.gz rust-2cad938a8173520f2bc39137b475f136be0aeeda.zip | |
Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errors
Implement `gen` blocks in the 2024 edition
Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122
`gen` block tracking issue https://github.com/rust-lang/rust/issues/117078
This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically.
An example usage of `gen` blocks is
```rust
fn foo() -> impl Iterator<Item = i32> {
gen {
yield 42;
for i in 5..18 {
if i.is_even() { continue }
yield i * 2;
}
}
}
```
The limitations (to be resolved) of the implementation are listed in the tracking issue
Diffstat (limited to 'compiler/rustc_parse/src/errors.rs')
| -rw-r--r-- | compiler/rustc_parse/src/errors.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index aeb4fd0a304..c0e94d15da0 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -521,6 +521,14 @@ pub(crate) struct CatchAfterTry { } #[derive(Diagnostic)] +#[diag(parse_gen_block)] +#[help] +pub(crate) struct GenBlock { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] #[diag(parse_comma_after_base_struct)] #[note] pub(crate) struct CommaAfterBaseStruct { |
