Skip to content

Commit e445aad

Browse files
committed
Fix
All system_tests pass now!
1 parent a371652 commit e445aad

7 files changed

+11
-15
lines changed

src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ fn rewrite_struct_lit<'a>(
16561656

16571657
let one_line_width = h_shape.map_or(0, |shape| shape.width);
16581658
let body_lo = context.snippet_provider.span_after(span, "{");
1659-
let fields_str = if context.config.struct_field_align_threshold() > 0 {
1659+
let fields_str = if !fields.is_empty() && context.config.struct_field_align_threshold() > 0 {
16601660
rewrite_with_alignment(
16611661
fields,
16621662
context,

src/test/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ fn system_tests() {
181181
init_log();
182182
run_test_with(&TestSetting::default(), || {
183183
// Get all files in the tests/source directory.
184-
// let files = get_test_files(Path::new("tests/source"), true);
185-
let files = vec![
186-
// PathBuf::from("tests/source/issue_6096.rs"),
187-
// PathBuf::from("tests/source/issue_6080.rs")
188-
PathBuf::from("tests/source/configs/struct_field_align_threshold/20.rs")
189-
];
184+
let files = get_test_files(Path::new("tests/source"), true);
185+
// let files = vec![
186+
// PathBuf::from("tests/source/issue_6096.rs"),
187+
// PathBuf::from("tests/source/issue_6080.rs"),
188+
// PathBuf::from("tests/source/issue-4926/deeply_nested_struct_with_long_field_names.rs"),
189+
// ];
190190
// dbg!(&files);
191191
let (_reports, count, fails) = check_files(files, &None);
192192

src/vertical.rs

-4
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,6 @@ fn rewrite_aligned_items_inner<T: AlignedItem>(
235235

236236
let has_base_or_rest = match struct_rest {
237237
Some(rest) => match rest {
238-
// ast::StructRest::None if fields.is_empty() => return format!("{path_str} {{}}"),
239-
// ast::StructRest::Rest(_) if fields.is_empty() => {
240-
// return Ok(format!("{path_str} {{ .. }}"));
241-
// }
242238
ast::StructRest::Rest(_) | ast::StructRest::Base(_) => true,
243239
_ => false,
244240
},

tests/source/issue-4926/deeply_nested_struct_with_long_field_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-struct_field_align_threshold: 30
1+
// rustfmt-struct_field_align_threshold: 27
22

33
struct X {
44
really_really_long_field_a: i32,

tests/source/issue-4926/struct_with_long_field_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-struct_field_align_threshold: 30
1+
// rustfmt-struct_field_align_threshold: 27
22

33
struct X {
44
really_really_long_field_a: i32,

tests/target/issue-4926/deeply_nested_struct_with_long_field_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-struct_field_align_threshold: 30
1+
// rustfmt-struct_field_align_threshold: 27
22

33
struct X {
44
really_really_long_field_a: i32,

tests/target/issue-4926/struct_with_long_field_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-struct_field_align_threshold: 30
1+
// rustfmt-struct_field_align_threshold: 27
22

33
struct X {
44
really_really_long_field_a: i32,

0 commit comments

Comments
 (0)