From: Pierre-Emmanuel Patry Date: Wed, 1 Mar 2023 13:20:23 +0000 (+0100) Subject: testsuite: Add a test for if let syntax X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac375e498312c00c3eebc738e77792f8b39e7d8d;p=people%2Fms%2Fgcc.git 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 00000000000..31e301fa3a3 --- /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 + }; +}