rust-lang / rust-lang/rustfmt

Rustfmt deletes leading non-breaking space from comments

Open
#5,638 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-comments
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

This came up in https://github.com/rust-lang/rust/issues/106098#issuecomment-1364374483.

The 2 possible behaviors that seem reasonable to me are either:

  • keep the non-breaking space characters as is; or
  • replace non-breaking space (U+00A0) with ordinary space (U+0020) inside of comments.

The current behavior is not a way that I would expect rustfmt to behave.

Repro:
$ echo -e '/*\n  normal spaces\n\u00a0\u00a0non-breaking\u00a0spaces\n*/' | rustfmt
/*
  normal spaces
non-breaking spaces
*/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproduction command from the issue and compare how ordinary spaces and U+00A0 are handled in comments. Trace the comment-formatting path and add a regression test covering the leading non-breaking spaces. Done means the project has a defined, tested behavior: either preserving U+00A0 or replacing it with ordinary spaces.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.