Missing unreachable code/arm warning, when a match guard is diverging
Open
Nobody has claimed this yet.
A-lints
C-bug
L-unreachable_code
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
fn main() {
match () {
_ if loop {} => (),
_ => (),
}
println!("nya :3");
}
I expected to see this happen: compiler to emit a warning that the first arm and later code is unreachable (since loop{} never terminates and has type !).
Instead, this happened: the code compiles without warnings.
Meta
rustc version: 1.84.0-beta.4 (2024-12-07 202008a1b8de96d2e5b6)
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
Reproduce the issue with the provided Rust match-guard example on the cited beta toolchain, then investigate unreachable-code analysis for diverging guards. Done means the compiler warns that the first match arm and the later println! are unreachable, with coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100