mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-29 08:54:50 +00:00
Address review comments
This commit is contained in:
parent
483f9e2580
commit
2459dbb4ba
@ -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("[");
|
||||
|
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…
Reference in New Issue
Block a user