the inability to comment every non-obnoxious token without leftover whitespace before or after
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Take any piece of Rust code, split by non-obnoxious tokens on each line, for each line add a space after the token, a newline, and a comment.
non-obnoxious token would mean tokens that make sense to be commented, e.g. all tokens other than commas, double colons :: in paths or dots in field access or method calls ., or < and > in generic argument syntax etc.
for example this code:
pub trait Clean<Inner, Outer>: Dirty + 'static {
const ASSOC: usize = 0;
}
would become
pub
// comment
trait
// comment
Clean<
// comment
Inner,
// comment
Outer>:
// comment
Dirty +
// comment
'static {
// comment
const
// comment
ASSOC:
// comment
usize =
// comment
0;
// comment
}
(note the whitespace before newlines)
the reason we do this is to see which tokens leave leftover whitespace after them when passed through rustfmt. these are all locations a programmer would possibly want to comment on, for example, one could need to add a comment between pub and trait to denote why Clean needs to be a trait and not a standalone constant (first error), or simply comment on the type of a constant (8th error) etc.
in contemporary rustfmt this cannot be formatted due to left behind trailing whitespace errors:
eurydice@fedora:~/coreign/thread_local_rng$ cargo fmt
error[internal]: left behind trailing whitespace
--> /home/eurydice/coreign/thread_local_rng/src/lib.rs:22:22:4
|
22 | pub
| ^
|
error[internal]: left behind trailing whitespace
--> /home/eurydice/coreign/thread_local_rng/src/lib.rs:24:24:6
|
24 | trait
| ^
|
...
warning: rustfmt has failed to format. See previous 11 errors.
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 Rust snippet in the report and run cargo fmt to observe the trailing-whitespace errors. Then trace rustfmt's handling of whitespace around comments and token boundaries. Done means the described comments can be inserted without leftover whitespace errors while formatting remains valid.
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