Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"functions cannot be both _ and _" diagnostic thinks gen fns are async #130232

Closed
PatchMixolydic opened this issue Sep 11, 2024 · 0 comments · Fixed by #130252
Closed

"functions cannot be both _ and _" diagnostic thinks gen fns are async #130232

PatchMixolydic opened this issue Sep 11, 2024 · 0 comments · Fixed by #130252
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. F-gen_blocks `gen {}` expressions that produce `Iterator`s requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@PatchMixolydic
Copy link
Contributor

PatchMixolydic commented Sep 11, 2024

Code

(playground)

#![feature(gen_blocks)]

const gen fn x() {}

Current output

error: functions cannot be both `const` and `async`
 --> src/lib.rs:3:1
  |
3 | const gen fn x() {}
  | ^^^^^-^^^----------
  | |     |
  | |     `async` because of this
  | `const` because of this

Desired output

error: functions cannot be both `const` and `gen`
 --> src/lib.rs:3:1
  |
3 | const gen fn x() {}
  | ^^^^^-^^^----------
  | |     |
  | |     `gen` because of this
  | `const` because of this

Rust Version

rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: x86_64-unknown-linux-gnu
release: 1.80.0
LLVM version: 18.1.7

Reproduces on the playground using 1.83.0-nightly (2024-09-05 9c01301c52df5d2d7b6f).

Anything else?

@rustbot label +D-incorrect +F-gen_blocks +requires-nightly

@PatchMixolydic PatchMixolydic added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 11, 2024
@rustbot rustbot added D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. F-gen_blocks `gen {}` expressions that produce `Iterator`s requires-nightly This issue requires a nightly compiler in some way. labels Sep 11, 2024
@PatchMixolydic PatchMixolydic changed the title "functions cannot be both _ and _" diagnostic thinks gen fn is async "functions cannot be both _ and _" diagnostic thinks gen fns are async Sep 11, 2024
@compiler-errors compiler-errors self-assigned this Sep 11, 2024
Zalathar added a commit to Zalathar/rust that referenced this issue Sep 12, 2024
…ukang

Properly report error on `const gen fn`

Fixes rust-lang#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.
@bors bors closed this as completed in a3d9d13 Sep 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 12, 2024
Rollup merge of rust-lang#130252 - compiler-errors:const-gen, r=chenyukang

Properly report error on `const gen fn`

Fixes rust-lang#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. F-gen_blocks `gen {}` expressions that produce `Iterator`s requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants