diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-21 18:29:08 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:35 +0100 |
commit | 9e9be0f396e304e27598405ff26f02f0f0a47c96 (patch) | |
tree | ee13204b687c140f0b2b66ac43c70e128a8918df /gcc | |
parent | ab89ab377d8d99d9875dc0f2262c5282ce083bdf (diff) | |
download | gcc-9e9be0f396e304e27598405ff26f02f0f0a47c96.zip gcc-9e9be0f396e304e27598405ff26f02f0f0a47c96.tar.gz gcc-9e9be0f396e304e27598405ff26f02f0f0a47c96.tar.bz2 |
gccrs: Add regression tests for exclusive range pattern
Add a few test to check the exclusive range pattern feature. This feature
is experimental and shall not be enabled in stable rust.
gcc/testsuite/ChangeLog:
* rust/compile/exclusive_range_pattern.rs: New test.
* rust/compile/exclusive_range_pattern_feature_gate.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/rust/compile/exclusive_range_pattern.rs | 17 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/exclusive_range_pattern_feature_gate.rs | 8 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/exclusive_range_pattern.rs b/gcc/testsuite/rust/compile/exclusive_range_pattern.rs new file mode 100644 index 0000000..4840abe --- /dev/null +++ b/gcc/testsuite/rust/compile/exclusive_range_pattern.rs @@ -0,0 +1,17 @@ +// { dg-options "-fsyntax-only" } +#![feature(exclusive_range_pattern)] + +const TEN: usize = 10; + +fn test(n: usize) { + match n { + 0..TEN => (), + TEN..20 => (), + 20..30 => (), + _ => (), + } +} + +fn test2(t: usize) { + if let 0..10 = t {} +} diff --git a/gcc/testsuite/rust/compile/exclusive_range_pattern_feature_gate.rs b/gcc/testsuite/rust/compile/exclusive_range_pattern_feature_gate.rs new file mode 100644 index 0000000..4530214 --- /dev/null +++ b/gcc/testsuite/rust/compile/exclusive_range_pattern_feature_gate.rs @@ -0,0 +1,8 @@ +// { dg-options "-frust-compile-until=lowering" } + +fn test(n: usize) { + match n { + 0..10 => (), //{ dg-error "exclusive range pattern syntax is experimental." "" { target *-*-* } } + _ => (), + } +} |