You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Configurations.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2754,6 +2754,44 @@ fn main() {
2754
2754
}
2755
2755
```
2756
2756
2757
+
## `strict_line_comment_wrap`
2758
+
2759
+
Wrap long line comments (`//`) that exceed the maximum width, even if they are not markdown headers. This option works in combination with `wrap_comments`.
2760
+
2761
+
-**Default value**: `false`
2762
+
-**Possible values**: `true`, `false`
2763
+
-**Stable**: No (tracking issue: [#6726](https://github.com/rust-lang/rustfmt/issues/6726))
2764
+
2765
+
#### `false` (default):
2766
+
2767
+
Long line comments may remain unwrapped:
2768
+
2769
+
```rust
2770
+
// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
2771
+
fnfoo() {
2772
+
println!("Lorem");
2773
+
}
2774
+
```
2775
+
#### `true`:
2776
+
2777
+
Long line comments are automatically wrapped to fit within the configured maximum width, preserving indentation and // prefixes, without introducing blank lines between segments:
2778
+
2779
+
```rust
2780
+
// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
2781
+
// tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
2782
+
// veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
2783
+
// ea commodo consequat.
2784
+
fnmain() {
2785
+
println!("Hello, world!");
2786
+
}
2787
+
```
2788
+
2789
+
- Works with `wrap_comments = true`.
2790
+
- Inline comments attached to code (`println!("Hello"); // comment`) are also wrapped correctly.
0 commit comments