summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.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/variant.rs')
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs
new file mode 100644
index 000000000..bc346aea5
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs
@@ -0,0 +1,33 @@
+// aux-build:variants.rs
+
+extern crate variants;
+
+use variants::NonExhaustiveVariants;
+
+fn main() {
+ let variant_struct = NonExhaustiveVariants::Struct { field: 640 };
+ //~^ ERROR cannot create non-exhaustive variant
+
+ let variant_tuple = NonExhaustiveVariants::Tuple(640);
+ //~^ ERROR tuple variant `Tuple` is private [E0603]
+
+ let variant_unit = NonExhaustiveVariants::Unit;
+ //~^ ERROR unit variant `Unit` is private [E0603]
+
+ match variant_struct {
+ NonExhaustiveVariants::Unit => "",
+ //~^ ERROR unit variant `Unit` is private [E0603]
+ NonExhaustiveVariants::Tuple(fe_tpl) => "",
+ //~^ ERROR tuple variant `Tuple` is private [E0603]
+ NonExhaustiveVariants::Struct { field } => ""
+ //~^ ERROR `..` required with variant marked as non-exhaustive
+ };
+
+ if let NonExhaustiveVariants::Tuple(fe_tpl) = variant_struct {
+ //~^ ERROR tuple variant `Tuple` is private [E0603]
+ }
+
+ if let NonExhaustiveVariants::Struct { field } = variant_struct {
+ //~^ ERROR `..` required with variant marked as non-exhaustive
+ }
+}