Parse only outer_attributes for match arms for now
This commit is contained in:
parent
1c97c1ac11
commit
96e3ac389f
@ -1,15 +1,5 @@
|
||||
use super::*;
|
||||
|
||||
/// Parses both inner & outer attributes.
|
||||
///
|
||||
/// Allowing to run validation for reporting errors
|
||||
/// regarding attributes
|
||||
pub(super) fn all_attributes(p: &mut Parser) {
|
||||
while p.at(POUND) {
|
||||
attribute(p, p.nth(1) == EXCL)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn inner_attributes(p: &mut Parser) {
|
||||
while p.current() == POUND && p.nth(1) == EXCL {
|
||||
attribute(p, true)
|
||||
|
@ -331,11 +331,6 @@ pub(crate) fn match_arm_list(p: &mut Parser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// This may result in invalid attributes
|
||||
// if there are inner attributes mixed in together
|
||||
// with the outer attributes, but we allow parsing
|
||||
// those so we can run validation and report better errors
|
||||
|
||||
// test match_arms_outer_attributes
|
||||
// fn foo() {
|
||||
// match () {
|
||||
@ -349,7 +344,7 @@ pub(crate) fn match_arm_list(p: &mut Parser) {
|
||||
// _ => (),
|
||||
// }
|
||||
// }
|
||||
attributes::all_attributes(p);
|
||||
attributes::outer_attributes(p);
|
||||
|
||||
// test match_arms_commas
|
||||
// fn foo() {
|
||||
|
@ -33,18 +33,29 @@ SOURCE_FILE@[0; 293)
|
||||
R_PAREN@[40; 41)
|
||||
COMMA@[41; 42)
|
||||
WHITESPACE@[42; 51)
|
||||
err: `Inner attributes are only allowed directly after the opening brace of the match expression`
|
||||
ATTR@[51; 78)
|
||||
ATTR@[51; 52)
|
||||
POUND@[51; 52)
|
||||
EXCL@[52; 53)
|
||||
TOKEN_TREE@[53; 78)
|
||||
err: `expected `[``
|
||||
err: `expected pattern`
|
||||
MATCH_ARM@[52; 78)
|
||||
ERROR@[52; 53)
|
||||
EXCL@[52; 53)
|
||||
err: `expected FAT_ARROW`
|
||||
ARRAY_EXPR@[53; 78)
|
||||
L_BRACK@[53; 54)
|
||||
IDENT@[54; 57) "doc"
|
||||
TOKEN_TREE@[57; 77)
|
||||
L_PAREN@[57; 58)
|
||||
STRING@[58; 76)
|
||||
R_PAREN@[76; 77)
|
||||
CALL_EXPR@[54; 77)
|
||||
PATH_EXPR@[54; 57)
|
||||
PATH@[54; 57)
|
||||
PATH_SEGMENT@[54; 57)
|
||||
NAME_REF@[54; 57)
|
||||
IDENT@[54; 57) "doc"
|
||||
ARG_LIST@[57; 77)
|
||||
L_PAREN@[57; 58)
|
||||
LITERAL@[58; 76)
|
||||
STRING@[58; 76)
|
||||
R_PAREN@[76; 77)
|
||||
R_BRACK@[77; 78)
|
||||
err: `expected COMMA`
|
||||
WHITESPACE@[78; 87)
|
||||
MATCH_ARM@[87; 94)
|
||||
PLACEHOLDER_PAT@[87; 88)
|
||||
@ -92,23 +103,29 @@ SOURCE_FILE@[0; 293)
|
||||
R_PAREN@[149; 150)
|
||||
COMMA@[150; 151)
|
||||
WHITESPACE@[151; 160)
|
||||
err: `Inner attributes are only allowed directly after the opening brace of the match expression`
|
||||
ATTR@[160; 179)
|
||||
ATTR@[160; 161)
|
||||
POUND@[160; 161)
|
||||
EXCL@[161; 162)
|
||||
TOKEN_TREE@[162; 179)
|
||||
err: `expected `[``
|
||||
err: `expected pattern`
|
||||
MATCH_ARM@[161; 179)
|
||||
ERROR@[161; 162)
|
||||
EXCL@[161; 162)
|
||||
err: `expected FAT_ARROW`
|
||||
ARRAY_EXPR@[162; 179)
|
||||
L_BRACK@[162; 163)
|
||||
IDENT@[163; 166) "doc"
|
||||
TOKEN_TREE@[166; 178)
|
||||
L_PAREN@[166; 167)
|
||||
STRING@[167; 177)
|
||||
R_PAREN@[177; 178)
|
||||
CALL_EXPR@[163; 178)
|
||||
PATH_EXPR@[163; 166)
|
||||
PATH@[163; 166)
|
||||
PATH_SEGMENT@[163; 166)
|
||||
NAME_REF@[163; 166)
|
||||
IDENT@[163; 166) "doc"
|
||||
ARG_LIST@[166; 178)
|
||||
L_PAREN@[166; 167)
|
||||
LITERAL@[167; 177)
|
||||
STRING@[167; 177)
|
||||
R_PAREN@[177; 178)
|
||||
R_BRACK@[178; 179)
|
||||
WHITESPACE@[179; 184)
|
||||
err: `expected pattern`
|
||||
err: `expected FAT_ARROW`
|
||||
err: `expected expression`
|
||||
MATCH_ARM@[184; 184)
|
||||
R_CURLY@[184; 185)
|
||||
WHITESPACE@[185; 191)
|
||||
MATCH_EXPR@[191; 290)
|
||||
@ -132,18 +149,29 @@ SOURCE_FILE@[0; 293)
|
||||
R_PAREN@[220; 221)
|
||||
R_BRACK@[221; 222)
|
||||
WHITESPACE@[222; 231)
|
||||
err: `Inner attributes are only allowed directly after the opening brace of the match expression`
|
||||
ATTR@[231; 250)
|
||||
ATTR@[231; 232)
|
||||
POUND@[231; 232)
|
||||
EXCL@[232; 233)
|
||||
TOKEN_TREE@[233; 250)
|
||||
err: `expected `[``
|
||||
err: `expected pattern`
|
||||
MATCH_ARM@[232; 250)
|
||||
ERROR@[232; 233)
|
||||
EXCL@[232; 233)
|
||||
err: `expected FAT_ARROW`
|
||||
ARRAY_EXPR@[233; 250)
|
||||
L_BRACK@[233; 234)
|
||||
IDENT@[234; 237) "doc"
|
||||
TOKEN_TREE@[237; 249)
|
||||
L_PAREN@[237; 238)
|
||||
STRING@[238; 248)
|
||||
R_PAREN@[248; 249)
|
||||
CALL_EXPR@[234; 249)
|
||||
PATH_EXPR@[234; 237)
|
||||
PATH@[234; 237)
|
||||
PATH_SEGMENT@[234; 237)
|
||||
NAME_REF@[234; 237)
|
||||
IDENT@[234; 237) "doc"
|
||||
ARG_LIST@[237; 249)
|
||||
L_PAREN@[237; 238)
|
||||
LITERAL@[238; 248)
|
||||
STRING@[238; 248)
|
||||
R_PAREN@[248; 249)
|
||||
R_BRACK@[249; 250)
|
||||
err: `expected COMMA`
|
||||
WHITESPACE@[250; 259)
|
||||
MATCH_ARM@[259; 266)
|
||||
PLACEHOLDER_PAT@[259; 260)
|
||||
|
Loading…
x
Reference in New Issue
Block a user