summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/issue-5488.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rustfmt/tests/source/issue-5488.rs')
-rw-r--r--src/tools/rustfmt/tests/source/issue-5488.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/source/issue-5488.rs b/src/tools/rustfmt/tests/source/issue-5488.rs
new file mode 100644
index 000000000..d361632e2
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/issue-5488.rs
@@ -0,0 +1,17 @@
+// rustfmt-use_field_init_shorthand: true
+
+struct MyStruct(u32);
+struct AnotherStruct {
+ a: u32,
+}
+
+fn main() {
+ // Since MyStruct is a tuple struct, it should not be shorthanded to
+ // MyStruct { 0 } even if use_field_init_shorthand is enabled.
+ let instance = MyStruct { 0: 0 };
+
+ // Since AnotherStruct is not a tuple struct, the shorthand should
+ // apply.
+ let a = 10;
+ let instance = AnotherStruct { a: a };
+}