rustfmt breaks a `/* ... */` comment into `/* ... //`, with no terminating `*/`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
With version = "Two" and wrap_comments = true, rustfmt can break a /* ... */ comment by changing one of its lines to start with //. The error does not occur without version "Two" or without wrap_comments. Maybe worth noting, we have both of those options on at work.
(Sorry if this is a duplicate bug, couldn't find anything by searching for is:issue state:open "wrap_comments = true" "version = \"Two\"")
Reproduction steps:
cargo new test-crate
cd test-crate
echo 'version = "Two"
wrap_comments = true' > rustfmt.toml
echo 'use rustc_middle::ty::{self, Region, Ty, TyCtxt}; /* xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* xxxxxxxxxxxxx */
fn main() {}
' > src/main.rs
cargo +nightly fmt # or rustfmt +nightly src/main.rs
cat src/main.rs
On my computer, I get:
use rustc_middle::ty::{self, Region, Ty, TyCtxt}; /* xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// xxxxxxxxxxxxx
fn main() {}
Which is not valid syntax.
rustfmt version:
$ rustfmt +nightly --version
rustfmt 1.7.1-nightly (506f22b 2024-09-19)
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 with the rustfmt.toml settings and the src/main.rs reproduction, then run cargo +nightly fmt or rustfmt +nightly src/main.rs. Done means formatting the reproduced block comment preserves a terminating */ and produces valid Rust syntax when version = "Two" and wrap_comments = true.
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
- Clearly specified
- Newbie friendliness
- 50/100