Skip to content

Commit 20805ac

Browse files
committed
Merge attributes_on_same_line_as_field and attributes_on_same_line_as_variant into same_line_attributes
1 parent d00c60d commit 20805ac

12 files changed

+15
-127
lines changed

Configurations.md

+9-23
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "
296296
#### Lines longer than `array_width`:
297297
See [`indent_style`](#indent_style).
298298

299-
## `attributes_on_same_line_as_field`
299+
## `same_line_attributes`
300300

301-
Try to put attributes on the same line as fields
301+
Try to put attributes on the same line as fields and variants
302302

303303
- **Default value**: `true`
304304
- **Possible values**: `true`, `false`
@@ -311,6 +311,12 @@ struct Lorem {
311311
#[serde(rename = "Dolor")] dolor: usize,
312312
#[serde(rename = "Amet")] amet: usize,
313313
}
314+
315+
enum Lorem {
316+
#[serde(skip_serializing)] Ipsum,
317+
#[serde(skip_serializing)] Dolor,
318+
#[serde(skip_serializing)] Amet,
319+
}
314320
```
315321

316322
#### `false`:
@@ -324,28 +330,7 @@ struct Lorem {
324330
#[serde(rename = "Amet")]
325331
amet: usize,
326332
}
327-
```
328-
329-
## `attributes_on_same_line_as_variant`
330-
331-
Try to put attributes on the same line as variants
332-
333-
- **Default value**: `true`
334-
- **Possible values**: `true`, `false`
335-
336-
#### `true` (default):
337-
338-
```rust
339-
enum Lorem {
340-
#[serde(skip_serializing)] Ipsum,
341-
#[serde(skip_serializing)] Dolor,
342-
#[serde(skip_serializing)] Amet,
343-
}
344-
```
345-
346-
#### `false`:
347333

348-
```rust
349334
enum Lorem {
350335
#[serde(skip_serializing)]
351336
Ipsum,
@@ -356,6 +341,7 @@ enum Lorem {
356341
}
357342
```
358343

344+
359345
## `binop_separator`
360346

361347
Where to put a binary operator when a binary expression goes multiline.

src/config.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,8 @@ create_config! {
613613
threshold.";
614614
remove_blank_lines_at_start_or_end_of_block: bool, true, false,
615615
"Remove blank lines at start or end of a block";
616-
attributes_on_same_line_as_field: bool, true, false,
617-
"Try to put attributes on the same line as fields.";
618-
attributes_on_same_line_as_variant: bool, true, false,
619-
"Try to put attributes on the same line as variants in enum declarations.";
616+
same_line_attributes: bool, true, false,
617+
"Try to put attributes on the same line as fields and variants.";
620618
multiline_closure_forces_block: bool, false, false,
621619
"Force multiline closure bodies to be wrapped in a block";
622620
multiline_match_arm_forces_block: bool, false, false,

src/items.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,7 @@ impl<'a> FmtVisitor<'a> {
567567
};
568568

569569
let attrs_extendable = attrs_str.is_empty()
570-
|| (context.config.attributes_on_same_line_as_variant()
571-
&& is_attributes_extendable(&attrs_str));
570+
|| (context.config.same_line_attributes() && is_attributes_extendable(&attrs_str));
572571
combine_strs_with_missing_comments(
573572
&context,
574573
&attrs_str,
@@ -1450,8 +1449,7 @@ pub fn rewrite_struct_field(
14501449

14511450
let attrs_str = field.attrs.rewrite(context, shape)?;
14521451
let attrs_extendable = attrs_str.is_empty()
1453-
|| (context.config.attributes_on_same_line_as_field()
1454-
&& is_attributes_extendable(&attrs_str));
1452+
|| (context.config.same_line_attributes() && is_attributes_extendable(&attrs_str));
14551453
let missing_span = if field.attrs.is_empty() {
14561454
mk_sp(field.span.lo(), field.span.lo())
14571455
} else {

src/vertical.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ impl AlignedItem for ast::StructField {
5454
} else {
5555
mk_sp(self.attrs.last().unwrap().span.hi(), self.span.lo())
5656
};
57-
let attrs_extendable = context.config.attributes_on_same_line_as_field()
58-
&& is_attributes_extendable(&attrs_str);
57+
let attrs_extendable =
58+
context.config.same_line_attributes() && is_attributes_extendable(&attrs_str);
5959
rewrite_struct_field_prefix(context, self).and_then(|field_str| {
6060
combine_strs_with_missing_comments(
6161
context,

tests/source/configs-attributes_on_same_line_as_field-false.rs

-17
This file was deleted.

tests/source/configs-attributes_on_same_line_as_field-true.rs

-11
This file was deleted.

tests/source/configs-attributes_on_same_line_as_variant-false.rs

-11
This file was deleted.

tests/source/configs-attributes_on_same_line_as_variant-true.rs

-11
This file was deleted.

tests/target/configs-attributes_on_same_line_as_field-false.rs

-17
This file was deleted.

tests/target/configs-attributes_on_same_line_as_field-true.rs

-8
This file was deleted.

tests/target/configs-attributes_on_same_line_as_variant-false.rs

-11
This file was deleted.

tests/target/configs-attributes_on_same_line_as_variant-true.rs

-8
This file was deleted.

0 commit comments

Comments
 (0)