diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-01 14:20:23 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-03-01 21:29:26 +0000 |
commit | ac375e498312c00c3eebc738e77792f8b39e7d8d (patch) | |
tree | f19f532a33ff1cbc675ad2bfd4eafade5c28aa82 | |
parent | 1f24ea4b3cdd25b019e2f972753a992beaacdd3a (diff) | |
download | gcc-ac375e498312c00c3eebc738e77792f8b39e7d8d.zip gcc-ac375e498312c00c3eebc738e77792f8b39e7d8d.tar.gz gcc-ac375e498312c00c3eebc738e77792f8b39e7d8d.tar.bz2 |
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>
-rw-r--r-- | gcc/testsuite/rust/compile/if_let_expr.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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 0000000..31e301f --- /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 + }; +} |