|
10 | 10 | #![feature(coroutines)]
|
11 | 11 | #![feature(decl_macro)]
|
12 | 12 | #![feature(explicit_tail_calls)]
|
| 13 | +#![feature(if_let_guard)] |
| 14 | +#![feature(let_chains)] |
13 | 15 | #![feature(more_qualified_paths)]
|
14 | 16 | #![feature(never_patterns)]
|
15 | 17 | #![feature(raw_ref_op)]
|
@@ -47,7 +49,7 @@ macro_rules! c1 {
|
47 | 49 | // easy to find the cases where the two pretty-printing approaches give
|
48 | 50 | // different results.
|
49 | 51 | macro_rules! c2 {
|
50 |
| - ($frag:ident, [$($tt:tt)*], $s1:literal, $s2:literal) => { |
| 52 | + ($frag:ident, [$($tt:tt)*], $s1:literal, $s2:literal $(,)?) => { |
51 | 53 | assert_ne!($s1, $s2, "should use `c1!` instead");
|
52 | 54 | assert_eq!($frag!($($tt)*), $s1);
|
53 | 55 | assert_eq!(stringify!($($tt)*), $s2);
|
@@ -136,6 +138,23 @@ fn test_expr() {
|
136 | 138 |
|
137 | 139 | // ExprKind::Let
|
138 | 140 | c1!(expr, [ if let Some(a) = b { c } else { d } ], "if let Some(a) = b { c } else { d }");
|
| 141 | + c1!(expr, [ if let _ = true && false {} ], "if let _ = true && false {}"); |
| 142 | + c1!(expr, [ if let _ = (true && false) {} ], "if let _ = (true && false) {}"); |
| 143 | + macro_rules! c2_if_let { |
| 144 | + ($expr:expr, $expr_expected:expr, $tokens_expected:expr $(,)?) => { |
| 145 | + c2!(expr, [ if let _ = $expr {} ], $expr_expected, $tokens_expected); |
| 146 | + }; |
| 147 | + } |
| 148 | + c2_if_let!( |
| 149 | + true && false, |
| 150 | + "if let _ = (true && false) {}", |
| 151 | + "if let _ = true && false {}", |
| 152 | + ); |
| 153 | + c2!(expr, |
| 154 | + [ match () { _ if let _ = Struct {} => {} } ], |
| 155 | + "match () { _ if let _ = (Struct {}) => {} }", // FIXME: do not parenthesize |
| 156 | + "match() { _ if let _ = Struct {} => {} }", |
| 157 | + ); |
139 | 158 |
|
140 | 159 | // ExprKind::If
|
141 | 160 | c1!(expr, [ if true {} ], "if true {}");
|
|
0 commit comments