rust-lang / rust-lang/rust-clippy
single_match_else suggestion introduces violation of semicolon_if_nothing_returned
Open
Nobody has claimed this yet.
C-bug
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
When applying the single_match_else suggestion, the output introduces a violation of semicolon_if_nothing_returned.
Reproducer
Code:
match parse_char_escape(line) {
Some(decoded) => result.push(decoded),
None => {
result.push('\\');
result.push(line.current());
line.advance();
}
}
Current output:
if let Some(decoded) = parse_char_escape(line) {
result.push(decoded) // semicolon_if_nothing_returned
} else {
result.push('\\');
result.push(line.current());
line.advance();
}
Desired output:
if let Some(decoded) = parse_char_escape(line) {
result.push(decoded);
} else {
result.push('\\');
result.push(line.current());
line.advance();
}
Version
nightly
Additional Labels
No response
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 reproducing the interaction between the single_match_else suggestion and the semicolon_if_nothing_returned lint using the Rust example in this issue. Trace the suggestion's generated output and verify that the resulting if-let branch includes the required semicolon and no longer triggers the second lint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100