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

E0121 only machineapplicable for functions but not items? #106843

Closed
matthiaskrgr opened this issue Jan 14, 2023 · 0 comments · Fixed by #106887
Closed

E0121 only machineapplicable for functions but not items? #106843

matthiaskrgr opened this issue Jan 14, 2023 · 0 comments · Fixed by #106887
Assignees
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

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.

@matthiaskrgr matthiaskrgr 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 Jan 14, 2023
@compiler-errors compiler-errors self-assigned this Jan 14, 2023
@bors bors closed this as completed in e7e8b91 Feb 4, 2023
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 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.

2 participants