Skip to content

Commit a9876e8

Browse files
whizsidcalebcartwright
authored andcommitted
Fix issue 'double spaces between struct field prefix and identity when using a long attribute'
1 parent e10d2d7 commit a9876e8

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/formatting/items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ pub(crate) fn rewrite_struct_field(
18161816

18171817
let is_prefix_empty = prefix.is_empty();
18181818
// We must use multiline. We are going to put attributes and a field on different lines.
1819-
let field_str = rewrite_assign_rhs(context, prefix, &*field.ty, shape)?;
1819+
let field_str = rewrite_assign_rhs(context, prefix.trim_end(), &*field.ty, shape)?;
18201820
// Remove a leading white-space from `rewrite_assign_rhs()` when rewriting a tuple struct.
18211821
let field_str = if is_prefix_empty {
18221822
field_str.trim_start()

tests/source/issue-4671.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
struct X<'a>(
2+
#[X(X = "_________________________________________________________________________")]
3+
pub &'a u32,
4+
// ^^
5+
);
6+
7+
struct X<'a>(
8+
#[X(X = "_______________________________________________")]
9+
pub &'a u32,
10+
// ^^
11+
);

tests/target/issue-4671.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct X<'a>(
2+
#[X(X = "_________________________________________________________________________")]
3+
pub &'a u32,
4+
// ^^
5+
);
6+
7+
struct X<'a>(
8+
#[X(X = "_______________________________________________")] pub &'a u32,
9+
// ^^
10+
);

0 commit comments

Comments
 (0)