aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 74b23e2f7..45f2e3de4 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -250,6 +250,7 @@ fn current_op(p: &Parser) -> (u8, SyntaxKind) {
250 T![!] if p.at(T![!=]) => (5, T![!=]), 250 T![!] if p.at(T![!=]) => (5, T![!=]),
251 T![-] if p.at(T![-=]) => (1, T![-=]), 251 T![-] if p.at(T![-=]) => (1, T![-=]),
252 T![-] => (10, T![-]), 252 T![-] => (10, T![-]),
253 T![as] => (12, T![as]),
253 254
254 _ => NOT_AN_OP 255 _ => NOT_AN_OP
255 } 256 }
@@ -278,6 +279,14 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> (Option<CompletedMarker>,
278 if op_bp < bp { 279 if op_bp < bp {
279 break; 280 break;
280 } 281 }
282 // test as_precedence
283 // fn foo() {
284 // let _ = &1 as *const i32;
285 // }
286 if p.at(T![as]) {
287 lhs = cast_expr(p, lhs);
288 continue;
289 }
281 let m = lhs.precede(p); 290 let m = lhs.precede(p);
282 p.bump(op); 291 p.bump(op);
283 292
@@ -344,6 +353,7 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)>
344 )); 353 ));
345 } 354 }
346 }; 355 };
356 // parse the interior of the unary expression
347 expr_bp(p, r, 255); 357 expr_bp(p, r, 255);
348 Some((m.complete(p, kind), BlockLike::NotBlock)) 358 Some((m.complete(p, kind), BlockLike::NotBlock))
349} 359}
@@ -378,7 +388,6 @@ fn postfix_expr(
378 } 388 }
379 }, 389 },
380 T![?] => try_expr(p, lhs), 390 T![?] => try_expr(p, lhs),
381 T![as] => cast_expr(p, lhs),
382 _ => break, 391 _ => break,
383 }; 392 };
384 allow_calls = true; 393 allow_calls = true;