parent
9038da6df0
commit
b28a0cd6e6
10
src/lists.rs
10
src/lists.rs
@ -297,17 +297,15 @@ where
|
||||
if formatting.ends_with_newline {
|
||||
trailing_separator = true;
|
||||
}
|
||||
} else if line_len > 0 {
|
||||
result.push(' ');
|
||||
line_len += 1;
|
||||
}
|
||||
|
||||
if last && formatting.ends_with_newline {
|
||||
separate = formatting.trailing_separator != SeparatorTactic::Never;
|
||||
}
|
||||
|
||||
if line_len > 0 {
|
||||
result.push(' ');
|
||||
line_len += 1;
|
||||
}
|
||||
|
||||
line_len += total_width;
|
||||
}
|
||||
_ => {}
|
||||
@ -341,6 +339,8 @@ where
|
||||
} else {
|
||||
result.push('\n');
|
||||
result.push_str(indent_str);
|
||||
// This is the width of the item (without comments).
|
||||
line_len = item.item.as_ref().map_or(0, |str| str.len());
|
||||
}
|
||||
} else {
|
||||
result.push(' ');
|
||||
|
19
tests/source/array_comment.rs
Normal file
19
tests/source/array_comment.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Issue 2842
|
||||
// The comment should not make the last line shorter
|
||||
|
||||
static XXX: [i8; 64] = [
|
||||
1, // Comment
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
];
|
||||
|
||||
static XXX: [i8; 64] = [
|
||||
1,
|
||||
// Comment
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
];
|
||||
|
||||
static XXX: [i8; 64] = [
|
||||
1,
|
||||
// Comment
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
];
|
18
tests/target/array_comment.rs
Normal file
18
tests/target/array_comment.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Issue 2842
|
||||
// The comment should not make the last line shorter
|
||||
|
||||
static XXX: [i8; 64] = [
|
||||
1, // Comment
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
];
|
||||
|
||||
static XXX: [i8; 64] = [
|
||||
1, // Comment
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
];
|
||||
|
||||
static XXX: [i8; 64] = [
|
||||
1, // Comment
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1,
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user