Address review comments
This commit is contained in:
parent
483f9e2580
commit
2459dbb4ba
2 changed files with 22 additions and 0 deletions
|
@ -1710,10 +1710,12 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatKind::Guard(subpat, condition) => {
|
PatKind::Guard(subpat, condition) => {
|
||||||
|
self.popen();
|
||||||
self.print_pat(subpat);
|
self.print_pat(subpat);
|
||||||
self.space();
|
self.space();
|
||||||
self.word_space("if");
|
self.word_space("if");
|
||||||
self.print_expr(condition, FixupContext::default());
|
self.print_expr(condition, FixupContext::default());
|
||||||
|
self.pclose();
|
||||||
}
|
}
|
||||||
PatKind::Slice(elts) => {
|
PatKind::Slice(elts) => {
|
||||||
self.word("[");
|
self.word("[");
|
||||||
|
|
20
tests/ui/pattern/rfc-3637-guard-patterns/macro-rules.rs
Normal file
20
tests/ui/pattern/rfc-3637-guard-patterns/macro-rules.rs
Normal 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);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue