summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/issue-4926
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rustfmt/tests/source/issue-4926')
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct.rs35
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_long_field_names.rs43
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_many_fields.rs44
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/enum_struct_field.rs35
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/minimum_example.rs10
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/struct_with_long_field_names.rs21
-rw-r--r--src/tools/rustfmt/tests/source/issue-4926/struct_with_many_fields.rs21
7 files changed, 209 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct.rs b/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct.rs
new file mode 100644
index 000000000..e55e41bd1
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct.rs
@@ -0,0 +1,35 @@
+
+// rustfmt-struct_field_align_threshold: 30
+
+struct X {
+ a: i32,
+ b: i32,
+ c: i32,
+}
+
+fn test(x: X) {
+ let d = {
+ let e = {
+ let f = {
+ let g = {
+ let h = {
+ let i = {
+ let j = {
+ matches!(
+ x,
+ X { a: 1_000, b: 1_000, .. }
+ )
+ };
+ j
+ };
+ i
+ };
+ h
+ };
+ g
+ };
+ f
+ };
+ e
+ };
+} \ No newline at end of file
diff --git a/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_long_field_names.rs b/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_long_field_names.rs
new file mode 100644
index 000000000..516699fa2
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_long_field_names.rs
@@ -0,0 +1,43 @@
+// rustfmt-struct_field_align_threshold: 30
+
+struct X {
+ really_really_long_field_a: i32,
+ really_really_really_long_field_b: i32,
+ really_really_really_really_long_field_c: i32,
+ really_really_really_really_really_long_field_d: i32,
+ really_really_really_really_really_really_long_field_e: i32,
+ f: i32,
+}
+
+fn test(x: X) {
+ let d = {
+ let e = {
+ let f = {
+ let g = {
+ let h = {
+ let i = {
+ let j = {
+ matches!(
+ x,
+ X {
+ really_really_long_field_a: 10,
+ really_really_really_long_field_b: 10,
+ really_really_really_really_long_field_c: 10,
+ really_really_really_really_really_long_field_d: 10,
+ really_really_really_really_really_really_long_field_e: 10, ..
+ }
+ )
+ };
+ j
+ };
+ i
+ };
+ h
+ };
+ g
+ };
+ f
+ };
+ e
+ };
+}
diff --git a/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_many_fields.rs b/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_many_fields.rs
new file mode 100644
index 000000000..38fd6f02c
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/deeply_nested_struct_with_many_fields.rs
@@ -0,0 +1,44 @@
+// rustfmt-struct_field_align_threshold: 30
+
+struct X {
+ a: i32,
+ b: i32,
+ c: i32,
+ d: i32,
+ e: i32,
+ f: i32,
+ g: i32,
+ h: i32,
+ i: i32,
+ j: i32,
+ k: i32,
+}
+
+fn test(x: X) {
+ let d = {
+ let e = {
+ let f = {
+ let g = {
+ let h = {
+ let i = {
+ let j = {
+ matches!(
+ x,
+ X {
+ a: 1_000, b: 1_000, c: 1_000, d: 1_000, e: 1_000, f: 1_000, g: 1_000, h: 1_000, i: 1_000, j: 1_000, ..
+ }
+ )
+ };
+ j
+ };
+ i
+ };
+ h
+ };
+ g
+ };
+ f
+ };
+ e
+ };
+}
diff --git a/src/tools/rustfmt/tests/source/issue-4926/enum_struct_field.rs b/src/tools/rustfmt/tests/source/issue-4926/enum_struct_field.rs
new file mode 100644
index 000000000..336378537
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/enum_struct_field.rs
@@ -0,0 +1,35 @@
+// rustfmt-struct_field_align_threshold: 30
+// rustfmt-enum_discrim_align_threshold: 30
+// rustfmt-imports_layout: HorizontalVertical
+
+#[derive(Default)]
+struct InnerStructA { bbbbbbbbb: i32, cccccccc: i32 }
+
+enum SomeEnumNamedD {
+ E(InnerStructA),
+ F {
+ ggggggggggggggggggggggggg: bool,
+ h: bool,
+ }
+}
+
+impl SomeEnumNamedD {
+ fn f_variant() -> Self {
+ Self::F { ggggggggggggggggggggggggg: true, h: true }
+ }
+}
+
+fn main() {
+ let kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk = SomeEnumNamedD::f_variant();
+ let something_we_care_about = matches!(
+ kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk,
+ SomeEnumNamedD::F {
+ ggggggggggggggggggggggggg: true,
+ ..
+ }
+ );
+
+ if something_we_care_about {
+ println!("Yup it happened");
+ }
+}
diff --git a/src/tools/rustfmt/tests/source/issue-4926/minimum_example.rs b/src/tools/rustfmt/tests/source/issue-4926/minimum_example.rs
new file mode 100644
index 000000000..2c3045dea
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/minimum_example.rs
@@ -0,0 +1,10 @@
+// rustfmt-struct_field_align_threshold: 30
+
+struct X { a: i32, b: i32 }
+
+fn test(x: X) {
+ let y = matches!(x, X {
+ a: 1,
+ ..
+ });
+}
diff --git a/src/tools/rustfmt/tests/source/issue-4926/struct_with_long_field_names.rs b/src/tools/rustfmt/tests/source/issue-4926/struct_with_long_field_names.rs
new file mode 100644
index 000000000..b8a37f071
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/struct_with_long_field_names.rs
@@ -0,0 +1,21 @@
+// rustfmt-struct_field_align_threshold: 30
+
+struct X {
+ really_really_long_field_a: i32,
+ really_really_really_long_field_b: i32,
+ really_really_really_really_long_field_c: i32,
+ really_really_really_really_really_long_field_d: i32,
+ really_really_really_really_really_really_long_field_e: i32,
+ f: i32,
+}
+
+fn test(x: X) {
+ let y = matches!(x, X {
+ really_really_long_field_a: 10,
+ really_really_really_long_field_b: 10,
+ really_really_really_really_long_field_c: 10,
+ really_really_really_really_really_long_field_d: 10,
+ really_really_really_really_really_really_long_field_e: 10,
+ ..
+ });
+}
diff --git a/src/tools/rustfmt/tests/source/issue-4926/struct_with_many_fields.rs b/src/tools/rustfmt/tests/source/issue-4926/struct_with_many_fields.rs
new file mode 100644
index 000000000..4adfd3b30
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-4926/struct_with_many_fields.rs
@@ -0,0 +1,21 @@
+// rustfmt-struct_field_align_threshold: 30
+
+struct X {
+ a: i32,
+ b: i32,
+ c: i32,
+ d: i32,
+ e: i32,
+ f: i32,
+ g: i32,
+ h: i32,
+ i: i32,
+ j: i32,
+ k: i32,
+}
+
+fn test(x: X) {
+ let y = matches!(x, X {
+ a: 1_000, b: 1_000, c: 1_000, d: 1_000, e: 1_000, f: 1_000, g: 1_000, h: 1_000, i: 1_000, j: 1_000, ..
+ });
+} \ No newline at end of file