Make async gen fn an error
This commit is contained in:
parent
7c43784cb0
commit
f29b36d03e
5 changed files with 34 additions and 0 deletions
|
@ -23,6 +23,8 @@ parse_async_block_in_2015 = `async` blocks are only allowed in Rust 2018 or late
|
||||||
parse_async_fn_in_2015 = `async fn` is not permitted in Rust 2015
|
parse_async_fn_in_2015 = `async fn` is not permitted in Rust 2015
|
||||||
.label = to use `async fn`, switch to Rust 2018 or later
|
.label = to use `async fn`, switch to Rust 2018 or later
|
||||||
|
|
||||||
|
parse_async_gen_fn = `async gen` functions are not supported
|
||||||
|
|
||||||
parse_async_move_block_in_2015 = `async move` blocks are only allowed in Rust 2018 or later
|
parse_async_move_block_in_2015 = `async move` blocks are only allowed in Rust 2018 or later
|
||||||
|
|
||||||
parse_async_move_order_incorrect = the order of `move` and `async` is incorrect
|
parse_async_move_order_incorrect = the order of `move` and `async` is incorrect
|
||||||
|
|
|
@ -562,6 +562,13 @@ pub(crate) struct GenFn {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(parse_async_gen_fn)]
|
||||||
|
pub(crate) struct AsyncGenFn {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(parse_comma_after_base_struct)]
|
#[diag(parse_comma_after_base_struct)]
|
||||||
#[note]
|
#[note]
|
||||||
|
|
|
@ -2414,6 +2414,12 @@ impl<'a> Parser<'a> {
|
||||||
self.sess.gated_spans.gate(sym::gen_blocks, span);
|
self.sess.gated_spans.gate(sym::gen_blocks, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let (Async::Yes { span: async_span, .. }, Gen::Yes { span: gen_span, .. }) =
|
||||||
|
(asyncness, genness)
|
||||||
|
{
|
||||||
|
self.sess.emit_err(errors::AsyncGenFn { span: async_span.to(gen_span) });
|
||||||
|
}
|
||||||
|
|
||||||
if !self.eat_keyword_case(kw::Fn, case) {
|
if !self.eat_keyword_case(kw::Fn, case) {
|
||||||
// It is possible for `expect_one_of` to recover given the contents of
|
// It is possible for `expect_one_of` to recover given the contents of
|
||||||
// `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't
|
// `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't
|
||||||
|
|
11
tests/ui/coroutine/async_gen_fn.rs
Normal file
11
tests/ui/coroutine/async_gen_fn.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// edition: 2024
|
||||||
|
// compile-flags: -Zunstable-options
|
||||||
|
#![feature(gen_blocks)]
|
||||||
|
|
||||||
|
// async generators are not yet supported, so this test makes sure they make some kind of reasonable
|
||||||
|
// error.
|
||||||
|
|
||||||
|
async gen fn foo() {}
|
||||||
|
//~^ `async gen` functions are not supported
|
||||||
|
|
||||||
|
fn main() {}
|
8
tests/ui/coroutine/async_gen_fn.stderr
Normal file
8
tests/ui/coroutine/async_gen_fn.stderr
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
error: `async gen` functions are not supported
|
||||||
|
--> $DIR/async_gen_fn.rs:8:1
|
||||||
|
|
|
||||||
|
LL | async gen fn foo() {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue