Rollup merge of #130252 - compiler-errors:const-gen, r=chenyukang
Properly report error on `const gen fn` Fixes #130232 Also removes some (what I thought were unused) functions, and fixes a bug in clippy where we considered `gen fn` to be the same as `fn` because it was only built to consider asyncness.
This commit is contained in:
commit
a3d9d13d7a
7 changed files with 66 additions and 28 deletions
12
tests/ui/coroutine/const_gen_fn.rs
Normal file
12
tests/ui/coroutine/const_gen_fn.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
//@ edition:2024
|
||||
//@ compile-flags: -Zunstable-options
|
||||
|
||||
#![feature(gen_blocks)]
|
||||
|
||||
const gen fn a() {}
|
||||
//~^ ERROR functions cannot be both `const` and `gen`
|
||||
|
||||
const async gen fn b() {}
|
||||
//~^ ERROR functions cannot be both `const` and `async gen`
|
||||
|
||||
fn main() {}
|
20
tests/ui/coroutine/const_gen_fn.stderr
Normal file
20
tests/ui/coroutine/const_gen_fn.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error: functions cannot be both `const` and `gen`
|
||||
--> $DIR/const_gen_fn.rs:6:1
|
||||
|
|
||||
LL | const gen fn a() {}
|
||||
| ^^^^^-^^^----------
|
||||
| | |
|
||||
| | `gen` because of this
|
||||
| `const` because of this
|
||||
|
||||
error: functions cannot be both `const` and `async gen`
|
||||
--> $DIR/const_gen_fn.rs:9:1
|
||||
|
|
||||
LL | const async gen fn b() {}
|
||||
| ^^^^^-^^^^^^^^^----------
|
||||
| | |
|
||||
| | `async gen` because of this
|
||||
| `const` because of this
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue