File tree 2 files changed +22
-0
lines changed
compiler/rustc_ast_pretty/src/pprust
tests/ui/pattern/rfc-3637-guard-patterns
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1710,10 +1710,12 @@ impl<'a> State<'a> {
1710
1710
}
1711
1711
}
1712
1712
PatKind :: Guard ( subpat, condition) => {
1713
+ self . popen ( ) ;
1713
1714
self . print_pat ( subpat) ;
1714
1715
self . space ( ) ;
1715
1716
self . word_space ( "if" ) ;
1716
1717
self . print_expr ( condition, FixupContext :: default ( ) ) ;
1718
+ self . pclose ( ) ;
1717
1719
}
1718
1720
PatKind :: Slice ( elts) => {
1719
1721
self . word ( "[" ) ;
Original file line number Diff line number Diff line change
1
+ //@ run-pass
2
+ //! Tests that the addition of guard patterns does not change the behavior of the `pat` macro
3
+ //! fragment.
4
+ #![ feature( guard_patterns) ]
5
+ #![ allow( incomplete_features) ]
6
+
7
+ macro_rules! has_guard {
8
+ ( $p: pat) => {
9
+ false
10
+ } ;
11
+ ( $p: pat if $e: expr) => {
12
+ true
13
+ } ;
14
+ }
15
+
16
+ fn main ( ) {
17
+ assert_eq ! ( has_guard!( Some ( _) ) , false ) ;
18
+ assert_eq ! ( has_guard!( Some ( _) if true ) , true ) ;
19
+ assert_eq ! ( has_guard!( ( Some ( _) if true ) ) , false ) ;
20
+ }
You can’t perform that action at this time.
0 commit comments