diff options
| author | bors <bors@rust-lang.org> | 2023-12-05 18:37:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-05 18:37:15 +0000 |
| commit | 56278a6e2824acc96b222e5816bf2d74e85dab93 (patch) | |
| tree | c89d0da283fbf0e7fcec805d65e3ad5052724604 /compiler/rustc_parse/src/errors.rs | |
| parent | ec94480d9877e9c7ccf1255ab592dfc85d07ec50 (diff) | |
| parent | 2c8dbd959f430d09d36f733aefa33fdbf8058e80 (diff) | |
| download | rust-56278a6e2824acc96b222e5816bf2d74e85dab93.tar.gz rust-56278a6e2824acc96b222e5816bf2d74e85dab93.zip | |
Auto merge of #118457 - eholk:genfn, r=compiler-errors
Add support for `gen fn`
This builds on #116447 to add support for `gen fn` functions. For the most part we follow the same approach as desugaring `async fn`, but replacing `Future` with `Iterator` and `async {}` with `gen {}` for the body.
The version implemented here uses the return type of a `gen fn` as the yield type. For example:
```rust
gen fn count_to_three() -> i32 {
yield 1;
yield 2;
yield 3;
}
```
In the future, I think we should experiment with a syntax like `gen fn count_to_three() yield i32 { ... }`, but that can go in another PR.
cc `@oli-obk` `@compiler-errors`
Diffstat (limited to 'compiler/rustc_parse/src/errors.rs')
| -rw-r--r-- | compiler/rustc_parse/src/errors.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 03e047b297d..4bd7c99de9a 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -563,6 +563,13 @@ pub(crate) struct GenFn { } #[derive(Diagnostic)] +#[diag(parse_async_gen_fn)] +pub(crate) struct AsyncGenFn { + #[primary_span] + pub span: Span, +} + +#[derive(Diagnostic)] #[diag(parse_comma_after_base_struct)] #[note] pub(crate) struct CommaAfterBaseStruct { |
