Address review comments

This commit is contained in:
Nadrieril 2024-12-07 12:49:08 +01:00
parent 483f9e2580
commit 2459dbb4ba
2 changed files with 22 additions and 0 deletions

View File

@ -1710,10 +1710,12 @@ impl<'a> State<'a> {
}
}
PatKind::Guard(subpat, condition) => {
self.popen();
self.print_pat(subpat);
self.space();
self.word_space("if");
self.print_expr(condition, FixupContext::default());
self.pclose();
}
PatKind::Slice(elts) => {
self.word("[");

View File

@ -0,0 +1,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);
}