Skip to content

"discriminant value already exists" message for overlapping C-like enum variants could be tweaked to be clearer #15524

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

Closed
2 tasks
huonw opened this issue Jul 8, 2014 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@huonw
Copy link
Member

huonw commented Jul 8, 2014

The error message could:

  • mention the value in question (i.e. 1 in the examples below), since the conflicting variant doesn't necessarily have an literal discriminant (D and E below)
  • point to the other overlapping variant(s)
static N: int = 1;

enum Foo {
    A = 1,
    B = 1,
    C = 0,
    D,
    E = N,
}

fn main() {}
<anon>:5:5: 5:10 error: discriminant value already exists
<anon>:5     B = 1,
             ^~~~~
<anon>:7:5: 7:6 error: discriminant value already exists
<anon>:7     D,
             ^
<anon>:8:5: 8:10 error: discriminant value already exists
<anon>:8     E = N,
             ^~~~~
bors added a commit that referenced this issue Oct 5, 2014
@bors bors closed this as completed in a29df44 Oct 5, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 18, 2023
Bind unused parameter assistant

This PR introduces a new **Bind unused parameter assistant**.

While we do have a QuickFix from `rustc` (prefixing the parameter with an underscore), it's sometimes more convenient to suppress the warning using the following approach:
```rust
 fn some_function(unused: i32) {}
```
->
```rust
fn some_function(unused: i32) {
    let _ = unused;
}
```
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant