Skip to content

Commit 419b269

Browse files
committedDec 8, 2023
Add if_let_guard and let_chains pretty printer tests
1 parent f967532 commit 419b269

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎tests/ui/macros/stringify.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#![feature(coroutines)]
1111
#![feature(decl_macro)]
1212
#![feature(explicit_tail_calls)]
13+
#![feature(if_let_guard)]
14+
#![feature(let_chains)]
1315
#![feature(more_qualified_paths)]
1416
#![feature(never_patterns)]
1517
#![feature(raw_ref_op)]
@@ -47,7 +49,7 @@ macro_rules! c1 {
4749
// easy to find the cases where the two pretty-printing approaches give
4850
// different results.
4951
macro_rules! c2 {
50-
($frag:ident, [$($tt:tt)*], $s1:literal, $s2:literal) => {
52+
($frag:ident, [$($tt:tt)*], $s1:literal, $s2:literal $(,)?) => {
5153
assert_ne!($s1, $s2, "should use `c1!` instead");
5254
assert_eq!($frag!($($tt)*), $s1);
5355
assert_eq!(stringify!($($tt)*), $s2);
@@ -136,6 +138,23 @@ fn test_expr() {
136138

137139
// ExprKind::Let
138140
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+
);
139158

140159
// ExprKind::If
141160
c1!(expr, [ if true {} ], "if true {}");

0 commit comments

Comments
 (0)
Please sign in to comment.