1
Fork 0

Rollup merge of #133424 - Nadrieril:guard-patterns-parsing, r=fee1-dead

Parse guard patterns

This implements the parsing of [RFC3637 Guard Patterns](https://rust-lang.github.io/rfcs/3637-guard-patterns.html) (see also [tracking issue](https://github.com/rust-lang/rust/issues/129967)). This PR is extracted from https://github.com/rust-lang/rust/pull/129996 with minor modifications.

cc `@max-niederman`
This commit is contained in:
Matthias Krüger 2024-12-08 17:18:50 +01:00 committed by GitHub
commit 1868c8f66f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 328 additions and 81 deletions

View file

@ -1709,6 +1709,14 @@ impl<'a> State<'a> {
self.print_expr(e, FixupContext::default());
}
}
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("[");
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));