]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
testsuite: Add a test for if let syntax
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 1 Mar 2023 13:20:23 +0000 (14:20 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Wed, 1 Mar 2023 21:29:26 +0000 (21:29 +0000)
Add a new test to check the if let expression syntax parsing.

gcc/testsuite/ChangeLog:

* rust/compile/if_let_expr.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/rust/compile/if_let_expr.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/if_let_expr.rs b/gcc/testsuite/rust/compile/if_let_expr.rs
new file mode 100644 (file)
index 0000000..31e301f
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-options "-fsyntax-only" }
+
+pub enum Option<T> {
+    None,
+    Some(T),
+}
+
+fn main() {
+    let x = Option::Some(3);
+    let a = if let Option::Some(1) = x {
+        1
+    } else if x == Option::Some(2) {
+        2
+    } else if let Option::Some(y) = x {
+        y
+    } else {
+        -1
+    };
+}