mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Merge #1573
1573: fix: parse box syntax inside parentheses r=matklad a=csmoe r? @matklad Co-authored-by: csmoe <csmoe@msn.com>
This commit is contained in:
commit
25921f5a5f
3 changed files with 69 additions and 6 deletions
|
@ -43,6 +43,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
|
|||
L_BRACK,
|
||||
PIPE,
|
||||
MOVE_KW,
|
||||
BOX_KW,
|
||||
IF_KW,
|
||||
WHILE_KW,
|
||||
MATCH_KW,
|
||||
|
@ -529,6 +530,8 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
|
|||
// test box_expr
|
||||
// fn foo() {
|
||||
// let x = box 1i32;
|
||||
// let y = (box 1i32, box 2i32);
|
||||
// let z = Foo(box 1i32, box 2i32);
|
||||
// }
|
||||
fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
|
||||
assert!(p.at(T![box]));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
fn foo() {
|
||||
let x = box 1i32;
|
||||
let y = (box 1i32, box 2i32);
|
||||
let z = Foo(box 1i32, box 2i32);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_FILE@[0; 35)
|
||||
FN_DEF@[0; 34)
|
||||
SOURCE_FILE@[0; 106)
|
||||
FN_DEF@[0; 105)
|
||||
FN_KW@[0; 2) "fn"
|
||||
WHITESPACE@[2; 3) " "
|
||||
NAME@[3; 6)
|
||||
|
@ -8,7 +8,7 @@ SOURCE_FILE@[0; 35)
|
|||
L_PAREN@[6; 7) "("
|
||||
R_PAREN@[7; 8) ")"
|
||||
WHITESPACE@[8; 9) " "
|
||||
BLOCK@[9; 34)
|
||||
BLOCK@[9; 105)
|
||||
L_CURLY@[9; 10) "{"
|
||||
WHITESPACE@[10; 15) "\n "
|
||||
LET_STMT@[15; 32)
|
||||
|
@ -26,6 +26,64 @@ SOURCE_FILE@[0; 35)
|
|||
LITERAL@[27; 31)
|
||||
INT_NUMBER@[27; 31) "1i32"
|
||||
SEMI@[31; 32) ";"
|
||||
WHITESPACE@[32; 33) "\n"
|
||||
R_CURLY@[33; 34) "}"
|
||||
WHITESPACE@[34; 35) "\n"
|
||||
WHITESPACE@[32; 37) "\n "
|
||||
LET_STMT@[37; 66)
|
||||
LET_KW@[37; 40) "let"
|
||||
WHITESPACE@[40; 41) " "
|
||||
BIND_PAT@[41; 42)
|
||||
NAME@[41; 42)
|
||||
IDENT@[41; 42) "y"
|
||||
WHITESPACE@[42; 43) " "
|
||||
EQ@[43; 44) "="
|
||||
WHITESPACE@[44; 45) " "
|
||||
TUPLE_EXPR@[45; 65)
|
||||
L_PAREN@[45; 46) "("
|
||||
BOX_EXPR@[46; 54)
|
||||
BOX_KW@[46; 49) "box"
|
||||
WHITESPACE@[49; 50) " "
|
||||
LITERAL@[50; 54)
|
||||
INT_NUMBER@[50; 54) "1i32"
|
||||
COMMA@[54; 55) ","
|
||||
WHITESPACE@[55; 56) " "
|
||||
BOX_EXPR@[56; 64)
|
||||
BOX_KW@[56; 59) "box"
|
||||
WHITESPACE@[59; 60) " "
|
||||
LITERAL@[60; 64)
|
||||
INT_NUMBER@[60; 64) "2i32"
|
||||
R_PAREN@[64; 65) ")"
|
||||
SEMI@[65; 66) ";"
|
||||
WHITESPACE@[66; 71) "\n "
|
||||
LET_STMT@[71; 103)
|
||||
LET_KW@[71; 74) "let"
|
||||
WHITESPACE@[74; 75) " "
|
||||
BIND_PAT@[75; 76)
|
||||
NAME@[75; 76)
|
||||
IDENT@[75; 76) "z"
|
||||
WHITESPACE@[76; 77) " "
|
||||
EQ@[77; 78) "="
|
||||
WHITESPACE@[78; 79) " "
|
||||
CALL_EXPR@[79; 102)
|
||||
PATH_EXPR@[79; 82)
|
||||
PATH@[79; 82)
|
||||
PATH_SEGMENT@[79; 82)
|
||||
NAME_REF@[79; 82)
|
||||
IDENT@[79; 82) "Foo"
|
||||
ARG_LIST@[82; 102)
|
||||
L_PAREN@[82; 83) "("
|
||||
BOX_EXPR@[83; 91)
|
||||
BOX_KW@[83; 86) "box"
|
||||
WHITESPACE@[86; 87) " "
|
||||
LITERAL@[87; 91)
|
||||
INT_NUMBER@[87; 91) "1i32"
|
||||
COMMA@[91; 92) ","
|
||||
WHITESPACE@[92; 93) " "
|
||||
BOX_EXPR@[93; 101)
|
||||
BOX_KW@[93; 96) "box"
|
||||
WHITESPACE@[96; 97) " "
|
||||
LITERAL@[97; 101)
|
||||
INT_NUMBER@[97; 101) "2i32"
|
||||
R_PAREN@[101; 102) ")"
|
||||
SEMI@[102; 103) ";"
|
||||
WHITESPACE@[103; 104) "\n"
|
||||
R_CURLY@[104; 105) "}"
|
||||
WHITESPACE@[105; 106) "\n"
|
||||
|
|
Loading…
Reference in a new issue