diff options
author | DJMcNab <[email protected]> | 2019-01-28 20:03:56 +0000 |
---|---|---|
committer | DJMcNab <[email protected]> | 2019-01-28 20:03:56 +0000 |
commit | 00e6b5d26c82d5faff066c24418a0eb5741efcd1 (patch) | |
tree | 82ad741bab4f820850ba6f13e2b760cc840f43fb /crates/ra_syntax/tests/data/parser/ok | |
parent | 137b1ccb715fe795cdf6c528bef6f8df3387f158 (diff) |
Parse and validate attributes in blocks
Diffstat (limited to 'crates/ra_syntax/tests/data/parser/ok')
-rw-r--r-- | crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.rs | 20 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.txt | 167 |
2 files changed, 187 insertions, 0 deletions
diff --git a/crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.rs b/crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.rs new file mode 100644 index 000000000..88df8138e --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.rs | |||
@@ -0,0 +1,20 @@ | |||
1 | fn block() { | ||
2 | #![doc("Inner attributes allowed here")] | ||
3 | //! As are ModuleDoc style comments | ||
4 | { | ||
5 | #![doc("Inner attributes are allowed in blocks used as statements")] | ||
6 | #![doc("Being validated is not affected by duplcates")] | ||
7 | //! As are ModuleDoc style comments | ||
8 | }; | ||
9 | { | ||
10 | #![doc("Inner attributes are allowed in blocks when they are the last statement of another block")] | ||
11 | //! As are ModuleDoc style comments | ||
12 | } | ||
13 | } | ||
14 | |||
15 | // https://github.com/rust-analyzer/rust-analyzer/issues/689 | ||
16 | impl Whatever { | ||
17 | fn salsa_event(&self, event_fn: impl Fn() -> Event<Self>) { | ||
18 | #![allow(unused_variables)] // this is `inner_attr` of the block | ||
19 | } | ||
20 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.txt b/crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.txt new file mode 100644 index 000000000..a1ba645ef --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0045_block_inner_attrs.txt | |||
@@ -0,0 +1,167 @@ | |||
1 | SOURCE_FILE@[0; 686) | ||
2 | FN_DEF@[0; 461) | ||
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; 461) | ||
12 | L_CURLY@[11; 12) | ||
13 | WHITESPACE@[12; 17) | ||
14 | ATTR@[17; 57) | ||
15 | POUND@[17; 18) | ||
16 | EXCL@[18; 19) | ||
17 | TOKEN_TREE@[19; 57) | ||
18 | L_BRACK@[19; 20) | ||
19 | IDENT@[20; 23) "doc" | ||
20 | TOKEN_TREE@[23; 56) | ||
21 | L_PAREN@[23; 24) | ||
22 | STRING@[24; 55) | ||
23 | R_PAREN@[55; 56) | ||
24 | R_BRACK@[56; 57) | ||
25 | WHITESPACE@[57; 62) | ||
26 | COMMENT@[62; 97) | ||
27 | WHITESPACE@[97; 102) | ||
28 | EXPR_STMT@[102; 295) | ||
29 | BLOCK_EXPR@[102; 294) | ||
30 | BLOCK@[102; 294) | ||
31 | L_CURLY@[102; 103) | ||
32 | WHITESPACE@[103; 112) | ||
33 | ATTR@[112; 180) | ||
34 | POUND@[112; 113) | ||
35 | EXCL@[113; 114) | ||
36 | TOKEN_TREE@[114; 180) | ||
37 | L_BRACK@[114; 115) | ||
38 | IDENT@[115; 118) "doc" | ||
39 | TOKEN_TREE@[118; 179) | ||
40 | L_PAREN@[118; 119) | ||
41 | STRING@[119; 178) | ||
42 | R_PAREN@[178; 179) | ||
43 | R_BRACK@[179; 180) | ||
44 | WHITESPACE@[180; 189) | ||
45 | ATTR@[189; 244) | ||
46 | POUND@[189; 190) | ||
47 | EXCL@[190; 191) | ||
48 | TOKEN_TREE@[191; 244) | ||
49 | L_BRACK@[191; 192) | ||
50 | IDENT@[192; 195) "doc" | ||
51 | TOKEN_TREE@[195; 243) | ||
52 | L_PAREN@[195; 196) | ||
53 | STRING@[196; 242) | ||
54 | R_PAREN@[242; 243) | ||
55 | R_BRACK@[243; 244) | ||
56 | WHITESPACE@[244; 253) | ||
57 | COMMENT@[253; 288) | ||
58 | WHITESPACE@[288; 293) | ||
59 | R_CURLY@[293; 294) | ||
60 | SEMI@[294; 295) | ||
61 | WHITESPACE@[295; 300) | ||
62 | BLOCK_EXPR@[300; 459) | ||
63 | BLOCK@[300; 459) | ||
64 | L_CURLY@[300; 301) | ||
65 | WHITESPACE@[301; 310) | ||
66 | ATTR@[310; 409) | ||
67 | POUND@[310; 311) | ||
68 | EXCL@[311; 312) | ||
69 | TOKEN_TREE@[312; 409) | ||
70 | L_BRACK@[312; 313) | ||
71 | IDENT@[313; 316) "doc" | ||
72 | TOKEN_TREE@[316; 408) | ||
73 | L_PAREN@[316; 317) | ||
74 | STRING@[317; 407) | ||
75 | R_PAREN@[407; 408) | ||
76 | R_BRACK@[408; 409) | ||
77 | WHITESPACE@[409; 418) | ||
78 | COMMENT@[418; 453) | ||
79 | WHITESPACE@[453; 458) | ||
80 | R_CURLY@[458; 459) | ||
81 | WHITESPACE@[459; 460) | ||
82 | R_CURLY@[460; 461) | ||
83 | WHITESPACE@[461; 463) | ||
84 | COMMENT@[463; 523) | ||
85 | WHITESPACE@[523; 524) | ||
86 | IMPL_BLOCK@[524; 685) | ||
87 | IMPL_KW@[524; 528) | ||
88 | WHITESPACE@[528; 529) | ||
89 | PATH_TYPE@[529; 537) | ||
90 | PATH@[529; 537) | ||
91 | PATH_SEGMENT@[529; 537) | ||
92 | NAME_REF@[529; 537) | ||
93 | IDENT@[529; 537) "Whatever" | ||
94 | WHITESPACE@[537; 538) | ||
95 | ITEM_LIST@[538; 685) | ||
96 | L_CURLY@[538; 539) | ||
97 | WHITESPACE@[539; 544) | ||
98 | FN_DEF@[544; 683) | ||
99 | FN_KW@[544; 546) | ||
100 | WHITESPACE@[546; 547) | ||
101 | NAME@[547; 558) | ||
102 | IDENT@[547; 558) "salsa_event" | ||
103 | PARAM_LIST@[558; 601) | ||
104 | L_PAREN@[558; 559) | ||
105 | SELF_PARAM@[559; 564) | ||
106 | AMP@[559; 560) | ||
107 | SELF_KW@[560; 564) | ||
108 | COMMA@[564; 565) | ||
109 | WHITESPACE@[565; 566) | ||
110 | PARAM@[566; 600) | ||
111 | BIND_PAT@[566; 574) | ||
112 | NAME@[566; 574) | ||
113 | IDENT@[566; 574) "event_fn" | ||
114 | COLON@[574; 575) | ||
115 | WHITESPACE@[575; 576) | ||
116 | IMPL_TRAIT_TYPE@[576; 600) | ||
117 | IMPL_KW@[576; 580) | ||
118 | WHITESPACE@[580; 581) | ||
119 | PATH_TYPE@[581; 600) | ||
120 | PATH@[581; 600) | ||
121 | PATH_SEGMENT@[581; 600) | ||
122 | NAME_REF@[581; 583) | ||
123 | IDENT@[581; 583) "Fn" | ||
124 | PARAM_LIST@[583; 585) | ||
125 | L_PAREN@[583; 584) | ||
126 | R_PAREN@[584; 585) | ||
127 | WHITESPACE@[585; 586) | ||
128 | RET_TYPE@[586; 600) | ||
129 | THIN_ARROW@[586; 588) | ||
130 | WHITESPACE@[588; 589) | ||
131 | PATH_TYPE@[589; 600) | ||
132 | PATH@[589; 600) | ||
133 | PATH_SEGMENT@[589; 600) | ||
134 | NAME_REF@[589; 594) | ||
135 | IDENT@[589; 594) "Event" | ||
136 | TYPE_ARG_LIST@[594; 600) | ||
137 | L_ANGLE@[594; 595) | ||
138 | TYPE_ARG@[595; 599) | ||
139 | PATH_TYPE@[595; 599) | ||
140 | PATH@[595; 599) | ||
141 | PATH_SEGMENT@[595; 599) | ||
142 | NAME_REF@[595; 599) | ||
143 | IDENT@[595; 599) "Self" | ||
144 | R_ANGLE@[599; 600) | ||
145 | R_PAREN@[600; 601) | ||
146 | WHITESPACE@[601; 602) | ||
147 | BLOCK@[602; 683) | ||
148 | L_CURLY@[602; 603) | ||
149 | WHITESPACE@[603; 612) | ||
150 | ATTR@[612; 639) | ||
151 | POUND@[612; 613) | ||
152 | EXCL@[613; 614) | ||
153 | TOKEN_TREE@[614; 639) | ||
154 | L_BRACK@[614; 615) | ||
155 | IDENT@[615; 620) "allow" | ||
156 | TOKEN_TREE@[620; 638) | ||
157 | L_PAREN@[620; 621) | ||
158 | IDENT@[621; 637) "unused_variables" | ||
159 | R_PAREN@[637; 638) | ||
160 | R_BRACK@[638; 639) | ||
161 | WHITESPACE@[639; 640) | ||
162 | COMMENT@[640; 677) | ||
163 | WHITESPACE@[677; 682) | ||
164 | R_CURLY@[682; 683) | ||
165 | WHITESPACE@[683; 684) | ||
166 | R_CURLY@[684; 685) | ||
167 | WHITESPACE@[685; 686) | ||