mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Auto merge of #16310 - Veykril:range-access-parse, r=Veykril
fix: Fix incorrect parsing error on method call on range Fixes https://github.com/rust-lang/rust-analyzer/issues/16289
This commit is contained in:
commit
c246ecfd55
3 changed files with 62 additions and 1 deletions
|
@ -371,7 +371,15 @@ fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLik
|
|||
if p.at(op) {
|
||||
m = p.start();
|
||||
p.bump(op);
|
||||
if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(T!['{'])) {
|
||||
|
||||
// test closure_range_method_call
|
||||
// fn foo() {
|
||||
// || .. .method();
|
||||
// || .. .field;
|
||||
// }
|
||||
let has_access_after = p.at(T![.]) && p.nth_at(1, SyntaxKind::IDENT);
|
||||
let struct_forbidden = r.forbid_structs && p.at(T!['{']);
|
||||
if p.at_ts(EXPR_FIRST) && !has_access_after && !struct_forbidden {
|
||||
expr_bp(p, None, r, 2);
|
||||
}
|
||||
let cm = m.complete(p, RANGE_EXPR);
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
SOURCE_FILE
|
||||
FN
|
||||
FN_KW "fn"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "foo"
|
||||
PARAM_LIST
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
WHITESPACE " "
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
METHOD_CALL_EXPR
|
||||
CLOSURE_EXPR
|
||||
PARAM_LIST
|
||||
PIPE "|"
|
||||
PIPE "|"
|
||||
WHITESPACE " "
|
||||
RANGE_EXPR
|
||||
DOT2 ".."
|
||||
WHITESPACE " "
|
||||
DOT "."
|
||||
NAME_REF
|
||||
IDENT "method"
|
||||
ARG_LIST
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
FIELD_EXPR
|
||||
CLOSURE_EXPR
|
||||
PARAM_LIST
|
||||
PIPE "|"
|
||||
PIPE "|"
|
||||
WHITESPACE " "
|
||||
RANGE_EXPR
|
||||
DOT2 ".."
|
||||
WHITESPACE " "
|
||||
DOT "."
|
||||
NAME_REF
|
||||
IDENT "field"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
|
@ -0,0 +1,4 @@
|
|||
fn foo() {
|
||||
|| .. .method();
|
||||
|| .. .field;
|
||||
}
|
Loading…
Reference in a new issue