Rustfmt can generate invalid code when using `space_after_colon=false`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
formatting the following code with space_after_colon=false will generate invalid code
struct SomeStruct {
some_field: ::some_crate::Thing,
}
since it removes the space between the field colon and the :: prefix on some_crate
i cant see this as very high priority because i dont know anyone who prefixes things with :: asides from maybe alloc or std, and space_after_colon=false isnt widely used, but this should probably be looked into
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 Rust snippet with space_after_colon=false and checking whether the formatted output still parses. Then trace rustfmt's handling of spaces after struct-field colons and add a regression test for the :: path prefix; done means formatting preserves valid Rust code.
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
- Mostly clear
- Newbie friendliness
- 35/100