about summary refs log tree commit diff
path: root/tests/ui/pattern/rfc-3637-guard-patterns/macro-rules.rs
blob: 76681f45bb336b32aaa01f47e4b0fc740eab0e67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//@ run-pass
//! Tests that the addition of guard patterns does not change the behavior of the `pat` macro
//! fragment.
#![feature(guard_patterns)]
#![allow(incomplete_features)]

macro_rules! has_guard {
    ($p:pat) => {
        false
    };
    ($p:pat if $e:expr) => {
        true
    };
}

fn main() {
    assert_eq!(has_guard!(Some(_)), false);
    assert_eq!(has_guard!(Some(_) if true), true);
    assert_eq!(has_guard!((Some(_) if true)), false);
}