Skip to content

Commit 7c43784

Browse files
committed
gate gen fn behind gen_blocks
1 parent c104f3b commit 7c43784

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Diff for: compiler/rustc_parse/src/parser/item.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,10 @@ impl<'a> Parser<'a> {
24102410
}
24112411
}
24122412

2413+
if let Gen::Yes { span, .. } = genness {
2414+
self.sess.gated_spans.gate(sym::gen_blocks, span);
2415+
}
2416+
24132417
if !self.eat_keyword_case(kw::Fn, case) {
24142418
// It is possible for `expect_one_of` to recover given the contents of
24152419
// `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't

Diff for: tests/ui/coroutine/gen_fn.e2024.stderr

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
error: `gen` functions are not yet implemented
1+
error[E0658]: gen blocks are experimental
22
--> $DIR/gen_fn.rs:4:1
33
|
44
LL | gen fn foo() {}
55
| ^^^
66
|
7-
= help: for now you can use `gen {}` blocks and return `impl Iterator` instead
7+
= note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information
8+
= help: add `#![feature(gen_blocks)]` to the crate attributes to enable
89

910
error: aborting due to 1 previous error
1011

12+
For more information about this error, try `rustc --explain E0658`.

Diff for: 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` functions are not yet implemented
6+
//[e2024]~^^ ERROR: gen blocks are experimental
77

88
fn main() {}

0 commit comments

Comments
 (0)