Inconsistent handling of `return` on match arm
Open
Nobody has claimed this yet.
I-poor-formatting
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
E.g.
fn foo(input: Option<usize>) -> usize {
match input {
Some(x) => return x,
None => {
return 0;
}
}
}
Technically these two returns are different on AST level (the first one is an expression whereas the second is a statement). We could normalize them from either one to the other.
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
Use the two match-arm examples in the issue as the starting case, then inspect rustfmt's handling of match arms and its existing formatting tests. Resolve whether both forms should normalize to expression or statement style, and consider the issue done when equivalent return forms are formatted consistently with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100