Skip to content

Commit 796d6ea

Browse files
fix: backport fix for #4079
1 parent 5db7152 commit 796d6ea

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/comment.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ impl<'a> CommentRewrite<'a> {
529529
.checked_sub(closer.len() + opener.len())
530530
.unwrap_or(1);
531531
let indent_str = shape.indent.to_string_with_newline(config).to_string();
532-
let fmt_indent = shape.indent + (opener.len() - line_start.len());
533532

534533
let mut cr = CommentRewrite {
535534
result: String::with_capacity(orig.len() * 2),
@@ -540,14 +539,14 @@ impl<'a> CommentRewrite<'a> {
540539
comment_line_separator: format!("{}{}", indent_str, line_start),
541540
max_width,
542541
indent_str,
543-
fmt_indent,
542+
fmt_indent: shape.indent,
544543

545544
fmt: StringFormat {
546545
opener: "",
547546
closer: "",
548547
line_start,
549548
line_end: "",
550-
shape: Shape::legacy(max_width, fmt_indent),
549+
shape: Shape::legacy(max_width, shape.indent),
551550
trim_end: true,
552551
config,
553552
},

tests/source/issue-4079.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// rustfmt-wrap_comments: true
2+
3+
/*!
4+
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia
5+
* ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem volutpat
6+
*/
7+
8+
/*! Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem volutpat */

tests/target/issue-4079.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-wrap_comments: true
2+
3+
/*!
4+
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia
5+
* ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem
6+
* volutpat
7+
*/
8+
9+
/*! Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia
10+
* ullamcorper lorem, non hendrerit enim convallis ut. Curabitur id sem
11+
* volutpat */

0 commit comments

Comments
 (0)