public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] testsuite: Add a test for if let syntax
@ 2023-03-05 11:41 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-05 11:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ac375e498312c00c3eebc738e77792f8b39e7d8d

commit ac375e498312c00c3eebc738e77792f8b39e7d8d
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Wed Mar 1 14:20:23 2023 +0100

    testsuite: Add a test for if let syntax
    
    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>

Diff:
---
 gcc/testsuite/rust/compile/if_let_expr.rs | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gcc/testsuite/rust/compile/if_let_expr.rs b/gcc/testsuite/rust/compile/if_let_expr.rs
new file mode 100644
index 00000000000..31e301fa3a3
--- /dev/null
+++ b/gcc/testsuite/rust/compile/if_let_expr.rs
@@ -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
+    };
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-05 11:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-05 11:41 [gcc/devel/rust/master] testsuite: Add a test for if let syntax Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).