`unreachable_pattern` could get more specific if the preempting pattern resembles a `const`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
matchallways picks the first arm if matching value is not defined/unknown.
I was using constto define the values for the arms.
But the const were places inside the main() and the match expression was in a separate function.
I tried this code:
Uncommenting the first 2 const gives the wanted results.
I expected to see this happen:
That the compiler finds the const values or stop compiling because the matching values are unknown.
Instead, this happened:
It just compiles.
But it gives some warnings like warning: unreachable pattern.
It just runs but with the wrong values.
See play link. See the behavior on all the versions "Stable", "Beta" and "Nightly".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked Rust Playground reproducer on Stable, Beta, and Nightly, including the versions with the first two const declarations uncommented. The issue names no source files or tests; done should establish whether unknown const values in a separate function should change match analysis or produce a compilation error, and should include regression coverage if a behavior change is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100