diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-30 10:13:12 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-10-30 10:13:12 +0000 |
| commit | 745c600617bc5dd1405cb53b1f79e5f421d62b0f (patch) | |
| tree | 8bce243d67b4195373766de6fa17c553110e00da | |
| parent | 91bbdd927a5e53a2fe126304fe8adbedf339616c (diff) | |
| download | rust-745c600617bc5dd1405cb53b1f79e5f421d62b0f.tar.gz rust-745c600617bc5dd1405cb53b1f79e5f421d62b0f.zip | |
Talk about `gen fn` in diagnostics about `gen fn`
| -rw-r--r-- | compiler/rustc_parse/messages.ftl | 4 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/errors.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 2 | ||||
| -rw-r--r-- | tests/ui/coroutine/gen_fn.e2024.stderr | 4 | ||||
| -rw-r--r-- | tests/ui/coroutine/gen_fn.rs | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 9bedd7b8a33..9ba1f0a5df9 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -278,8 +278,8 @@ parse_found_expr_would_be_stmt = expected expression, found `{$token}` parse_function_body_equals_expr = function body cannot be `= expression;` .suggestion = surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;` -parse_gen_block = `gen` blocks are not yet implemented - .help = only the keyword is reserved for now +parse_gen_fn = `gen` functions are not yet implemented + .help = for now you can use `gen {"{}"}` blocks and return `impl Iterator` instead parse_generic_args_in_pat_require_turbofish_syntax = generic args in patterns require the turbofish syntax diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index c0e94d15da0..e5cd91a32a7 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -521,9 +521,9 @@ pub(crate) struct CatchAfterTry { } #[derive(Diagnostic)] -#[diag(parse_gen_block)] +#[diag(parse_gen_fn)] #[help] -pub(crate) struct GenBlock { +pub(crate) struct GenFn { #[primary_span] pub span: Span, } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index a9f456d64cd..55ad3f42938 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2372,7 +2372,7 @@ impl<'a> Parser<'a> { } if let Gen::Yes { span, .. } = genness { - self.sess.emit_err(errors::GenBlock { span }); + self.sess.emit_err(errors::GenFn { span }); } if !self.eat_keyword_case(kw::Fn, case) { diff --git a/tests/ui/coroutine/gen_fn.e2024.stderr b/tests/ui/coroutine/gen_fn.e2024.stderr index 41bd04d9769..388e10fd65e 100644 --- a/tests/ui/coroutine/gen_fn.e2024.stderr +++ b/tests/ui/coroutine/gen_fn.e2024.stderr @@ -1,10 +1,10 @@ -error: `gen` blocks are not yet implemented +error: `gen` functions are not yet implemented --> $DIR/gen_fn.rs:4:1 | LL | gen fn foo() {} | ^^^ | - = help: only the keyword is reserved for now + = help: for now you can use `gen {}` blocks and return `impl Iterator` instead error: aborting due to previous error diff --git a/tests/ui/coroutine/gen_fn.rs b/tests/ui/coroutine/gen_fn.rs index 9566660dfb5..da515f263b0 100644 --- a/tests/ui/coroutine/gen_fn.rs +++ b/tests/ui/coroutine/gen_fn.rs @@ -3,6 +3,6 @@ gen fn foo() {} //[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen` -//[e2024]~^^ ERROR: `gen` blocks are not yet implemented +//[e2024]~^^ ERROR: `gen` functions are not yet implemented fn main() {} |
