1884: Add indexing to record_field_pat r=matklad a=kjeremy

Fixes #1870 

Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
bors[bot] 2019-09-20 15:54:01 +00:00 committed by GitHub
commit 3575f7c4a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 91 additions and 2 deletions

View file

@ -168,6 +168,7 @@ fn record_field_pat_list(p: &mut Parser) {
T![.] if p.at(T![..]) => p.bump(T![..]),
IDENT if p.nth(1) == T![:] => record_field_pat(p),
INT_NUMBER if p.nth(1) == T![:] => record_field_pat(p),
T!['{'] => error_block(p, "expected ident"),
T![box] => {
box_pat(p);
@ -184,12 +185,21 @@ fn record_field_pat_list(p: &mut Parser) {
m.complete(p, RECORD_FIELD_PAT_LIST);
}
// test record_field_pat
// fn foo() {
// let S { 0: 1 } = ();
// let S { x: 1 } = ();
// }
fn record_field_pat(p: &mut Parser) {
assert!(p.at(IDENT));
assert!(p.at(IDENT) || p.at(INT_NUMBER));
assert!(p.nth(1) == T![:]);
let m = p.start();
name(p);
if !p.eat(INT_NUMBER) {
name(p)
}
p.bump_any();
pattern(p);
m.complete(p, RECORD_FIELD_PAT);