Skip to content
New issue

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

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

Already on GitHub? # to your account

Produce a separate warning for every colliding name #2856

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Nov 11, 2024

Before:

warning: unreachable pattern
  --> tests/ui/conflict/alias.rs:12:21
   |
8  |       #[serde(alias = "a", alias = "b", alias = "c")]
   |                       ----------------------------- matches all the relevant values
...
12 |       #[serde(alias = "c")]
   |  _____________________^
13 | |     b: (),
   | |_____^ no value can reach this
   |
   = note: `#[warn(unreachable_patterns)]` on by default

After:

warning: unreachable pattern
  --> tests/ui/conflict/alias.rs:13:5
   |
8  |     #[serde(alias = "a", alias = "b", alias = "c")]
   |                                  --- matches all the relevant values
...
13 |     b: (),
   |     ^ no value can reach this
   |
   = note: `#[warn(unreachable_patterns)]` on by default

warning: unreachable pattern
  --> tests/ui/conflict/alias.rs:12:21
   |
8  |     #[serde(alias = "a", alias = "b", alias = "c")]
   |                                               --- matches all the relevant values
...
12 |     #[serde(alias = "c")]
   |                     ^^^ no value can reach this

The diagnostic in the "Before" is a confusingly rendered consequence of a warning that looks like this in the underlying macro-expanded code:

warning: unreachable pattern
  --> src/main.rs:74:25
   |
73 |                         "a" | "b" | "c" => _serde::__private::Ok(__Field::__field0),
   |                         --------------- matches all the relevant values
74 |                         "b" | "c" => _serde::__private::Ok(__Field::__field1),
   |                         ^^^^^^^^^ no value can reach this
   |
   = note: `#[warn(unreachable_patterns)]` on by default

@dtolnay dtolnay merged commit b1353a9 into serde-rs:master Nov 11, 2024
15 checks passed
@dtolnay dtolnay deleted the dename branch November 11, 2024 07:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant