Comment indentation/alignment changed in Rust 1.81
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
When I updated to Rust 1.81 I noticed that the comment indentation changed. Not sure if this is an intentional breakage or a bug.
I have the following code (formatted with Rust 1.80.1, rustfmt 1.7.0):
enum Enum12 {
Fn,
NotEquals,
Backslash,
}
fn parse_symbol2(ch: char) -> Enum12 {
match ch {
'=' => Enum12::Fn,
'\u{2260}' => Enum12::NotEquals, // unicode not equal to symbol
'\\' | '\u{3bb}' => Enum12::Backslash, // lambda symbol
_ => todo!(),
}
}
.rustfmt.toml:
hard_tabs = true
When I updated to Rust 1.81 (rustfmt 1.7.1) I got this diff:
diff --git a/src/lib.rs b/src/lib.rs
index 634b281..edc0fca 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,7 +7,7 @@ enum Enum12 {
fn parse_symbol2(ch: char) -> Enum12 {
match ch {
'=' => Enum12::Fn,
- '\u{2260}' => Enum12::NotEquals, // unicode not equal to symbol
+ '\u{2260}' => Enum12::NotEquals, // unicode not equal to symbol
'\\' | '\u{3bb}' => Enum12::Backslash, // lambda symbol
_ => todo!(),
}
Strangely the bug seems to be very dependent on the length of some of my identifiers. If I change the enum name to Enum or E the formatting difference goes away. Are comments like this meant to be aligned or not?
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 formatting difference using the provided src/lib.rs example and .rustfmt.toml with Rust 1.80.1 and Rust 1.81. Compare how the inline comments are aligned for the different identifier lengths. Done means the intended alignment behavior is established and the regression is covered by a project test.
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
- 42/100