summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/patkind-litrange-no-expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/pattern/patkind-litrange-no-expr.rs')
-rw-r--r--tests/ui/pattern/patkind-litrange-no-expr.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/pattern/patkind-litrange-no-expr.rs b/tests/ui/pattern/patkind-litrange-no-expr.rs
new file mode 100644
index 000000000..7ef541cb5
--- /dev/null
+++ b/tests/ui/pattern/patkind-litrange-no-expr.rs
@@ -0,0 +1,24 @@
+macro_rules! enum_number {
+ ($name:ident { $($variant:ident = $value:expr, )* }) => {
+ enum $name {
+ $($variant = $value,)*
+ }
+
+ fn foo(value: i32) -> Option<$name> {
+ match value {
+ $( $value => Some($name::$variant), )* // PatKind::Lit
+ $( $value ..= 42 => Some($name::$variant), )* // PatKind::Range
+ _ => None
+ }
+ }
+ }
+}
+
+enum_number!(Change {
+ Pos = 1,
+ Neg = -1,
+ Arith = 1 + 1, //~ ERROR arbitrary expressions aren't allowed in patterns
+ //~| ERROR arbitrary expressions aren't allowed in patterns
+});
+
+fn main() {}