aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar/expressions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/grammar/expressions.rs')
-rw-r--r--crates/ra_syntax/src/grammar/expressions.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs
index da78d85a2..2d1f17491 100644
--- a/crates/ra_syntax/src/grammar/expressions.rs
+++ b/crates/ra_syntax/src/grammar/expressions.rs
@@ -283,14 +283,10 @@ fn postfix_expr(
283 // } 283 // }
284 L_PAREN if allow_calls => call_expr(p, lhs), 284 L_PAREN if allow_calls => call_expr(p, lhs),
285 L_BRACK if allow_calls => index_expr(p, lhs), 285 L_BRACK if allow_calls => index_expr(p, lhs),
286 DOT if p.nth(1) == IDENT => { 286 DOT if p.nth(1) == IDENT && (p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON) => {
287 if p.nth(2) == L_PAREN || p.nth(2) == COLONCOLON { 287 method_call_expr(p, lhs)
288 method_call_expr(p, lhs)
289 } else {
290 field_expr(p, lhs)
291 }
292 } 288 }
293 DOT if p.nth(1) == INT_NUMBER => field_expr(p, lhs), 289 DOT => field_expr(p, lhs),
294 // test postfix_range 290 // test postfix_range
295 // fn foo() { let x = 1..; } 291 // fn foo() { let x = 1..; }
296 DOTDOT | DOTDOTEQ if !EXPR_FIRST.contains(p.nth(1)) => { 292 DOTDOT | DOTDOTEQ if !EXPR_FIRST.contains(p.nth(1)) => {
@@ -355,13 +351,15 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
355// x.0.bar; 351// x.0.bar;
356// } 352// }
357fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { 353fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
358 assert!(p.at(DOT) && (p.nth(1) == IDENT || p.nth(1) == INT_NUMBER)); 354 assert!(p.at(DOT));
359 let m = lhs.precede(p); 355 let m = lhs.precede(p);
360 p.bump(); 356 p.bump();
361 if p.at(IDENT) { 357 if p.at(IDENT) {
362 name_ref(p) 358 name_ref(p)
363 } else { 359 } else if p.at(INT_NUMBER) {
364 p.bump() 360 p.bump()
361 } else {
362 p.error("expected field name or number")
365 } 363 }
366 m.complete(p, FIELD_EXPR) 364 m.complete(p, FIELD_EXPR)
367} 365}