Skip to content

Commit c58c4e8

Browse files
committed
gate gen fn behind gen_blocks
1 parent b24a957 commit c58c4e8

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

compiler/rustc_parse/src/parser/item.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,10 @@ impl<'a> Parser<'a> {
23832383
}
23842384
}
23852385

2386+
if let Gen::Yes { span, .. } = genness {
2387+
self.sess.gated_spans.gate(sym::gen_blocks, span);
2388+
}
2389+
23862390
if !self.eat_keyword_case(kw::Fn, case) {
23872391
// It is possible for `expect_one_of` to recover given the contents of
23882392
// `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't
Lines changed: 4 additions & 2 deletions
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`.

tests/ui/coroutine/gen_fn.rs

Lines changed: 1 addition & 1 deletion
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)