Add disambiguating space after unary minus
@chfogelman is already working on this.
Since Oct 27, 2023.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Currently, rustfmt combines unary minus with the expression it's being applied to. This can lead to ambiguity when it's followed by a method call on an integer literal. For example, -1.method() is parsed by rustc as -(1.method()) rather than (-1).method(). To reduce confusion, one might want to see a space between the unary minus and its operand, if the operand is a non-parethesized method invocation on a numeric literal. For example:
-1;
-x;
-(x + y);
-x.y;
-x.method();
-(1.method());
// but
- 1.method();
This issue is motivated by: https://github.com/rust-lang/rust/issues/117155
I'm happy to claim this and implement it, as long as maintainers think it's a good idea.
@rustbot claim
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.
Assessment
This issue has not been assessed yet.