mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Parse attributes in tuple expressions
This commit is contained in:
parent
4be9ed675e
commit
64caa027b8
3 changed files with 56 additions and 3 deletions
|
@ -156,11 +156,13 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker {
|
|||
let mut saw_expr = false;
|
||||
while !p.at(EOF) && !p.at(T![')']) {
|
||||
saw_expr = true;
|
||||
if !p.at_ts(EXPR_FIRST) {
|
||||
p.error("expected expression");
|
||||
|
||||
// test tuple_attrs
|
||||
// const A: (i64, i64) = (1, #[cfg(test)] 2);
|
||||
if !expr_with_attrs(p) {
|
||||
break;
|
||||
}
|
||||
expr(p);
|
||||
|
||||
if !p.at(T![')']) {
|
||||
saw_comma = true;
|
||||
p.expect(T![,]);
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
SOURCE_FILE@0..43
|
||||
CONST@0..42
|
||||
CONST_KW@0..5 "const"
|
||||
WHITESPACE@5..6 " "
|
||||
NAME@6..7
|
||||
IDENT@6..7 "A"
|
||||
COLON@7..8 ":"
|
||||
WHITESPACE@8..9 " "
|
||||
TUPLE_TYPE@9..19
|
||||
L_PAREN@9..10 "("
|
||||
PATH_TYPE@10..13
|
||||
PATH@10..13
|
||||
PATH_SEGMENT@10..13
|
||||
NAME_REF@10..13
|
||||
IDENT@10..13 "i64"
|
||||
COMMA@13..14 ","
|
||||
WHITESPACE@14..15 " "
|
||||
PATH_TYPE@15..18
|
||||
PATH@15..18
|
||||
PATH_SEGMENT@15..18
|
||||
NAME_REF@15..18
|
||||
IDENT@15..18 "i64"
|
||||
R_PAREN@18..19 ")"
|
||||
WHITESPACE@19..20 " "
|
||||
EQ@20..21 "="
|
||||
WHITESPACE@21..22 " "
|
||||
TUPLE_EXPR@22..41
|
||||
L_PAREN@22..23 "("
|
||||
LITERAL@23..24
|
||||
INT_NUMBER@23..24 "1"
|
||||
COMMA@24..25 ","
|
||||
WHITESPACE@25..26 " "
|
||||
LITERAL@26..40
|
||||
ATTR@26..38
|
||||
POUND@26..27 "#"
|
||||
L_BRACK@27..28 "["
|
||||
PATH@28..31
|
||||
PATH_SEGMENT@28..31
|
||||
NAME_REF@28..31
|
||||
IDENT@28..31 "cfg"
|
||||
TOKEN_TREE@31..37
|
||||
L_PAREN@31..32 "("
|
||||
IDENT@32..36 "test"
|
||||
R_PAREN@36..37 ")"
|
||||
R_BRACK@37..38 "]"
|
||||
WHITESPACE@38..39 " "
|
||||
INT_NUMBER@39..40 "2"
|
||||
R_PAREN@40..41 ")"
|
||||
SEMICOLON@41..42 ";"
|
||||
WHITESPACE@42..43 "\n"
|
|
@ -0,0 +1 @@
|
|||
const A: (i64, i64) = (1, #[cfg(test)] 2);
|
Loading…
Reference in a new issue