Skip to content

Commit 745c600

Browse files
committed
Talk about gen fn in diagnostics about gen fn
1 parent 91bbdd9 commit 745c600

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

compiler/rustc_parse/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ parse_found_expr_would_be_stmt = expected expression, found `{$token}`
278278
parse_function_body_equals_expr = function body cannot be `= expression;`
279279
.suggestion = surround the expression with `{"{"}` and `{"}"}` instead of `=` and `;`
280280
281-
parse_gen_block = `gen` blocks are not yet implemented
282-
.help = only the keyword is reserved for now
281+
parse_gen_fn = `gen` functions are not yet implemented
282+
.help = for now you can use `gen {"{}"}` blocks and return `impl Iterator` instead
283283
284284
parse_generic_args_in_pat_require_turbofish_syntax = generic args in patterns require the turbofish syntax
285285

compiler/rustc_parse/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ pub(crate) struct CatchAfterTry {
521521
}
522522

523523
#[derive(Diagnostic)]
524-
#[diag(parse_gen_block)]
524+
#[diag(parse_gen_fn)]
525525
#[help]
526-
pub(crate) struct GenBlock {
526+
pub(crate) struct GenFn {
527527
#[primary_span]
528528
pub span: Span,
529529
}

compiler/rustc_parse/src/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ impl<'a> Parser<'a> {
23722372
}
23732373

23742374
if let Gen::Yes { span, .. } = genness {
2375-
self.sess.emit_err(errors::GenBlock { span });
2375+
self.sess.emit_err(errors::GenFn { span });
23762376
}
23772377

23782378
if !self.eat_keyword_case(kw::Fn, case) {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: `gen` blocks are not yet implemented
1+
error: `gen` functions are not yet implemented
22
--> $DIR/gen_fn.rs:4:1
33
|
44
LL | gen fn foo() {}
55
| ^^^
66
|
7-
= help: only the keyword is reserved for now
7+
= help: for now you can use `gen {}` blocks and return `impl Iterator` instead
88

99
error: aborting due to previous error
1010

tests/ui/coroutine/gen_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
gen fn foo() {}
55
//[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen`
6-
//[e2024]~^^ ERROR: `gen` blocks are not yet implemented
6+
//[e2024]~^^ ERROR: `gen` functions are not yet implemented
77

88
fn main() {}

0 commit comments

Comments
 (0)