summaryrefslogtreecommitdiffstats
path: root/src/test/ui/macros/macro-pat-neg-lit.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/macros/macro-pat-neg-lit.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/macros/macro-pat-neg-lit.rs b/src/test/ui/macros/macro-pat-neg-lit.rs
new file mode 100644
index 000000000..79c68fd25
--- /dev/null
+++ b/src/test/ui/macros/macro-pat-neg-lit.rs
@@ -0,0 +1,25 @@
+// run-pass
+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), )*
+ _ => None
+ }
+ }
+ }
+}
+
+enum_number!(Change {
+ Down = -1,
+ None = 0,
+ Up = 1,
+});
+
+fn main() {
+ if let Some(Change::Down) = foo(-1) {} else { panic!() }
+}