Skip to content

E0121 only machineapplicable for functions but not items? #106843

Closed
@matthiaskrgr

Description

@matthiaskrgr

Given the following code:

fn foo() -> _ { 5 } //~ ERROR E0121

static BAR: _ = "test"; //~ ERROR E0121

fn main() {}

The current output is:

error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
 --> src/main.rs:1:13
  |
1 | fn foo() -> _ { 5 } //~ ERROR E0121
  |             ^
  |             |
  |             not allowed in type signatures
  |             help: replace with the correct return type: `i32`

error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
 --> src/main.rs:3:13
  |
3 | static BAR: _ = "test"; //~ ERROR E0121
  |             ^
  |             |
  |             not allowed in type signatures
  |             help: replace with the correct type: `&str`

For more information about this error, try `rustc --explain E0121`.

Both suggestions are valid here, but when I run cargo fix --broken-code, only the function will be fixed, and the static item will be left untouched for some reason 🤔
Looks like an oversight to me.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions