Support if let match guards

This commit is contained in:
Jonas Schievink 2021-08-13 00:21:42 +02:00
parent 4466e07fd7
commit d568e7686a
10 changed files with 90 additions and 27 deletions

View file

@ -458,12 +458,17 @@ fn match_arm(p: &mut Parser) {
// fn foo() {
// match () {
// _ if foo => (),
// _ if let foo = bar => (),
// }
// }
fn match_guard(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T![if]));
let m = p.start();
p.bump(T![if]);
if p.eat(T![let]) {
patterns::pattern_top(p);
p.expect(T![=]);
}
expr(p);
m.complete(p, MATCH_GUARD)
}