Skip to content

Commit 2459dbb

Browse files
committed
Address review comments
1 parent 483f9e2 commit 2459dbb

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1710,10 +1710,12 @@ impl<'a> State<'a> {
17101710
}
17111711
}
17121712
PatKind::Guard(subpat, condition) => {
1713+
self.popen();
17131714
self.print_pat(subpat);
17141715
self.space();
17151716
self.word_space("if");
17161717
self.print_expr(condition, FixupContext::default());
1718+
self.pclose();
17171719
}
17181720
PatKind::Slice(elts) => {
17191721
self.word("[");
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

0 commit comments

Comments
 (0)