summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs')
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs
new file mode 100644
index 000000000..5f76b0cb2
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs
@@ -0,0 +1,32 @@
+// run-pass
+
+#![allow(unused_variables)]
+
+#[non_exhaustive]
+pub struct NormalStruct {
+ pub first_field: u16,
+ pub second_field: u16,
+}
+
+#[non_exhaustive]
+pub struct UnitStruct;
+
+#[non_exhaustive]
+pub struct TupleStruct (pub u16, pub u16);
+
+fn main() {
+ let ns = NormalStruct { first_field: 640, second_field: 480 };
+
+ let NormalStruct { first_field, second_field } = ns;
+
+ let ts = TupleStruct { 0: 340, 1: 480 };
+ let ts_constructor = TupleStruct(340, 480);
+
+ let TupleStruct { 0: first, 1: second } = ts;
+ let TupleStruct(first, second) = ts_constructor;
+
+ let us = UnitStruct {};
+ let us_constructor = UnitStruct;
+
+ let UnitStruct { } = us;
+}