From: Pierre-Emmanuel Patry Date: Wed, 1 Mar 2023 13:20:23 +0000 (+0100) Subject: gccrs: testsuite: Add a test for if let syntax X-Git-Tag: basepoints/gcc-15~2819 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d344a64be5b8f985acdccf644e0959a0564a54d5;p=thirdparty%2Fgcc.git gccrs: 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 --- 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 000000000000..31e301fa3a37 --- /dev/null +++ b/gcc/testsuite/rust/compile/if_let_expr.rs @@ -0,0 +1,19 @@ +// { dg-options "-fsyntax-only" } + +pub enum Option { + 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 + }; +}