Remove parse error on array initializer attributes

This is actually allowed by the `rustc` parser but most attributes will
fail later due to attributes on expressions being experimental.
This commit is contained in:
Ryan Cumming 2019-06-30 19:55:50 +10:00
parent b01496538c
commit 2959aa446e
3 changed files with 0 additions and 76 deletions

View File

@ -177,21 +177,10 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
// 1,
// 2,
// ];
let first_member_has_attrs = p.at(T![#]);
attributes::outer_attributes(p);
expr(p);
if p.eat(T![;]) {
if first_member_has_attrs {
// test_err array_length_attributes
// pub const A: &[i64] = &[
// #[cfg(test)]
// 1;
// 2,
// ];
p.error("removing an expression is not supported in this position");
}
expr(p);
p.expect(T![']']);
return m.complete(p, ARRAY_EXPR);

View File

@ -1,5 +0,0 @@
pub const A: &[i64] = &[
#[cfg(test)]
1;
2,
];

View File

@ -1,60 +0,0 @@
SOURCE_FILE@[0; 53)
CONST_DEF@[0; 48)
VISIBILITY@[0; 3)
PUB_KW@[0; 3) "pub"
WHITESPACE@[3; 4) " "
CONST_KW@[4; 9) "const"
WHITESPACE@[9; 10) " "
NAME@[10; 11)
IDENT@[10; 11) "A"
COLON@[11; 12) ":"
WHITESPACE@[12; 13) " "
REFERENCE_TYPE@[13; 19)
AMP@[13; 14) "&"
SLICE_TYPE@[14; 19)
L_BRACK@[14; 15) "["
PATH_TYPE@[15; 18)
PATH@[15; 18)
PATH_SEGMENT@[15; 18)
NAME_REF@[15; 18)
IDENT@[15; 18) "i64"
R_BRACK@[18; 19) "]"
WHITESPACE@[19; 20) " "
EQ@[20; 21) "="
WHITESPACE@[21; 22) " "
REF_EXPR@[22; 48)
AMP@[22; 23) "&"
ARRAY_EXPR@[23; 48)
L_BRACK@[23; 24) "["
WHITESPACE@[24; 27) "\n "
ATTR@[27; 39)
POUND@[27; 28) "#"
TOKEN_TREE@[28; 39)
L_BRACK@[28; 29) "["
IDENT@[29; 32) "cfg"
TOKEN_TREE@[32; 38)
L_PAREN@[32; 33) "("
IDENT@[33; 37) "test"
R_PAREN@[37; 38) ")"
R_BRACK@[38; 39) "]"
WHITESPACE@[39; 42) "\n "
LITERAL@[42; 43)
INT_NUMBER@[42; 43) "1"
SEMI@[43; 44) ";"
WHITESPACE@[44; 47) "\n "
LITERAL@[47; 48)
INT_NUMBER@[47; 48) "2"
ERROR@[48; 49)
COMMA@[48; 49) ","
WHITESPACE@[49; 50) "\n"
ERROR@[50; 51)
R_BRACK@[50; 51) "]"
ERROR@[51; 52)
SEMI@[51; 52) ";"
WHITESPACE@[52; 53) "\n"
error 44: removing an expression is not supported in this position
error 48: expected R_BRACK
error 48: expected SEMI
error 48: expected an item
error 50: expected an item
error 51: expected an item