mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Merge #1884
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:
commit
3575f7c4a2
3 changed files with 91 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue