aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/tests/data/parser/err
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-31 07:06:31 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-31 07:06:31 +0000
commit97ade899937dafcafa852177c85edb22ce0b80dc (patch)
treecf5f8bdc5647222c8300c3386c5c8d47283d5116 /crates/ra_syntax/tests/data/parser/err
parent777c79ce6bff0e70c8367f429f058f6d87ff3864 (diff)
parent00e6b5d26c82d5faff066c24418a0eb5741efcd1 (diff)
Merge #692
692: [WIP] Correctly parse attributes r=matklad a=DJMcNab Reference - https://doc.rust-lang.org/reference/attributes.html This fixes/investigates inner attributes for: - [x] `impl` blocks - [x] `extern` blocks - [x] `fn`s (fixes #689) - [x] `mod`s (already supported) - [x] 'block expressions' (the long text just describes all 'blocks' used as statements) This also investigates/fixes outer attributes for: - [ ] 'most statements' (see also: #685, https://doc.rust-lang.org/reference/expressions.html#expression-attributes) - [x] Enum variants, Struct and Union fields (Fixed in #507) - [ ] 'Match expression arms' (@matklad can you provide a test case which explains what this means?) - [ ] 'Generic lifetime or type parameters' - [ ] 'Elements of array expressions, tuple expressions, call expressions, tuple-style struct and enum variant expressions' - [ ] 'The tail expression of block expressions' Co-authored-by: DJMcNab <[email protected]>
Diffstat (limited to 'crates/ra_syntax/tests/data/parser/err')
-rw-r--r--crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.rs15
-rw-r--r--crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt114
2 files changed, 129 insertions, 0 deletions
diff --git a/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.rs b/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.rs
new file mode 100644
index 000000000..6a04f2d0a
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.rs
@@ -0,0 +1,15 @@
1fn block() {
2 let inner = {
3 #![doc("Inner attributes not allowed here")]
4 //! Nor are ModuleDoc comments
5 };
6 if true {
7 #![doc("Nor here")]
8 #![doc("We error on each attr")]
9 //! Nor are ModuleDoc comments
10 }
11 while true {
12 #![doc("Nor here")]
13 //! Nor are ModuleDoc comments
14 }
15}
diff --git a/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt b/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt
new file mode 100644
index 000000000..086aa79ac
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt
@@ -0,0 +1,114 @@
1SOURCE_FILE@[0; 350)
2 FN_DEF@[0; 349)
3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3)
5 NAME@[3; 8)
6 IDENT@[3; 8) "block"
7 PARAM_LIST@[8; 10)
8 L_PAREN@[8; 9)
9 R_PAREN@[9; 10)
10 WHITESPACE@[10; 11)
11 BLOCK@[11; 349)
12 L_CURLY@[11; 12)
13 WHITESPACE@[12; 17)
14 LET_STMT@[17; 129)
15 LET_KW@[17; 20)
16 WHITESPACE@[20; 21)
17 BIND_PAT@[21; 26)
18 NAME@[21; 26)
19 IDENT@[21; 26) "inner"
20 WHITESPACE@[26; 27)
21 EQ@[27; 28)
22 WHITESPACE@[28; 29)
23 BLOCK_EXPR@[29; 128)
24 BLOCK@[29; 128)
25 L_CURLY@[29; 30)
26 WHITESPACE@[30; 39)
27 err: `A block in this position cannot accept inner attributes`
28 ATTR@[39; 83)
29 POUND@[39; 40)
30 EXCL@[40; 41)
31 TOKEN_TREE@[41; 83)
32 L_BRACK@[41; 42)
33 IDENT@[42; 45) "doc"
34 TOKEN_TREE@[45; 82)
35 L_PAREN@[45; 46)
36 STRING@[46; 81)
37 R_PAREN@[81; 82)
38 R_BRACK@[82; 83)
39 WHITESPACE@[83; 92)
40 COMMENT@[92; 122)
41 WHITESPACE@[122; 127)
42 R_CURLY@[127; 128)
43 SEMI@[128; 129)
44 WHITESPACE@[129; 134)
45 EXPR_STMT@[134; 257)
46 IF_EXPR@[134; 257)
47 IF_KW@[134; 136)
48 WHITESPACE@[136; 137)
49 CONDITION@[137; 141)
50 LITERAL@[137; 141)
51 TRUE_KW@[137; 141)
52 WHITESPACE@[141; 142)
53 BLOCK@[142; 257)
54 L_CURLY@[142; 143)
55 WHITESPACE@[143; 152)
56 err: `A block in this position cannot accept inner attributes`
57 ATTR@[152; 171)
58 POUND@[152; 153)
59 EXCL@[153; 154)
60 TOKEN_TREE@[154; 171)
61 L_BRACK@[154; 155)
62 IDENT@[155; 158) "doc"
63 TOKEN_TREE@[158; 170)
64 L_PAREN@[158; 159)
65 STRING@[159; 169)
66 R_PAREN@[169; 170)
67 R_BRACK@[170; 171)
68 WHITESPACE@[171; 180)
69 err: `A block in this position cannot accept inner attributes`
70 ATTR@[180; 212)
71 POUND@[180; 181)
72 EXCL@[181; 182)
73 TOKEN_TREE@[182; 212)
74 L_BRACK@[182; 183)
75 IDENT@[183; 186) "doc"
76 TOKEN_TREE@[186; 211)
77 L_PAREN@[186; 187)
78 STRING@[187; 210)
79 R_PAREN@[210; 211)
80 R_BRACK@[211; 212)
81 WHITESPACE@[212; 221)
82 COMMENT@[221; 251)
83 WHITESPACE@[251; 256)
84 R_CURLY@[256; 257)
85 WHITESPACE@[257; 262)
86 WHILE_EXPR@[262; 347)
87 WHILE_KW@[262; 267)
88 WHITESPACE@[267; 268)
89 CONDITION@[268; 272)
90 LITERAL@[268; 272)
91 TRUE_KW@[268; 272)
92 WHITESPACE@[272; 273)
93 BLOCK@[273; 347)
94 L_CURLY@[273; 274)
95 WHITESPACE@[274; 283)
96 err: `A block in this position cannot accept inner attributes`
97 ATTR@[283; 302)
98 POUND@[283; 284)
99 EXCL@[284; 285)
100 TOKEN_TREE@[285; 302)
101 L_BRACK@[285; 286)
102 IDENT@[286; 289) "doc"
103 TOKEN_TREE@[289; 301)
104 L_PAREN@[289; 290)
105 STRING@[290; 300)
106 R_PAREN@[300; 301)
107 R_BRACK@[301; 302)
108 WHITESPACE@[302; 311)
109 COMMENT@[311; 341)
110 WHITESPACE@[341; 346)
111 R_CURLY@[346; 347)
112 WHITESPACE@[347; 348)
113 R_CURLY@[348; 349)
114 WHITESPACE@[349; 350)