diff options
author | veetaha <[email protected]> | 2020-04-22 02:16:28 +0100 |
---|---|---|
committer | veetaha <[email protected]> | 2020-05-10 17:06:28 +0100 |
commit | 3554866d67809e027ad6faeda1604a36a27c6561 (patch) | |
tree | 8975c95bb6a425d113fad793f565761b6a1ad62e /crates/ra_syntax/src/ast/generated | |
parent | e0e384a34ab06b18c76f8020df149bef392c04c7 (diff) |
Run codegen of ast types with documentation
Diffstat (limited to 'crates/ra_syntax/src/ast/generated')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 1483 |
1 files changed, 1345 insertions, 138 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index b00c15608..dbb009b68 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -5,7 +5,9 @@ use crate::{ | |||
5 | SyntaxKind::{self, *}, | 5 | SyntaxKind::{self, *}, |
6 | SyntaxNode, SyntaxToken, T, | 6 | SyntaxNode, SyntaxToken, T, |
7 | }; | 7 | }; |
8 | 8 | /// The entire Rust source file. Includes all top-level inner attributes and module items. | |
9 | /// | ||
10 | /// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html) | ||
9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 11 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
10 | pub struct SourceFile { | 12 | pub struct SourceFile { |
11 | pub(crate) syntax: SyntaxNode, | 13 | pub(crate) syntax: SyntaxNode, |
@@ -16,7 +18,28 @@ impl ast::DocCommentsOwner for SourceFile {} | |||
16 | impl SourceFile { | 18 | impl SourceFile { |
17 | pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } | 19 | pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } |
18 | } | 20 | } |
19 | 21 | /// Function definition either with body or not. | |
22 | /// Includes all of its attributes and doc comments. | ||
23 | /// | ||
24 | /// ``` | ||
25 | /// ❰ | ||
26 | /// /// Docs | ||
27 | /// #[attr] | ||
28 | /// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32 | ||
29 | /// where | ||
30 | /// T: Debug | ||
31 | /// { | ||
32 | /// 42 | ||
33 | /// } | ||
34 | /// ❱ | ||
35 | /// | ||
36 | /// extern "C" { | ||
37 | /// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱ | ||
38 | /// } | ||
39 | /// ``` | ||
40 | /// | ||
41 | /// - [Reference](https://doc.rust-lang.org/reference/items/functions.html) | ||
42 | /// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions) | ||
20 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 43 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
21 | pub struct FnDef { | 44 | pub struct FnDef { |
22 | pub(crate) syntax: SyntaxNode, | 45 | pub(crate) syntax: SyntaxNode, |
@@ -38,7 +61,13 @@ impl FnDef { | |||
38 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 61 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
39 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 62 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
40 | } | 63 | } |
41 | 64 | /// Return type annotation. | |
65 | /// | ||
66 | /// ``` | ||
67 | /// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) } | ||
68 | /// ``` | ||
69 | /// | ||
70 | /// [Reference](https://doc.rust-lang.org/reference/items/functions.html) | ||
42 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 71 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
43 | pub struct RetType { | 72 | pub struct RetType { |
44 | pub(crate) syntax: SyntaxNode, | 73 | pub(crate) syntax: SyntaxNode, |
@@ -47,7 +76,26 @@ impl RetType { | |||
47 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | 76 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } |
48 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 77 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
49 | } | 78 | } |
50 | 79 | /// Struct definition. | |
80 | /// Includes all of its attributes and doc comments. | ||
81 | /// | ||
82 | /// ``` | ||
83 | /// ❰ | ||
84 | /// /// Docs | ||
85 | /// #[attr] | ||
86 | /// struct Foo<T> where T: Debug { | ||
87 | /// /// Docs | ||
88 | /// #[attr] | ||
89 | /// pub a: u32, | ||
90 | /// b: T, | ||
91 | /// } | ||
92 | /// ❱ | ||
93 | /// | ||
94 | /// ❰ struct Foo; ❱ | ||
95 | /// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱ | ||
96 | /// ``` | ||
97 | /// | ||
98 | /// [Reference](https://doc.rust-lang.org/reference/items/structs.html) | ||
51 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 99 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
52 | pub struct StructDef { | 100 | pub struct StructDef { |
53 | pub(crate) syntax: SyntaxNode, | 101 | pub(crate) syntax: SyntaxNode, |
@@ -62,7 +110,23 @@ impl StructDef { | |||
62 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | 110 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } |
63 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 111 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
64 | } | 112 | } |
65 | 113 | /// Union definition. | |
114 | /// Includes all of its attributes and doc comments. | ||
115 | /// | ||
116 | /// ``` | ||
117 | /// ❰ | ||
118 | /// /// Docs | ||
119 | /// #[attr] | ||
120 | /// pub union Foo<T> where T: Debug { | ||
121 | /// /// Docs | ||
122 | /// #[attr] | ||
123 | /// a: T, | ||
124 | /// b: u32, | ||
125 | /// } | ||
126 | /// ❱ | ||
127 | /// ``` | ||
128 | /// | ||
129 | /// [Reference](https://doc.rust-lang.org/reference/items/unions.html) | ||
66 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 130 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
67 | pub struct UnionDef { | 131 | pub struct UnionDef { |
68 | pub(crate) syntax: SyntaxNode, | 132 | pub(crate) syntax: SyntaxNode, |
@@ -78,7 +142,19 @@ impl UnionDef { | |||
78 | support::child(&self.syntax) | 142 | support::child(&self.syntax) |
79 | } | 143 | } |
80 | } | 144 | } |
81 | 145 | /// Record field definition list including enclosing curly braces. | |
146 | /// | ||
147 | /// ``` | ||
148 | /// struct Foo // same for union | ||
149 | /// ❰ | ||
150 | /// { | ||
151 | /// a: u32, | ||
152 | /// b: bool, | ||
153 | /// } | ||
154 | /// ❱ | ||
155 | /// ``` | ||
156 | /// | ||
157 | /// [Reference](https://doc.rust-lang.org/reference/items/structs.html) | ||
82 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 158 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
83 | pub struct RecordFieldDefList { | 159 | pub struct RecordFieldDefList { |
84 | pub(crate) syntax: SyntaxNode, | 160 | pub(crate) syntax: SyntaxNode, |
@@ -88,7 +164,22 @@ impl RecordFieldDefList { | |||
88 | pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } | 164 | pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } |
89 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 165 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
90 | } | 166 | } |
91 | 167 | /// Record field definition including its attributes and doc comments. | |
168 | /// | ||
169 | /// ` `` | ||
170 | /// same for union | ||
171 | /// struct Foo { | ||
172 | /// ❰ | ||
173 | /// /// Docs | ||
174 | /// #[attr] | ||
175 | /// pub a: u32 | ||
176 | /// ❱ | ||
177 | /// | ||
178 | /// ❰ b: bool ❱ | ||
179 | /// } | ||
180 | /// ``` | ||
181 | /// | ||
182 | /// [Reference](https://doc.rust-lang.org/reference/items/structs.html) | ||
92 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 183 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
93 | pub struct RecordFieldDef { | 184 | pub struct RecordFieldDef { |
94 | pub(crate) syntax: SyntaxNode, | 185 | pub(crate) syntax: SyntaxNode, |
@@ -99,7 +190,13 @@ impl ast::AttrsOwner for RecordFieldDef {} | |||
99 | impl ast::DocCommentsOwner for RecordFieldDef {} | 190 | impl ast::DocCommentsOwner for RecordFieldDef {} |
100 | impl ast::TypeAscriptionOwner for RecordFieldDef {} | 191 | impl ast::TypeAscriptionOwner for RecordFieldDef {} |
101 | impl RecordFieldDef {} | 192 | impl RecordFieldDef {} |
102 | 193 | /// Tuple field definition list including enclosing parens. | |
194 | /// | ||
195 | /// ``` | ||
196 | /// struct Foo ❰ (u32, String, Vec<u32>) ❱; | ||
197 | /// ``` | ||
198 | /// | ||
199 | /// [Reference](https://doc.rust-lang.org/reference/items/structs.html) | ||
103 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 200 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
104 | pub struct TupleFieldDefList { | 201 | pub struct TupleFieldDefList { |
105 | pub(crate) syntax: SyntaxNode, | 202 | pub(crate) syntax: SyntaxNode, |
@@ -109,7 +206,13 @@ impl TupleFieldDefList { | |||
109 | pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } | 206 | pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } |
110 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 207 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
111 | } | 208 | } |
112 | 209 | /// Tuple field definition including its attributes. | |
210 | /// | ||
211 | /// ``` | ||
212 | /// struct Foo(❰ #[attr] u32 ❱); | ||
213 | /// ``` | ||
214 | /// | ||
215 | /// [Reference](https://doc.rust-lang.org/reference/items/structs.html) | ||
113 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 216 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
114 | pub struct TupleFieldDef { | 217 | pub struct TupleFieldDef { |
115 | pub(crate) syntax: SyntaxNode, | 218 | pub(crate) syntax: SyntaxNode, |
@@ -119,7 +222,29 @@ impl ast::AttrsOwner for TupleFieldDef {} | |||
119 | impl TupleFieldDef { | 222 | impl TupleFieldDef { |
120 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 223 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
121 | } | 224 | } |
122 | 225 | /// Enum definition. | |
226 | /// Includes all of its attributes and doc comments. | ||
227 | /// | ||
228 | /// ``` | ||
229 | /// ❰ | ||
230 | /// /// Docs | ||
231 | /// #[attr] | ||
232 | /// pub enum Foo<T> where T: Debug { | ||
233 | /// /// Docs | ||
234 | /// #[attr] | ||
235 | /// Bar, | ||
236 | /// Baz(#[attr] u32), | ||
237 | /// Bruh { | ||
238 | /// a: u32, | ||
239 | /// /// Docs | ||
240 | /// #[attr] | ||
241 | /// b: T, | ||
242 | /// } | ||
243 | /// } | ||
244 | /// ❱ | ||
245 | /// ``` | ||
246 | /// | ||
247 | /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html) | ||
123 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 248 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
124 | pub struct EnumDef { | 249 | pub struct EnumDef { |
125 | pub(crate) syntax: SyntaxNode, | 250 | pub(crate) syntax: SyntaxNode, |
@@ -133,7 +258,22 @@ impl EnumDef { | |||
133 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } | 258 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } |
134 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } | 259 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } |
135 | } | 260 | } |
136 | 261 | /// Enum variant definition list including enclosing curly braces. | |
262 | /// | ||
263 | /// ``` | ||
264 | /// enum Foo | ||
265 | /// ❰ | ||
266 | /// { | ||
267 | /// Bar, | ||
268 | /// Baz(u32), | ||
269 | /// Bruh { | ||
270 | /// a: u32 | ||
271 | /// } | ||
272 | /// } | ||
273 | /// ❱ | ||
274 | /// ``` | ||
275 | /// | ||
276 | /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html) | ||
137 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 277 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
138 | pub struct EnumVariantList { | 278 | pub struct EnumVariantList { |
139 | pub(crate) syntax: SyntaxNode, | 279 | pub(crate) syntax: SyntaxNode, |
@@ -143,7 +283,21 @@ impl EnumVariantList { | |||
143 | pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } | 283 | pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } |
144 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 284 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
145 | } | 285 | } |
146 | 286 | /// Enum variant definition including its attributes and discriminant value definition. | |
287 | /// | ||
288 | /// ``` | ||
289 | /// enum Foo { | ||
290 | /// ❰ | ||
291 | /// /// Docs | ||
292 | /// #[attr] | ||
293 | /// Bar | ||
294 | /// ❱ | ||
295 | /// | ||
296 | /// // same for tuple and record variants | ||
297 | /// } | ||
298 | /// ``` | ||
299 | /// | ||
300 | /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html) | ||
147 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 301 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
148 | pub struct EnumVariant { | 302 | pub struct EnumVariant { |
149 | pub(crate) syntax: SyntaxNode, | 303 | pub(crate) syntax: SyntaxNode, |
@@ -157,7 +311,20 @@ impl EnumVariant { | |||
157 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 311 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
158 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 312 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
159 | } | 313 | } |
160 | 314 | /// Trait definition. | |
315 | /// Includes all of its attributes and doc comments. | ||
316 | /// | ||
317 | /// ``` | ||
318 | /// ❰ | ||
319 | /// /// Docs | ||
320 | /// #[attr] | ||
321 | /// pub unsafe trait Foo<T>: Debug where T: Debug { | ||
322 | /// // ... | ||
323 | /// } | ||
324 | /// ❱ | ||
325 | /// ``` | ||
326 | /// | ||
327 | /// [Reference](https://doc.rust-lang.org/reference/items/traits.html) | ||
161 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 328 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
162 | pub struct TraitDef { | 329 | pub struct TraitDef { |
163 | pub(crate) syntax: SyntaxNode, | 330 | pub(crate) syntax: SyntaxNode, |
@@ -174,7 +341,27 @@ impl TraitDef { | |||
174 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } | 341 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } |
175 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 342 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
176 | } | 343 | } |
177 | 344 | /// Module definition either with body or not. | |
345 | /// Includes all of its inner and outer attributes, module items, doc comments. | ||
346 | /// | ||
347 | /// ``` | ||
348 | /// ❰ | ||
349 | /// /// Docs | ||
350 | /// #[attr] | ||
351 | /// pub mod foo; | ||
352 | /// ❱ | ||
353 | /// | ||
354 | /// ❰ | ||
355 | /// /// Docs | ||
356 | /// #[attr] | ||
357 | /// pub mod bar { | ||
358 | /// //! Inner docs | ||
359 | /// #![inner_attr] | ||
360 | /// } | ||
361 | /// ❱ | ||
362 | /// ``` | ||
363 | /// | ||
364 | /// [Reference](https://doc.rust-lang.org/reference/items/modules.html) | ||
178 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 365 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
179 | pub struct Module { | 366 | pub struct Module { |
180 | pub(crate) syntax: SyntaxNode, | 367 | pub(crate) syntax: SyntaxNode, |
@@ -188,7 +375,28 @@ impl Module { | |||
188 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 375 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
189 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 376 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
190 | } | 377 | } |
191 | 378 | /// Item defintion list. | |
379 | /// This is used for both top-level items and impl block items. | ||
380 | /// | ||
381 | /// ``` | ||
382 | /// ❰ | ||
383 | /// fn foo {} | ||
384 | /// struct Bar; | ||
385 | /// enum Baz; | ||
386 | /// trait Bruh; | ||
387 | /// const BRUUH: u32 = 42; | ||
388 | /// ❱ | ||
389 | /// | ||
390 | /// impl Foo | ||
391 | /// ❰ | ||
392 | /// { | ||
393 | /// fn bar() {} | ||
394 | /// const BAZ: u32 = 42; | ||
395 | /// } | ||
396 | /// ❱ | ||
397 | /// ``` | ||
398 | /// | ||
399 | /// [Reference](https://doc.rust-lang.org/reference/items.html) | ||
192 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 400 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
193 | pub struct ItemList { | 401 | pub struct ItemList { |
194 | pub(crate) syntax: SyntaxNode, | 402 | pub(crate) syntax: SyntaxNode, |
@@ -199,7 +407,18 @@ impl ItemList { | |||
199 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } | 407 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } |
200 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 408 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
201 | } | 409 | } |
202 | 410 | /// Constant variable definition. | |
411 | /// Includes all of its attributes and doc comments. | ||
412 | /// | ||
413 | /// ``` | ||
414 | /// ❰ | ||
415 | /// /// Docs | ||
416 | /// #[attr] | ||
417 | /// pub const FOO: u32 = 42; | ||
418 | /// ❱ | ||
419 | /// ``` | ||
420 | /// | ||
421 | /// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html) | ||
203 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 422 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
204 | pub struct ConstDef { | 423 | pub struct ConstDef { |
205 | pub(crate) syntax: SyntaxNode, | 424 | pub(crate) syntax: SyntaxNode, |
@@ -217,7 +436,18 @@ impl ConstDef { | |||
217 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 436 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
218 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 437 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
219 | } | 438 | } |
220 | 439 | /// Static variable definition. | |
440 | /// Includes all of its attributes and doc comments. | ||
441 | /// | ||
442 | /// ``` | ||
443 | /// ❰ | ||
444 | /// /// Docs | ||
445 | /// #[attr] | ||
446 | /// pub static mut FOO: u32 = 42; | ||
447 | /// ❱ | ||
448 | /// ``` | ||
449 | /// | ||
450 | /// [Reference](https://doc.rust-lang.org/reference/items/static-items.html) | ||
221 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 451 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
222 | pub struct StaticDef { | 452 | pub struct StaticDef { |
223 | pub(crate) syntax: SyntaxNode, | 453 | pub(crate) syntax: SyntaxNode, |
@@ -235,7 +465,24 @@ impl StaticDef { | |||
235 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 465 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
236 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 466 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
237 | } | 467 | } |
238 | 468 | /// Type alias definition. | |
469 | /// Includes associated type clauses with type bounds. | ||
470 | /// | ||
471 | /// ``` | ||
472 | /// ❰ | ||
473 | /// /// Docs | ||
474 | /// #[attr] | ||
475 | /// pub type Foo<T> where T: Debug = T; | ||
476 | /// ❱ | ||
477 | /// | ||
478 | /// trait Bar { | ||
479 | /// ❰ type Baz: Debug; ❱ | ||
480 | /// ❰ type Bruh = String; ❱ | ||
481 | /// ❰ type Bruuh: Debug = u32; ❱ | ||
482 | /// } | ||
483 | /// ``` | ||
484 | /// | ||
485 | /// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html) | ||
239 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 486 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
240 | pub struct TypeAliasDef { | 487 | pub struct TypeAliasDef { |
241 | pub(crate) syntax: SyntaxNode, | 488 | pub(crate) syntax: SyntaxNode, |
@@ -253,7 +500,20 @@ impl TypeAliasDef { | |||
253 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 500 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
254 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 501 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
255 | } | 502 | } |
256 | 503 | /// Inherent and trait impl definition. | |
504 | /// Includes all of its inner and outer attributes. | ||
505 | /// | ||
506 | /// ``` | ||
507 | /// ❰ | ||
508 | /// #[attr] | ||
509 | /// unsafe impl<T> !Foo for Bar where T: Debug { | ||
510 | /// #![inner_attr] | ||
511 | /// // ... | ||
512 | /// } | ||
513 | /// ❱ | ||
514 | /// ``` | ||
515 | /// | ||
516 | /// [Reference](https://doc.rust-lang.org/reference/items/implementations.html) | ||
257 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 517 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
258 | pub struct ImplDef { | 518 | pub struct ImplDef { |
259 | pub(crate) syntax: SyntaxNode, | 519 | pub(crate) syntax: SyntaxNode, |
@@ -270,7 +530,16 @@ impl ImplDef { | |||
270 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 530 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
271 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 531 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
272 | } | 532 | } |
273 | 533 | /// Parenthesized type reference. | |
534 | /// Note: parens are only used for grouping, this is not a tuple type. | ||
535 | /// | ||
536 | /// ``` | ||
537 | /// // This is effectively just `u32`. | ||
538 | /// // Single-item tuple must be defined with a trailing comma: `(u32,)` | ||
539 | /// type Foo = ❰ (u32) ❱; | ||
540 | /// | ||
541 | /// let bar: &'static ❰ (dyn Debug) ❱ = "bruh"; | ||
542 | /// ``` | ||
274 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 543 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
275 | pub struct ParenType { | 544 | pub struct ParenType { |
276 | pub(crate) syntax: SyntaxNode, | 545 | pub(crate) syntax: SyntaxNode, |
@@ -280,7 +549,13 @@ impl ParenType { | |||
280 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 549 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
281 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 550 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
282 | } | 551 | } |
283 | 552 | /// Unnamed tuple type. | |
553 | /// | ||
554 | /// ``` | ||
555 | /// let foo: ❰ (u32, bool) ❱ = (42, true); | ||
556 | /// ``` | ||
557 | /// | ||
558 | /// [Reference](https://doc.rust-lang.org/reference/types/tuple.html) | ||
284 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 559 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
285 | pub struct TupleType { | 560 | pub struct TupleType { |
286 | pub(crate) syntax: SyntaxNode, | 561 | pub(crate) syntax: SyntaxNode, |
@@ -290,7 +565,17 @@ impl TupleType { | |||
290 | pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } | 565 | pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } |
291 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 566 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
292 | } | 567 | } |
293 | 568 | /// The never type (i.e. the exclamation point). | |
569 | /// | ||
570 | /// ``` | ||
571 | /// type T = ❰ ! ❱; | ||
572 | /// | ||
573 | /// fn no_return() -> ❰ ! ❱ { | ||
574 | /// loop {} | ||
575 | /// } | ||
576 | /// ``` | ||
577 | /// | ||
578 | /// [Reference](https://doc.rust-lang.org/reference/types/never.html) | ||
294 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 579 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
295 | pub struct NeverType { | 580 | pub struct NeverType { |
296 | pub(crate) syntax: SyntaxNode, | 581 | pub(crate) syntax: SyntaxNode, |
@@ -298,7 +583,17 @@ pub struct NeverType { | |||
298 | impl NeverType { | 583 | impl NeverType { |
299 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | 584 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } |
300 | } | 585 | } |
301 | 586 | /// Path to a type. | |
587 | /// Includes single identifier type names and elaborate paths with | ||
588 | /// generic parameters. | ||
589 | /// | ||
590 | /// ``` | ||
591 | /// type Foo = ❰ String ❱; | ||
592 | /// type Bar = ❰ std::vec::Vec<T> ❱; | ||
593 | /// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱; | ||
594 | /// ``` | ||
595 | /// | ||
596 | /// [Reference](https://doc.rust-lang.org/reference/paths.html) | ||
302 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 597 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
303 | pub struct PathType { | 598 | pub struct PathType { |
304 | pub(crate) syntax: SyntaxNode, | 599 | pub(crate) syntax: SyntaxNode, |
@@ -306,7 +601,14 @@ pub struct PathType { | |||
306 | impl PathType { | 601 | impl PathType { |
307 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 602 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
308 | } | 603 | } |
309 | 604 | /// Raw pointer type. | |
605 | /// | ||
606 | /// ``` | ||
607 | /// type Foo = ❰ *const u32 ❱; | ||
608 | /// type Bar = ❰ *mut u32 ❱; | ||
609 | /// ``` | ||
610 | /// | ||
611 | /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut) | ||
310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 612 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
311 | pub struct PointerType { | 613 | pub struct PointerType { |
312 | pub(crate) syntax: SyntaxNode, | 614 | pub(crate) syntax: SyntaxNode, |
@@ -317,7 +619,13 @@ impl PointerType { | |||
317 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 619 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
318 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 620 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
319 | } | 621 | } |
320 | 622 | /// Array type. | |
623 | /// | ||
624 | /// ``` | ||
625 | /// type Foo = ❰ [u32; 24 - 3] ❱; | ||
626 | /// ``` | ||
627 | /// | ||
628 | /// [Reference](https://doc.rust-lang.org/reference/types/array.html) | ||
321 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 629 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
322 | pub struct ArrayType { | 630 | pub struct ArrayType { |
323 | pub(crate) syntax: SyntaxNode, | 631 | pub(crate) syntax: SyntaxNode, |
@@ -329,7 +637,13 @@ impl ArrayType { | |||
329 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 637 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
330 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 638 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
331 | } | 639 | } |
332 | 640 | /// Slice type. | |
641 | /// | ||
642 | /// ``` | ||
643 | /// type Foo = ❰ [u8] ❱; | ||
644 | /// ``` | ||
645 | /// | ||
646 | /// [Reference](https://doc.rust-lang.org/reference/types/slice.html) | ||
333 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 647 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
334 | pub struct SliceType { | 648 | pub struct SliceType { |
335 | pub(crate) syntax: SyntaxNode, | 649 | pub(crate) syntax: SyntaxNode, |
@@ -339,7 +653,13 @@ impl SliceType { | |||
339 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 653 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
340 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 654 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
341 | } | 655 | } |
342 | 656 | /// Reference type. | |
657 | /// | ||
658 | /// ``` | ||
659 | /// type Foo = ❰ &'static str ❱; | ||
660 | /// ``` | ||
661 | /// | ||
662 | /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html) | ||
343 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 663 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
344 | pub struct ReferenceType { | 664 | pub struct ReferenceType { |
345 | pub(crate) syntax: SyntaxNode, | 665 | pub(crate) syntax: SyntaxNode, |
@@ -352,7 +672,13 @@ impl ReferenceType { | |||
352 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 672 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
353 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 673 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
354 | } | 674 | } |
355 | 675 | /// Placeholder type (i.e. the underscore). | |
676 | /// | ||
677 | /// ``` | ||
678 | /// let foo: ❰ _ ❱ = 42_u32; | ||
679 | /// ``` | ||
680 | /// | ||
681 | /// [Reference](https://doc.rust-lang.org/reference/types/inferred.html) | ||
356 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 682 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
357 | pub struct PlaceholderType { | 683 | pub struct PlaceholderType { |
358 | pub(crate) syntax: SyntaxNode, | 684 | pub(crate) syntax: SyntaxNode, |
@@ -360,7 +686,15 @@ pub struct PlaceholderType { | |||
360 | impl PlaceholderType { | 686 | impl PlaceholderType { |
361 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } | 687 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } |
362 | } | 688 | } |
363 | 689 | /// Function pointer type (not to be confused with `Fn*` family of traits). | |
690 | /// | ||
691 | /// ``` | ||
692 | /// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱; | ||
693 | /// | ||
694 | /// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱; | ||
695 | /// ``` | ||
696 | /// | ||
697 | /// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html) | ||
364 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 698 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
365 | pub struct FnPointerType { | 699 | pub struct FnPointerType { |
366 | pub(crate) syntax: SyntaxNode, | 700 | pub(crate) syntax: SyntaxNode, |
@@ -372,7 +706,13 @@ impl FnPointerType { | |||
372 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 706 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
373 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 707 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
374 | } | 708 | } |
375 | 709 | /// Higher order type. | |
710 | /// | ||
711 | /// ``` | ||
712 | /// type Foo = ❰ for<'a> fn(&'a str) ❱; | ||
713 | /// ``` | ||
714 | /// | ||
715 | /// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html) | ||
376 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 716 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
377 | pub struct ForType { | 717 | pub struct ForType { |
378 | pub(crate) syntax: SyntaxNode, | 718 | pub(crate) syntax: SyntaxNode, |
@@ -382,7 +722,13 @@ impl ForType { | |||
382 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | 722 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } |
383 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 723 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
384 | } | 724 | } |
385 | 725 | /// Opaque `impl Trait` type. | |
726 | /// | ||
727 | /// ``` | ||
728 | /// fn foo(bar: ❰ impl Debug + Eq ❱) {} | ||
729 | /// ``` | ||
730 | /// | ||
731 | /// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html) | ||
386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 732 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
387 | pub struct ImplTraitType { | 733 | pub struct ImplTraitType { |
388 | pub(crate) syntax: SyntaxNode, | 734 | pub(crate) syntax: SyntaxNode, |
@@ -391,7 +737,13 @@ impl ast::TypeBoundsOwner for ImplTraitType {} | |||
391 | impl ImplTraitType { | 737 | impl ImplTraitType { |
392 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } | 738 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } |
393 | } | 739 | } |
394 | 740 | /// Trait object type. | |
741 | /// | ||
742 | /// ``` | ||
743 | /// type Foo = ❰ dyn Debug ❱; | ||
744 | /// ``` | ||
745 | /// | ||
746 | /// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html) | ||
395 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 747 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
396 | pub struct DynTraitType { | 748 | pub struct DynTraitType { |
397 | pub(crate) syntax: SyntaxNode, | 749 | pub(crate) syntax: SyntaxNode, |
@@ -400,7 +752,13 @@ impl ast::TypeBoundsOwner for DynTraitType {} | |||
400 | impl DynTraitType { | 752 | impl DynTraitType { |
401 | pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) } | 753 | pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) } |
402 | } | 754 | } |
403 | 755 | /// Tuple literal. | |
756 | /// | ||
757 | /// ``` | ||
758 | /// ❰ (42, true) ❱; | ||
759 | /// ``` | ||
760 | /// | ||
761 | /// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html) | ||
404 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 762 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
405 | pub struct TupleExpr { | 763 | pub struct TupleExpr { |
406 | pub(crate) syntax: SyntaxNode, | 764 | pub(crate) syntax: SyntaxNode, |
@@ -411,7 +769,15 @@ impl TupleExpr { | |||
411 | pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } | 769 | pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } |
412 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 770 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
413 | } | 771 | } |
414 | 772 | /// Array literal. | |
773 | /// | ||
774 | /// ``` | ||
775 | /// ❰ [#![inner_attr] true, false, true] ❱; | ||
776 | /// | ||
777 | /// ❰ ["baz"; 24] ❱; | ||
778 | /// ``` | ||
779 | /// | ||
780 | /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html) | ||
415 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 781 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
416 | pub struct ArrayExpr { | 782 | pub struct ArrayExpr { |
417 | pub(crate) syntax: SyntaxNode, | 783 | pub(crate) syntax: SyntaxNode, |
@@ -423,7 +789,14 @@ impl ArrayExpr { | |||
423 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 789 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
424 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 790 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
425 | } | 791 | } |
426 | 792 | /// Parenthesized expression. | |
793 | /// Note: parens are only used for grouping, this is not a tuple literal. | ||
794 | /// | ||
795 | /// ``` | ||
796 | /// ❰ (#![inner_attr] 2 + 2) ❱ * 2; | ||
797 | /// ``` | ||
798 | /// | ||
799 | /// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html) | ||
427 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 800 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
428 | pub struct ParenExpr { | 801 | pub struct ParenExpr { |
429 | pub(crate) syntax: SyntaxNode, | 802 | pub(crate) syntax: SyntaxNode, |
@@ -434,7 +807,19 @@ impl ParenExpr { | |||
434 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 807 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
435 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 808 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
436 | } | 809 | } |
437 | 810 | /// Path to a symbol in expression context. | |
811 | /// Includes single identifier variable names and elaborate paths with | ||
812 | /// generic parameters. | ||
813 | /// | ||
814 | /// ``` | ||
815 | /// ❰ Some::<i32> ❱; | ||
816 | /// ❰ foo ❱ + 42; | ||
817 | /// ❰ Vec::<i32>::push ❱; | ||
818 | /// ❰ <[i32]>::reverse ❱; | ||
819 | /// ❰ <String as std::borrow::Borrow<str>>::borrow ❱; | ||
820 | /// ``` | ||
821 | /// | ||
822 | /// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html) | ||
438 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 823 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
439 | pub struct PathExpr { | 824 | pub struct PathExpr { |
440 | pub(crate) syntax: SyntaxNode, | 825 | pub(crate) syntax: SyntaxNode, |
@@ -442,21 +827,48 @@ pub struct PathExpr { | |||
442 | impl PathExpr { | 827 | impl PathExpr { |
443 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 828 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
444 | } | 829 | } |
445 | 830 | /// Anonymous callable object literal a.k.a. closure, lambda or functor. | |
831 | /// | ||
832 | /// ``` | ||
833 | /// ❰ || 42 ❱; | ||
834 | /// ❰ |a: u32| val + 1 ❱; | ||
835 | /// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱; | ||
836 | /// ❰ move || baz ❱; | ||
837 | /// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱ | ||
838 | /// ``` | ||
839 | /// | ||
840 | /// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html) | ||
446 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 841 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
447 | pub struct LambdaExpr { | 842 | pub struct LambdaExpr { |
448 | pub(crate) syntax: SyntaxNode, | 843 | pub(crate) syntax: SyntaxNode, |
449 | } | 844 | } |
450 | impl ast::AttrsOwner for LambdaExpr {} | 845 | impl ast::AttrsOwner for LambdaExpr {} |
451 | impl LambdaExpr { | 846 | impl LambdaExpr { |
452 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
453 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | 847 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } |
454 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } | 848 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } |
455 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 849 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
456 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 850 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
457 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 851 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
458 | } | 852 | } |
459 | 853 | /// If expression. Includes both regular `if` and `if let` forms. | |
854 | /// Beware that `else if` is a special case syntax sugar, because in general | ||
855 | /// there has to be block expression after `else`. | ||
856 | /// | ||
857 | /// ``` | ||
858 | /// ❰ if bool_cond { 42 } ❱ | ||
859 | /// ❰ if bool_cond { 42 } else { 24 } ❱ | ||
860 | /// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱ | ||
861 | /// | ||
862 | /// ❰ | ||
863 | /// if let Pattern(foo) = bar { | ||
864 | /// foo | ||
865 | /// } else { | ||
866 | /// panic!(); | ||
867 | /// } | ||
868 | /// ❱ | ||
869 | /// ``` | ||
870 | /// | ||
871 | /// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html) | ||
460 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 872 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
461 | pub struct IfExpr { | 873 | pub struct IfExpr { |
462 | pub(crate) syntax: SyntaxNode, | 874 | pub(crate) syntax: SyntaxNode, |
@@ -466,7 +878,17 @@ impl IfExpr { | |||
466 | pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } | 878 | pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } |
467 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | 879 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } |
468 | } | 880 | } |
469 | 881 | /// Unconditional loop expression. | |
882 | /// | ||
883 | /// ``` | ||
884 | /// ❰ | ||
885 | /// loop { | ||
886 | /// // yeah, it's that simple... | ||
887 | /// } | ||
888 | /// ❱ | ||
889 | /// ``` | ||
890 | /// | ||
891 | /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html) | ||
470 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 892 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
471 | pub struct LoopExpr { | 893 | pub struct LoopExpr { |
472 | pub(crate) syntax: SyntaxNode, | 894 | pub(crate) syntax: SyntaxNode, |
@@ -476,7 +898,20 @@ impl ast::LoopBodyOwner for LoopExpr {} | |||
476 | impl LoopExpr { | 898 | impl LoopExpr { |
477 | pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) } | 899 | pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) } |
478 | } | 900 | } |
479 | 901 | /// Block expression with an optional prefix (label, try ketword, | |
902 | /// unsafe keyword, async keyword...). | ||
903 | /// | ||
904 | /// ``` | ||
905 | /// ❰ | ||
906 | /// 'label: try { | ||
907 | /// None? | ||
908 | /// } | ||
909 | /// ❱ | ||
910 | /// ``` | ||
911 | /// | ||
912 | /// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html) | ||
913 | /// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks) | ||
914 | /// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks) | ||
480 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 915 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
481 | pub struct EffectExpr { | 916 | pub struct EffectExpr { |
482 | pub(crate) syntax: SyntaxNode, | 917 | pub(crate) syntax: SyntaxNode, |
@@ -489,7 +924,19 @@ impl EffectExpr { | |||
489 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | 924 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } |
490 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 925 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
491 | } | 926 | } |
492 | 927 | /// For loop expression. | |
928 | /// Note: record struct literals are not valid as iterable expression | ||
929 | /// due to ambiguity. | ||
930 | /// | ||
931 | /// ``` | ||
932 | /// ❰ | ||
933 | /// for i in (0..4) { | ||
934 | /// dbg!(i); | ||
935 | /// } | ||
936 | /// ❱ | ||
937 | /// ``` | ||
938 | /// | ||
939 | /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops) | ||
493 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 940 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
494 | pub struct ForExpr { | 941 | pub struct ForExpr { |
495 | pub(crate) syntax: SyntaxNode, | 942 | pub(crate) syntax: SyntaxNode, |
@@ -502,7 +949,22 @@ impl ForExpr { | |||
502 | pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } | 949 | pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } |
503 | pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } | 950 | pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } |
504 | } | 951 | } |
505 | 952 | /// While loop expression. Includes both regular `while` and `while let` forms. | |
953 | /// | ||
954 | /// ``` | ||
955 | /// ❰ | ||
956 | /// while bool_cond { | ||
957 | /// 42; | ||
958 | /// } | ||
959 | /// ❱ | ||
960 | /// ❰ | ||
961 | /// while let Pattern(foo) = bar { | ||
962 | /// bar += 1; | ||
963 | /// } | ||
964 | /// ❱ | ||
965 | /// ``` | ||
966 | /// | ||
967 | /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops) | ||
506 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 968 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
507 | pub struct WhileExpr { | 969 | pub struct WhileExpr { |
508 | pub(crate) syntax: SyntaxNode, | 970 | pub(crate) syntax: SyntaxNode, |
@@ -513,7 +975,22 @@ impl WhileExpr { | |||
513 | pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) } | 975 | pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) } |
514 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | 976 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } |
515 | } | 977 | } |
516 | 978 | /// Continue expression. | |
979 | /// | ||
980 | /// ``` | ||
981 | /// while bool_cond { | ||
982 | /// ❰ continue ❱; | ||
983 | /// } | ||
984 | /// | ||
985 | /// 'outer: loop { | ||
986 | /// loop { | ||
987 | /// ❰ continue 'outer ❱; | ||
988 | /// } | ||
989 | /// } | ||
990 | /// | ||
991 | /// ``` | ||
992 | /// | ||
993 | /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions) | ||
517 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 994 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
518 | pub struct ContinueExpr { | 995 | pub struct ContinueExpr { |
519 | pub(crate) syntax: SyntaxNode, | 996 | pub(crate) syntax: SyntaxNode, |
@@ -527,7 +1004,25 @@ impl ContinueExpr { | |||
527 | support::token(&self.syntax, T![lifetime]) | 1004 | support::token(&self.syntax, T![lifetime]) |
528 | } | 1005 | } |
529 | } | 1006 | } |
530 | 1007 | /// Break expression. | |
1008 | /// | ||
1009 | /// ``` | ||
1010 | /// while bool_cond { | ||
1011 | /// ❰ break ❱; | ||
1012 | /// } | ||
1013 | /// 'outer: loop { | ||
1014 | /// for foo in bar { | ||
1015 | /// ❰ break 'outer ❱; | ||
1016 | /// } | ||
1017 | /// } | ||
1018 | /// 'outer: loop { | ||
1019 | /// loop { | ||
1020 | /// ❰ break 'outer 42 ❱; | ||
1021 | /// } | ||
1022 | /// } | ||
1023 | /// ``` | ||
1024 | /// | ||
1025 | /// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions) | ||
531 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1026 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
532 | pub struct BreakExpr { | 1027 | pub struct BreakExpr { |
533 | pub(crate) syntax: SyntaxNode, | 1028 | pub(crate) syntax: SyntaxNode, |
@@ -540,7 +1035,20 @@ impl BreakExpr { | |||
540 | } | 1035 | } |
541 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1036 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
542 | } | 1037 | } |
543 | 1038 | /// Label. | |
1039 | /// | ||
1040 | /// ``` | ||
1041 | /// ❰ 'outer: ❱ loop {} | ||
1042 | /// | ||
1043 | /// let foo = ❰ 'bar: ❱ loop {} | ||
1044 | /// | ||
1045 | /// ❰ 'baz: ❱ { | ||
1046 | /// break 'baz; | ||
1047 | /// } | ||
1048 | /// ``` | ||
1049 | /// | ||
1050 | /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels) | ||
1051 | /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md) | ||
544 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1052 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
545 | pub struct Label { | 1053 | pub struct Label { |
546 | pub(crate) syntax: SyntaxNode, | 1054 | pub(crate) syntax: SyntaxNode, |
@@ -550,7 +1058,21 @@ impl Label { | |||
550 | support::token(&self.syntax, T![lifetime]) | 1058 | support::token(&self.syntax, T![lifetime]) |
551 | } | 1059 | } |
552 | } | 1060 | } |
553 | 1061 | /// Block expression. Includes unsafe blocks and block labels. | |
1062 | /// | ||
1063 | /// ``` | ||
1064 | /// let foo = ❰ | ||
1065 | /// { | ||
1066 | /// #![inner_attr] | ||
1067 | /// ❰ { } ❱ | ||
1068 | /// | ||
1069 | /// ❰ 'label: { break 'label } ❱ | ||
1070 | /// } | ||
1071 | /// ❱; | ||
1072 | /// ``` | ||
1073 | /// | ||
1074 | /// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html) | ||
1075 | /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md) | ||
554 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1076 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
555 | pub struct BlockExpr { | 1077 | pub struct BlockExpr { |
556 | pub(crate) syntax: SyntaxNode, | 1078 | pub(crate) syntax: SyntaxNode, |
@@ -563,7 +1085,17 @@ impl BlockExpr { | |||
563 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1085 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
564 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 1086 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
565 | } | 1087 | } |
566 | 1088 | /// Return expression. | |
1089 | /// | ||
1090 | /// ``` | ||
1091 | /// || ❰ return 42 ❱; | ||
1092 | /// | ||
1093 | /// fn bar() { | ||
1094 | /// ❰ return ❱; | ||
1095 | /// } | ||
1096 | /// ``` | ||
1097 | /// | ||
1098 | /// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html) | ||
567 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1099 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
568 | pub struct ReturnExpr { | 1100 | pub struct ReturnExpr { |
569 | pub(crate) syntax: SyntaxNode, | 1101 | pub(crate) syntax: SyntaxNode, |
@@ -572,7 +1104,16 @@ impl ast::AttrsOwner for ReturnExpr {} | |||
572 | impl ReturnExpr { | 1104 | impl ReturnExpr { |
573 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1105 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
574 | } | 1106 | } |
575 | 1107 | /// Call expression (not to be confused with method call expression, it is | |
1108 | /// a separate ast node). | ||
1109 | /// | ||
1110 | /// ``` | ||
1111 | /// ❰ foo() ❱; | ||
1112 | /// ❰ &str::len("bar") ❱; | ||
1113 | /// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱; | ||
1114 | /// ``` | ||
1115 | /// | ||
1116 | /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html) | ||
576 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1117 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
577 | pub struct CallExpr { | 1118 | pub struct CallExpr { |
578 | pub(crate) syntax: SyntaxNode, | 1119 | pub(crate) syntax: SyntaxNode, |
@@ -581,7 +1122,16 @@ impl ast::ArgListOwner for CallExpr {} | |||
581 | impl CallExpr { | 1122 | impl CallExpr { |
582 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1123 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
583 | } | 1124 | } |
584 | 1125 | /// Method call expression. | |
1126 | /// | ||
1127 | /// ``` | ||
1128 | /// ❰ receiver_expr.method() ❱; | ||
1129 | /// ❰ receiver_expr.method::<T>(42, true) ❱; | ||
1130 | /// | ||
1131 | /// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱; | ||
1132 | /// ``` | ||
1133 | /// | ||
1134 | /// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html) | ||
585 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1135 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
586 | pub struct MethodCallExpr { | 1136 | pub struct MethodCallExpr { |
587 | pub(crate) syntax: SyntaxNode, | 1137 | pub(crate) syntax: SyntaxNode, |
@@ -594,7 +1144,13 @@ impl MethodCallExpr { | |||
594 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 1144 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
595 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | 1145 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } |
596 | } | 1146 | } |
597 | 1147 | /// Index expression a.k.a. subscript operator call. | |
1148 | /// | ||
1149 | /// ``` | ||
1150 | /// ❰ foo[42] ❱; | ||
1151 | /// ``` | ||
1152 | /// | ||
1153 | /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html) | ||
598 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1154 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
599 | pub struct IndexExpr { | 1155 | pub struct IndexExpr { |
600 | pub(crate) syntax: SyntaxNode, | 1156 | pub(crate) syntax: SyntaxNode, |
@@ -604,7 +1160,15 @@ impl IndexExpr { | |||
604 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | 1160 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
605 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 1161 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
606 | } | 1162 | } |
607 | 1163 | /// Field access expression. | |
1164 | /// | ||
1165 | /// ``` | ||
1166 | /// ❰ expr.bar ❱; | ||
1167 | /// | ||
1168 | /// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱; | ||
1169 | /// ``` | ||
1170 | /// | ||
1171 | /// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html) | ||
608 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1172 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
609 | pub struct FieldExpr { | 1173 | pub struct FieldExpr { |
610 | pub(crate) syntax: SyntaxNode, | 1174 | pub(crate) syntax: SyntaxNode, |
@@ -615,7 +1179,13 @@ impl FieldExpr { | |||
615 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } | 1179 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } |
616 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 1180 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
617 | } | 1181 | } |
618 | 1182 | /// Await operator call expression. | |
1183 | /// | ||
1184 | /// ``` | ||
1185 | /// ❰ expr.await ❱; | ||
1186 | /// ``` | ||
1187 | /// | ||
1188 | /// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html) | ||
619 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1189 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
620 | pub struct AwaitExpr { | 1190 | pub struct AwaitExpr { |
621 | pub(crate) syntax: SyntaxNode, | 1191 | pub(crate) syntax: SyntaxNode, |
@@ -626,7 +1196,13 @@ impl AwaitExpr { | |||
626 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } | 1196 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } |
627 | pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) } | 1197 | pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) } |
628 | } | 1198 | } |
629 | 1199 | /// The question mark operator call. | |
1200 | /// | ||
1201 | /// ``` | ||
1202 | /// ❰ expr? ❱; | ||
1203 | /// ``` | ||
1204 | /// | ||
1205 | /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator) | ||
630 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1206 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
631 | pub struct TryExpr { | 1207 | pub struct TryExpr { |
632 | pub(crate) syntax: SyntaxNode, | 1208 | pub(crate) syntax: SyntaxNode, |
@@ -636,7 +1212,13 @@ impl TryExpr { | |||
636 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1212 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
637 | pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) } | 1213 | pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) } |
638 | } | 1214 | } |
639 | 1215 | /// Type cast expression. | |
1216 | /// | ||
1217 | /// ``` | ||
1218 | /// ❰ expr as T ❱; | ||
1219 | /// ``` | ||
1220 | /// | ||
1221 | /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions) | ||
640 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1222 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
641 | pub struct CastExpr { | 1223 | pub struct CastExpr { |
642 | pub(crate) syntax: SyntaxNode, | 1224 | pub(crate) syntax: SyntaxNode, |
@@ -647,7 +1229,14 @@ impl CastExpr { | |||
647 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | 1229 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } |
648 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1230 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
649 | } | 1231 | } |
650 | 1232 | /// Borrow operator call. | |
1233 | /// | ||
1234 | /// ``` | ||
1235 | /// ❰ &foo ❱; | ||
1236 | /// ❰ &mut bar ❱; | ||
1237 | /// ``` | ||
1238 | /// | ||
1239 | /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators) | ||
651 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1240 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
652 | pub struct RefExpr { | 1241 | pub struct RefExpr { |
653 | pub(crate) syntax: SyntaxNode, | 1242 | pub(crate) syntax: SyntaxNode, |
@@ -659,7 +1248,15 @@ impl RefExpr { | |||
659 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 1248 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
660 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1249 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
661 | } | 1250 | } |
662 | 1251 | /// Prefix operator call. This is either `!` or `*` or `-`. | |
1252 | /// | ||
1253 | /// ``` | ||
1254 | /// ❰ !foo ❱; | ||
1255 | /// ❰ *bar ❱; | ||
1256 | /// ❰ -42 ❱; | ||
1257 | /// ``` | ||
1258 | /// | ||
1259 | /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html) | ||
663 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1260 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
664 | pub struct PrefixExpr { | 1261 | pub struct PrefixExpr { |
665 | pub(crate) syntax: SyntaxNode, | 1262 | pub(crate) syntax: SyntaxNode, |
@@ -668,7 +1265,13 @@ impl ast::AttrsOwner for PrefixExpr {} | |||
668 | impl PrefixExpr { | 1265 | impl PrefixExpr { |
669 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1266 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
670 | } | 1267 | } |
671 | 1268 | /// Box operator call. | |
1269 | /// | ||
1270 | /// ``` | ||
1271 | /// ❰ box 42 ❱; | ||
1272 | /// ``` | ||
1273 | /// | ||
1274 | /// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md) | ||
672 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1275 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
673 | pub struct BoxExpr { | 1276 | pub struct BoxExpr { |
674 | pub(crate) syntax: SyntaxNode, | 1277 | pub(crate) syntax: SyntaxNode, |
@@ -678,27 +1281,69 @@ impl BoxExpr { | |||
678 | pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } | 1281 | pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } |
679 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1282 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
680 | } | 1283 | } |
681 | 1284 | /// Range operator call. | |
1285 | /// | ||
1286 | /// ``` | ||
1287 | /// ❰ 0..42 ❱; | ||
1288 | /// ❰ ..42 ❱; | ||
1289 | /// ❰ 0.. ❱; | ||
1290 | /// ❰ .. ❱; | ||
1291 | /// ❰ 0..=42 ❱; | ||
1292 | /// ❰ ..=42 ❱; | ||
1293 | /// ``` | ||
1294 | /// | ||
1295 | /// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html) | ||
682 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1296 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
683 | pub struct RangeExpr { | 1297 | pub struct RangeExpr { |
684 | pub(crate) syntax: SyntaxNode, | 1298 | pub(crate) syntax: SyntaxNode, |
685 | } | 1299 | } |
686 | impl ast::AttrsOwner for RangeExpr {} | 1300 | impl ast::AttrsOwner for RangeExpr {} |
687 | impl RangeExpr {} | 1301 | impl RangeExpr {} |
688 | 1302 | /// Binary operator call. | |
1303 | /// Includes all arithmetic, logic, bitwise and assignment operators. | ||
1304 | /// | ||
1305 | /// ``` | ||
1306 | /// ❰ 2 + ❰ 2 * 2 ❱ ❱; | ||
1307 | /// ❰ ❰ true && false ❱ || true ❱; | ||
1308 | /// ``` | ||
1309 | /// | ||
1310 | /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators) | ||
689 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1311 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
690 | pub struct BinExpr { | 1312 | pub struct BinExpr { |
691 | pub(crate) syntax: SyntaxNode, | 1313 | pub(crate) syntax: SyntaxNode, |
692 | } | 1314 | } |
693 | impl ast::AttrsOwner for BinExpr {} | 1315 | impl ast::AttrsOwner for BinExpr {} |
694 | impl BinExpr {} | 1316 | impl BinExpr {} |
695 | 1317 | /// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal. | |
1318 | /// | ||
1319 | /// ``` | ||
1320 | /// ❰ "str" ❱; | ||
1321 | /// ❰ br##"raw byte str"## ❱; | ||
1322 | /// ❰ 'c' ❱; | ||
1323 | /// ❰ b'c' ❱; | ||
1324 | /// ❰ 42 ❱; | ||
1325 | /// ❰ 1e9 ❱; | ||
1326 | /// ❰ true ❱; | ||
1327 | /// ``` | ||
1328 | /// | ||
1329 | /// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html) | ||
696 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1330 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
697 | pub struct Literal { | 1331 | pub struct Literal { |
698 | pub(crate) syntax: SyntaxNode, | 1332 | pub(crate) syntax: SyntaxNode, |
699 | } | 1333 | } |
700 | impl Literal {} | 1334 | impl Literal {} |
701 | 1335 | /// Match expression. | |
1336 | /// | ||
1337 | /// ``` | ||
1338 | /// ❰ | ||
1339 | /// match expr { | ||
1340 | /// Pat1 => {} | ||
1341 | /// Pat2(_) => 42, | ||
1342 | /// } | ||
1343 | /// ❱ | ||
1344 | /// ``` | ||
1345 | /// | ||
1346 | /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html) | ||
702 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1347 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
703 | pub struct MatchExpr { | 1348 | pub struct MatchExpr { |
704 | pub(crate) syntax: SyntaxNode, | 1349 | pub(crate) syntax: SyntaxNode, |
@@ -709,7 +1354,20 @@ impl MatchExpr { | |||
709 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1354 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
710 | pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } | 1355 | pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } |
711 | } | 1356 | } |
712 | 1357 | /// Match arm list part of match expression. Includes its inner attributes. | |
1358 | /// | ||
1359 | /// ``` | ||
1360 | /// match expr | ||
1361 | /// ❰ | ||
1362 | /// { | ||
1363 | /// #![inner_attr] | ||
1364 | /// Pat1 => {} | ||
1365 | /// Pat2(_) => 42, | ||
1366 | /// } | ||
1367 | /// ❱ | ||
1368 | /// ``` | ||
1369 | /// | ||
1370 | /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html) | ||
713 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
714 | pub struct MatchArmList { | 1372 | pub struct MatchArmList { |
715 | pub(crate) syntax: SyntaxNode, | 1373 | pub(crate) syntax: SyntaxNode, |
@@ -720,7 +1378,16 @@ impl MatchArmList { | |||
720 | pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } | 1378 | pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } |
721 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 1379 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
722 | } | 1380 | } |
723 | 1381 | /// Match arm. | |
1382 | /// Note: record struct literals are not valid as target match expression | ||
1383 | /// due to ambiguity. | ||
1384 | /// ``` | ||
1385 | /// match expr { | ||
1386 | /// ❰ #[attr] Pattern(it) if bool_cond => it ❱, | ||
1387 | /// } | ||
1388 | /// ``` | ||
1389 | /// | ||
1390 | /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html) | ||
724 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1391 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
725 | pub struct MatchArm { | 1392 | pub struct MatchArm { |
726 | pub(crate) syntax: SyntaxNode, | 1393 | pub(crate) syntax: SyntaxNode, |
@@ -732,7 +1399,15 @@ impl MatchArm { | |||
732 | pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) } | 1399 | pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) } |
733 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1400 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
734 | } | 1401 | } |
735 | 1402 | /// Match guard. | |
1403 | /// | ||
1404 | /// ``` | ||
1405 | /// match expr { | ||
1406 | /// Pattern(it) ❰ if bool_cond ❱ => it, | ||
1407 | /// } | ||
1408 | /// ``` | ||
1409 | /// | ||
1410 | /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards) | ||
736 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1411 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
737 | pub struct MatchGuard { | 1412 | pub struct MatchGuard { |
738 | pub(crate) syntax: SyntaxNode, | 1413 | pub(crate) syntax: SyntaxNode, |
@@ -741,7 +1416,21 @@ impl MatchGuard { | |||
741 | pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } | 1416 | pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } |
742 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1417 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
743 | } | 1418 | } |
744 | 1419 | /// Record literal expression. The same syntax is used for structs, | |
1420 | /// unions and record enum variants. | ||
1421 | /// | ||
1422 | /// ``` | ||
1423 | /// ❰ | ||
1424 | /// foo::Bar { | ||
1425 | /// #![inner_attr] | ||
1426 | /// baz: 42, | ||
1427 | /// bruh: true, | ||
1428 | /// ..spread | ||
1429 | /// } | ||
1430 | /// ❱ | ||
1431 | /// ``` | ||
1432 | /// | ||
1433 | /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html) | ||
745 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1434 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
746 | pub struct RecordLit { | 1435 | pub struct RecordLit { |
747 | pub(crate) syntax: SyntaxNode, | 1436 | pub(crate) syntax: SyntaxNode, |
@@ -750,7 +1439,16 @@ impl RecordLit { | |||
750 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 1439 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
751 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } | 1440 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } |
752 | } | 1441 | } |
753 | 1442 | /// Record field list including enclosing curly braces. | |
1443 | /// | ||
1444 | /// foo::Bar ❰ | ||
1445 | /// { | ||
1446 | /// baz: 42, | ||
1447 | /// ..spread | ||
1448 | /// } | ||
1449 | /// ❱ | ||
1450 | /// | ||
1451 | /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html) | ||
754 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1452 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
755 | pub struct RecordFieldList { | 1453 | pub struct RecordFieldList { |
756 | pub(crate) syntax: SyntaxNode, | 1454 | pub(crate) syntax: SyntaxNode, |
@@ -762,7 +1460,15 @@ impl RecordFieldList { | |||
762 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } | 1460 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } |
763 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 1461 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
764 | } | 1462 | } |
765 | 1463 | /// Record field. | |
1464 | /// | ||
1465 | /// ``` | ||
1466 | /// foo::Bar { | ||
1467 | /// ❰ #[attr] baz: 42 ❱ | ||
1468 | /// } | ||
1469 | /// ``` | ||
1470 | /// | ||
1471 | /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html) | ||
766 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1472 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
767 | pub struct RecordField { | 1473 | pub struct RecordField { |
768 | pub(crate) syntax: SyntaxNode, | 1474 | pub(crate) syntax: SyntaxNode, |
@@ -773,7 +1479,13 @@ impl RecordField { | |||
773 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 1479 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
774 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1480 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
775 | } | 1481 | } |
776 | 1482 | /// Disjunction of patterns. | |
1483 | /// | ||
1484 | /// ``` | ||
1485 | /// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh; | ||
1486 | /// ``` | ||
1487 | /// | ||
1488 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html) | ||
777 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1489 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
778 | pub struct OrPat { | 1490 | pub struct OrPat { |
779 | pub(crate) syntax: SyntaxNode, | 1491 | pub(crate) syntax: SyntaxNode, |
@@ -781,7 +1493,14 @@ pub struct OrPat { | |||
781 | impl OrPat { | 1493 | impl OrPat { |
782 | pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | 1494 | pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } |
783 | } | 1495 | } |
784 | 1496 | /// Parenthesized pattern. | |
1497 | /// Note: parens are only used for grouping, this is not a tuple pattern. | ||
1498 | /// | ||
1499 | /// ``` | ||
1500 | /// if let ❰ &(0..=42) ❱ = foo {} | ||
1501 | /// ``` | ||
1502 | /// | ||
1503 | /// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns | ||
785 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1504 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
786 | pub struct ParenPat { | 1505 | pub struct ParenPat { |
787 | pub(crate) syntax: SyntaxNode, | 1506 | pub(crate) syntax: SyntaxNode, |
@@ -791,7 +1510,16 @@ impl ParenPat { | |||
791 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1510 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
792 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 1511 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
793 | } | 1512 | } |
794 | 1513 | /// Reference pattern. | |
1514 | /// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns. | ||
1515 | /// | ||
1516 | /// ``` | ||
1517 | /// let ❰ &mut foo ❱ = bar; | ||
1518 | /// ``` | ||
1519 | /// // TODO: clarify on the special case of double reference pattern | ||
1520 | /// // described in the link bellow | ||
1521 | /// | ||
1522 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns) | ||
795 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1523 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
796 | pub struct RefPat { | 1524 | pub struct RefPat { |
797 | pub(crate) syntax: SyntaxNode, | 1525 | pub(crate) syntax: SyntaxNode, |
@@ -801,7 +1529,13 @@ impl RefPat { | |||
801 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 1529 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
802 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1530 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
803 | } | 1531 | } |
804 | 1532 | /// Box pattern. | |
1533 | /// | ||
1534 | /// ``` | ||
1535 | /// let ❰ box foo ❱ = box 42; | ||
1536 | /// ``` | ||
1537 | /// | ||
1538 | /// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html) | ||
805 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1539 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
806 | pub struct BoxPat { | 1540 | pub struct BoxPat { |
807 | pub(crate) syntax: SyntaxNode, | 1541 | pub(crate) syntax: SyntaxNode, |
@@ -810,7 +1544,16 @@ impl BoxPat { | |||
810 | pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } | 1544 | pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } |
811 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1545 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
812 | } | 1546 | } |
813 | 1547 | /// Bind pattern. | |
1548 | /// | ||
1549 | /// ``` | ||
1550 | /// match foo { | ||
1551 | /// Some(❰ ref mut bar ❱) => {} | ||
1552 | /// ❰ baz @ None ❱ => {} | ||
1553 | /// } | ||
1554 | /// ``` | ||
1555 | /// | ||
1556 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns) | ||
814 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1557 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
815 | pub struct BindPat { | 1558 | pub struct BindPat { |
816 | pub(crate) syntax: SyntaxNode, | 1559 | pub(crate) syntax: SyntaxNode, |
@@ -823,7 +1566,13 @@ impl BindPat { | |||
823 | pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } | 1566 | pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } |
824 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1567 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
825 | } | 1568 | } |
826 | 1569 | /// Placeholder pattern a.k.a. the wildcard pattern or the underscore. | |
1570 | /// | ||
1571 | /// ``` | ||
1572 | /// let ❰ _ ❱ = foo; | ||
1573 | /// ``` | ||
1574 | /// | ||
1575 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern) | ||
827 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1576 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
828 | pub struct PlaceholderPat { | 1577 | pub struct PlaceholderPat { |
829 | pub(crate) syntax: SyntaxNode, | 1578 | pub(crate) syntax: SyntaxNode, |
@@ -831,7 +1580,16 @@ pub struct PlaceholderPat { | |||
831 | impl PlaceholderPat { | 1580 | impl PlaceholderPat { |
832 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } | 1581 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } |
833 | } | 1582 | } |
834 | 1583 | /// Rest-of-the record/tuple pattern. | |
1584 | /// Note: this is not the unbonded range pattern (even more: it doesn't exist). | ||
1585 | /// | ||
1586 | /// ``` | ||
1587 | /// let Foo { bar, ❰ .. ❱ } = baz; | ||
1588 | /// let (❰ .. ❱, bruh) = (42, 24, 42); | ||
1589 | /// let Bruuh(❰ .. ❱) = bruuuh; | ||
1590 | /// ``` | ||
1591 | /// | ||
1592 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns) | ||
835 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1593 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
836 | pub struct DotDotPat { | 1594 | pub struct DotDotPat { |
837 | pub(crate) syntax: SyntaxNode, | 1595 | pub(crate) syntax: SyntaxNode, |
@@ -839,7 +1597,15 @@ pub struct DotDotPat { | |||
839 | impl DotDotPat { | 1597 | impl DotDotPat { |
840 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } | 1598 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } |
841 | } | 1599 | } |
842 | 1600 | /// Path pattern. | |
1601 | /// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`). | ||
1602 | /// | ||
1603 | /// ``` | ||
1604 | /// let ❰ foo::bar::Baz ❱ { .. } = bruh; | ||
1605 | /// if let ❰ CONST ❱ = 42 {} | ||
1606 | /// ``` | ||
1607 | /// | ||
1608 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns) | ||
843 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1609 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
844 | pub struct PathPat { | 1610 | pub struct PathPat { |
845 | pub(crate) syntax: SyntaxNode, | 1611 | pub(crate) syntax: SyntaxNode, |
@@ -847,7 +1613,13 @@ pub struct PathPat { | |||
847 | impl PathPat { | 1613 | impl PathPat { |
848 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 1614 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
849 | } | 1615 | } |
850 | 1616 | /// Slice pattern. | |
1617 | /// | ||
1618 | /// ``` | ||
1619 | /// let ❰ [foo, bar, baz] ❱ = [1, 2, 3]; | ||
1620 | /// ``` | ||
1621 | /// | ||
1622 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns) | ||
851 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1623 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
852 | pub struct SlicePat { | 1624 | pub struct SlicePat { |
853 | pub(crate) syntax: SyntaxNode, | 1625 | pub(crate) syntax: SyntaxNode, |
@@ -857,13 +1629,33 @@ impl SlicePat { | |||
857 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | 1629 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } |
858 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 1630 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
859 | } | 1631 | } |
860 | 1632 | /// Range pattern. | |
1633 | /// | ||
1634 | /// ``` | ||
1635 | /// match foo { | ||
1636 | /// ❰ 0..42 ❱ => {} | ||
1637 | /// ❰ 0..=42 ❱ => {} | ||
1638 | /// } | ||
1639 | /// ``` | ||
1640 | /// | ||
1641 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns) | ||
861 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1642 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
862 | pub struct RangePat { | 1643 | pub struct RangePat { |
863 | pub(crate) syntax: SyntaxNode, | 1644 | pub(crate) syntax: SyntaxNode, |
864 | } | 1645 | } |
865 | impl RangePat {} | 1646 | impl RangePat {} |
866 | 1647 | /// Literal pattern. | |
1648 | /// Includes only bool, number, char, and string literals. | ||
1649 | /// | ||
1650 | /// ``` | ||
1651 | /// match foo { | ||
1652 | /// Number(❰ 42 ❱) => {} | ||
1653 | /// String(❰ "42" ❱) => {} | ||
1654 | /// Bool(❰ true ❱) => {} | ||
1655 | /// } | ||
1656 | /// ``` | ||
1657 | /// | ||
1658 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns) | ||
867 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1659 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
868 | pub struct LiteralPat { | 1660 | pub struct LiteralPat { |
869 | pub(crate) syntax: SyntaxNode, | 1661 | pub(crate) syntax: SyntaxNode, |
@@ -871,7 +1663,13 @@ pub struct LiteralPat { | |||
871 | impl LiteralPat { | 1663 | impl LiteralPat { |
872 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | 1664 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } |
873 | } | 1665 | } |
874 | 1666 | /// Macro invocation in pattern position. | |
1667 | /// | ||
1668 | /// ``` | ||
1669 | /// let ❰ foo!(my custom syntax) ❱ = baz; | ||
1670 | /// | ||
1671 | /// ``` | ||
1672 | /// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation) | ||
875 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1673 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
876 | pub struct MacroPat { | 1674 | pub struct MacroPat { |
877 | pub(crate) syntax: SyntaxNode, | 1675 | pub(crate) syntax: SyntaxNode, |
@@ -879,7 +1677,13 @@ pub struct MacroPat { | |||
879 | impl MacroPat { | 1677 | impl MacroPat { |
880 | pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } | 1678 | pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } |
881 | } | 1679 | } |
882 | 1680 | /// Record literal pattern. | |
1681 | /// | ||
1682 | /// ``` | ||
1683 | /// let ❰ foo::Bar { baz, .. } ❱ = bruh; | ||
1684 | /// ``` | ||
1685 | /// | ||
1686 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns) | ||
883 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1687 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
884 | pub struct RecordPat { | 1688 | pub struct RecordPat { |
885 | pub(crate) syntax: SyntaxNode, | 1689 | pub(crate) syntax: SyntaxNode, |
@@ -890,7 +1694,13 @@ impl RecordPat { | |||
890 | } | 1694 | } |
891 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 1695 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
892 | } | 1696 | } |
893 | 1697 | /// Record literal's field patterns list including enclosing curly braces. | |
1698 | /// | ||
1699 | /// ``` | ||
1700 | /// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh; | ||
1701 | /// `` | ||
1702 | /// | ||
1703 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns) | ||
894 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1704 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
895 | pub struct RecordFieldPatList { | 1705 | pub struct RecordFieldPatList { |
896 | pub(crate) syntax: SyntaxNode, | 1706 | pub(crate) syntax: SyntaxNode, |
@@ -905,7 +1715,15 @@ impl RecordFieldPatList { | |||
905 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } | 1715 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } |
906 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 1716 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
907 | } | 1717 | } |
908 | 1718 | /// Record literal's field pattern. | |
1719 | /// Note: record literal can also match tuple structs. | ||
1720 | /// | ||
1721 | /// ``` | ||
1722 | /// let Foo { ❰ bar: _ ❱ } = baz; | ||
1723 | /// let TupleStruct { ❰ 0: _ ❱ } = bruh; | ||
1724 | /// ``` | ||
1725 | /// | ||
1726 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns) | ||
909 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1727 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
910 | pub struct RecordFieldPat { | 1728 | pub struct RecordFieldPat { |
911 | pub(crate) syntax: SyntaxNode, | 1729 | pub(crate) syntax: SyntaxNode, |
@@ -916,7 +1734,13 @@ impl RecordFieldPat { | |||
916 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 1734 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
917 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1735 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
918 | } | 1736 | } |
919 | 1737 | /// Tuple struct literal pattern. | |
1738 | /// | ||
1739 | /// ``` | ||
1740 | /// let ❰ foo::Bar(baz, bruh) ❱ = bruuh; | ||
1741 | /// ``` | ||
1742 | /// | ||
1743 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns) | ||
920 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1744 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
921 | pub struct TupleStructPat { | 1745 | pub struct TupleStructPat { |
922 | pub(crate) syntax: SyntaxNode, | 1746 | pub(crate) syntax: SyntaxNode, |
@@ -927,7 +1751,14 @@ impl TupleStructPat { | |||
927 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | 1751 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } |
928 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 1752 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
929 | } | 1753 | } |
930 | 1754 | /// Tuple pattern. | |
1755 | /// Note: this doesn't include tuple structs (see `TupleStructPat`) | ||
1756 | /// | ||
1757 | /// ``` | ||
1758 | /// let ❰ (foo, bar, .., baz) ❱ = bruh; | ||
1759 | /// ``` | ||
1760 | /// | ||
1761 | /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns) | ||
931 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1762 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
932 | pub struct TuplePat { | 1763 | pub struct TuplePat { |
933 | pub(crate) syntax: SyntaxNode, | 1764 | pub(crate) syntax: SyntaxNode, |
@@ -937,7 +1768,17 @@ impl TuplePat { | |||
937 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | 1768 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } |
938 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 1769 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
939 | } | 1770 | } |
940 | 1771 | /// Visibility. | |
1772 | /// | ||
1773 | /// ``` | ||
1774 | /// ❰ pub mod ❱ foo; | ||
1775 | /// ❰ pub(crate) ❱ struct Bar; | ||
1776 | /// ❰ pub(self) ❱ enum Baz {} | ||
1777 | /// ❰ pub(super) ❱ fn bruh() {} | ||
1778 | /// ❰ pub(in bruuh::bruuuh) ❱ type T = u64; | ||
1779 | /// ``` | ||
1780 | /// | ||
1781 | /// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html) | ||
941 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1782 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
942 | pub struct Visibility { | 1783 | pub struct Visibility { |
943 | pub(crate) syntax: SyntaxNode, | 1784 | pub(crate) syntax: SyntaxNode, |
@@ -948,7 +1789,16 @@ impl Visibility { | |||
948 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | 1789 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } |
949 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | 1790 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } |
950 | } | 1791 | } |
951 | 1792 | /// Single identifier. | |
1793 | /// // TODO: clarify the difference between Name and NameRef | ||
1794 | /// | ||
1795 | /// ``` | ||
1796 | /// let ❰ foo ❱ = bar; | ||
1797 | /// struct ❰ Baz ❱; | ||
1798 | /// fn ❰ bruh ❱() {} | ||
1799 | /// ``` | ||
1800 | /// | ||
1801 | /// [Reference](https://doc.rust-lang.org/reference/identifiers.html) | ||
952 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1802 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
953 | pub struct Name { | 1803 | pub struct Name { |
954 | pub(crate) syntax: SyntaxNode, | 1804 | pub(crate) syntax: SyntaxNode, |
@@ -956,13 +1806,34 @@ pub struct Name { | |||
956 | impl Name { | 1806 | impl Name { |
957 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | 1807 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } |
958 | } | 1808 | } |
959 | 1809 | /// Reference to a name. | |
1810 | /// | ||
1811 | /// ``` | ||
1812 | /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱; | ||
1813 | /// ``` | ||
1814 | /// | ||
1815 | /// [Reference](https://doc.rust-lang.org/reference/identifiers.html) | ||
960 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1816 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
961 | pub struct NameRef { | 1817 | pub struct NameRef { |
962 | pub(crate) syntax: SyntaxNode, | 1818 | pub(crate) syntax: SyntaxNode, |
963 | } | 1819 | } |
964 | impl NameRef {} | 1820 | impl NameRef {} |
965 | 1821 | /// Macro call. | |
1822 | /// Includes all of its attributes and doc comments. | ||
1823 | /// | ||
1824 | /// ``` | ||
1825 | /// ❰ | ||
1826 | /// /// Docs | ||
1827 | /// #[attr] | ||
1828 | /// macro_rules! foo { // macro rules is also a macro call | ||
1829 | /// ($bar: tt) => {} | ||
1830 | /// } | ||
1831 | /// ❱ | ||
1832 | /// | ||
1833 | /// ❰ foo!() ❱ | ||
1834 | /// ``` | ||
1835 | /// | ||
1836 | /// [Reference](https://doc.rust-lang.org/reference/macros.html) | ||
966 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1837 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
967 | pub struct MacroCall { | 1838 | pub struct MacroCall { |
968 | pub(crate) syntax: SyntaxNode, | 1839 | pub(crate) syntax: SyntaxNode, |
@@ -976,7 +1847,18 @@ impl MacroCall { | |||
976 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | 1847 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } |
977 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 1848 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
978 | } | 1849 | } |
979 | 1850 | /// Attribute. | |
1851 | /// | ||
1852 | /// ``` | ||
1853 | /// ❰ #![inner_attr] ❱ | ||
1854 | /// | ||
1855 | /// ❰ #[attr] ❱ | ||
1856 | /// ❰ #[foo = "bar"] ❱ | ||
1857 | /// ❰ #[baz(bruh::bruuh = "42")] ❱ | ||
1858 | /// struct Foo; | ||
1859 | /// ``` | ||
1860 | /// | ||
1861 | /// [Reference](https://doc.rust-lang.org/reference/attributes.html) | ||
980 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1862 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
981 | pub struct Attr { | 1863 | pub struct Attr { |
982 | pub(crate) syntax: SyntaxNode, | 1864 | pub(crate) syntax: SyntaxNode, |
@@ -990,13 +1872,31 @@ impl Attr { | |||
990 | pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } | 1872 | pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } |
991 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 1873 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
992 | } | 1874 | } |
993 | 1875 | /// // TODO: clarify on this AST type @edwin0cheng | |
1876 | /// | ||
1877 | /// ``` | ||
1878 | /// macro_call! ❰ { my syntax here } ❱; | ||
1879 | /// ``` | ||
1880 | /// | ||
1881 | /// [Reference](https://doc.rust-lang.org/reference/macros.html) | ||
994 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1882 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
995 | pub struct TokenTree { | 1883 | pub struct TokenTree { |
996 | pub(crate) syntax: SyntaxNode, | 1884 | pub(crate) syntax: SyntaxNode, |
997 | } | 1885 | } |
998 | impl TokenTree {} | 1886 | impl TokenTree {} |
999 | 1887 | /// Generic lifetime, type and constants parameters list **declaration**. | |
1888 | /// | ||
1889 | /// ``` | ||
1890 | /// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {} | ||
1891 | /// | ||
1892 | /// struct Baz❰ <T> ❱(T); | ||
1893 | /// | ||
1894 | /// impl❰ <T> ❱ Bruh<T> {} | ||
1895 | /// | ||
1896 | /// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str; | ||
1897 | /// ``` | ||
1898 | /// | ||
1899 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html) | ||
1000 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1900 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1001 | pub struct TypeParamList { | 1901 | pub struct TypeParamList { |
1002 | pub(crate) syntax: SyntaxNode, | 1902 | pub(crate) syntax: SyntaxNode, |
@@ -1009,7 +1909,13 @@ impl TypeParamList { | |||
1009 | pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) } | 1909 | pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) } |
1010 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | 1910 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } |
1011 | } | 1911 | } |
1012 | 1912 | /// Single type parameter **declaration**. | |
1913 | /// | ||
1914 | /// ``` | ||
1915 | /// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {} | ||
1916 | /// ``` | ||
1917 | /// | ||
1918 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html) | ||
1013 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1919 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1014 | pub struct TypeParam { | 1920 | pub struct TypeParam { |
1015 | pub(crate) syntax: SyntaxNode, | 1921 | pub(crate) syntax: SyntaxNode, |
@@ -1021,7 +1927,12 @@ impl TypeParam { | |||
1021 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 1927 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1022 | pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1928 | pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1023 | } | 1929 | } |
1024 | 1930 | /// Const generic parameter **declaration**. | |
1931 | /// ``` | ||
1932 | /// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {} | ||
1933 | /// ``` | ||
1934 | /// | ||
1935 | /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter) | ||
1025 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1936 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1026 | pub struct ConstParam { | 1937 | pub struct ConstParam { |
1027 | pub(crate) syntax: SyntaxNode, | 1938 | pub(crate) syntax: SyntaxNode, |
@@ -1033,7 +1944,13 @@ impl ConstParam { | |||
1033 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 1944 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1034 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } | 1945 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } |
1035 | } | 1946 | } |
1036 | 1947 | /// Lifetime parameter **declaration**. | |
1948 | /// | ||
1949 | /// ``` | ||
1950 | /// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {} | ||
1951 | /// ``` | ||
1952 | /// | ||
1953 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html) | ||
1037 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1954 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1038 | pub struct LifetimeParam { | 1955 | pub struct LifetimeParam { |
1039 | pub(crate) syntax: SyntaxNode, | 1956 | pub(crate) syntax: SyntaxNode, |
@@ -1044,7 +1961,20 @@ impl LifetimeParam { | |||
1044 | support::token(&self.syntax, T![lifetime]) | 1961 | support::token(&self.syntax, T![lifetime]) |
1045 | } | 1962 | } |
1046 | } | 1963 | } |
1047 | 1964 | /// Type bound declaration clause. | |
1965 | /// | ||
1966 | /// ``` | ||
1967 | /// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {} | ||
1968 | /// | ||
1969 | /// trait Bar<T> | ||
1970 | /// where | ||
1971 | /// T: ❰ Send ❱ + ❰ Sync ❱ | ||
1972 | /// { | ||
1973 | /// type Baz: ❰ !Sync ❱ + ❰ Debug ❱; | ||
1974 | /// } | ||
1975 | /// ``` | ||
1976 | /// | ||
1977 | /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html) | ||
1048 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1978 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1049 | pub struct TypeBound { | 1979 | pub struct TypeBound { |
1050 | pub(crate) syntax: SyntaxNode, | 1980 | pub(crate) syntax: SyntaxNode, |
@@ -1056,7 +1986,21 @@ impl TypeBound { | |||
1056 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 1986 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
1057 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1987 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1058 | } | 1988 | } |
1059 | 1989 | /// Type bounds list. | |
1990 | /// | ||
1991 | /// ``` | ||
1992 | /// | ||
1993 | /// fn foo<T: ❰ ?Sized + Debug ❱>() {} | ||
1994 | /// | ||
1995 | /// trait Bar<T> | ||
1996 | /// where | ||
1997 | /// T: ❰ Send + Sync ❱ | ||
1998 | /// { | ||
1999 | /// type Baz: ❰ !Sync + Debug ❱; | ||
2000 | /// } | ||
2001 | /// ``` | ||
2002 | /// | ||
2003 | /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html) | ||
1060 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2004 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1061 | pub struct TypeBoundList { | 2005 | pub struct TypeBoundList { |
1062 | pub(crate) syntax: SyntaxNode, | 2006 | pub(crate) syntax: SyntaxNode, |
@@ -1064,7 +2008,18 @@ pub struct TypeBoundList { | |||
1064 | impl TypeBoundList { | 2008 | impl TypeBoundList { |
1065 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | 2009 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } |
1066 | } | 2010 | } |
1067 | 2011 | /// Single where predicate. | |
2012 | /// | ||
2013 | /// ``` | ||
2014 | /// trait Foo<'a, 'b, T> | ||
2015 | /// where | ||
2016 | /// ❰ 'a: 'b ❱, | ||
2017 | /// ❰ T: IntoIterator ❱, | ||
2018 | /// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱ | ||
2019 | /// {} | ||
2020 | /// ``` | ||
2021 | /// | ||
2022 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) | ||
1068 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2023 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1069 | pub struct WherePred { | 2024 | pub struct WherePred { |
1070 | pub(crate) syntax: SyntaxNode, | 2025 | pub(crate) syntax: SyntaxNode, |
@@ -1076,7 +2031,14 @@ impl WherePred { | |||
1076 | } | 2031 | } |
1077 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 2032 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1078 | } | 2033 | } |
1079 | 2034 | /// Where clause. | |
2035 | /// | ||
2036 | /// ``` | ||
2037 | /// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {} | ||
2038 | /// | ||
2039 | /// ``` | ||
2040 | /// | ||
2041 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) | ||
1080 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2042 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1081 | pub struct WhereClause { | 2043 | pub struct WhereClause { |
1082 | pub(crate) syntax: SyntaxNode, | 2044 | pub(crate) syntax: SyntaxNode, |
@@ -1085,13 +2047,42 @@ impl WhereClause { | |||
1085 | pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) } | 2047 | pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) } |
1086 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } | 2048 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } |
1087 | } | 2049 | } |
1088 | 2050 | /// Abi declaration. | |
2051 | /// Note: the abi string is optional. | ||
2052 | /// | ||
2053 | /// ``` | ||
2054 | /// ❰ extern "C" ❱ { | ||
2055 | /// fn foo() {} | ||
2056 | /// } | ||
2057 | /// | ||
2058 | /// type Bar = ❰ extern ❱ fn() -> u32; | ||
2059 | /// | ||
2060 | /// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool; | ||
2061 | /// ``` | ||
2062 | /// | ||
2063 | /// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html) | ||
2064 | /// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions) | ||
1089 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2065 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1090 | pub struct Abi { | 2066 | pub struct Abi { |
1091 | pub(crate) syntax: SyntaxNode, | 2067 | pub(crate) syntax: SyntaxNode, |
1092 | } | 2068 | } |
1093 | impl Abi {} | 2069 | impl Abi {} |
1094 | 2070 | /// Expression statement. | |
2071 | /// Note: may be empty (i.e. only semicolon). | ||
2072 | /// | ||
2073 | /// ``` | ||
2074 | /// ❰ 42; ❱ | ||
2075 | /// ❰ foo(); ❱ | ||
2076 | /// ❰ (); ❱ | ||
2077 | /// ❰ {}; ❱ | ||
2078 | /// ❰ /* empty */; ❱ | ||
2079 | /// | ||
2080 | /// // constructions with trailing curly brace can omit the semicolon // TODO: clarify | ||
2081 | /// ❰ if bool_cond { } ❱ | ||
2082 | /// ❰ loop {} ❱ | ||
2083 | /// ``` | ||
2084 | /// | ||
2085 | /// [Reference](https://doc.rust-lang.org/reference/statements.html) | ||
1095 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2086 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1096 | pub struct ExprStmt { | 2087 | pub struct ExprStmt { |
1097 | pub(crate) syntax: SyntaxNode, | 2088 | pub(crate) syntax: SyntaxNode, |
@@ -1101,7 +2092,16 @@ impl ExprStmt { | |||
1101 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 2092 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1102 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 2093 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
1103 | } | 2094 | } |
1104 | 2095 | /// Let statement. | |
2096 | /// | ||
2097 | /// ``` | ||
2098 | /// ❰ #[attr] let foo; ❱ | ||
2099 | /// ❰ let bar: u64; ❱ | ||
2100 | /// ❰ let baz = 42; ❱ | ||
2101 | /// ❰ let bruh: bool = true; ❱ | ||
2102 | /// ``` | ||
2103 | /// | ||
2104 | /// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements) | ||
1105 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2105 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1106 | pub struct LetStmt { | 2106 | pub struct LetStmt { |
1107 | pub(crate) syntax: SyntaxNode, | 2107 | pub(crate) syntax: SyntaxNode, |
@@ -1115,7 +2115,18 @@ impl LetStmt { | |||
1115 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } | 2115 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } |
1116 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 2116 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
1117 | } | 2117 | } |
1118 | 2118 | /// Condition of `if` or `while` expression. | |
2119 | /// | ||
2120 | /// ``` | ||
2121 | /// if ❰ true ❱ {} | ||
2122 | /// if ❰ let Pat(foo) = bar ❱ {} | ||
2123 | /// | ||
2124 | /// while ❰ true ❱ {} | ||
2125 | /// while ❰ let Pat(baz) = bruh ❱ {} | ||
2126 | /// ``` | ||
2127 | /// | ||
2128 | /// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html) | ||
2129 | /// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops) | ||
1119 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2130 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1120 | pub struct Condition { | 2131 | pub struct Condition { |
1121 | pub(crate) syntax: SyntaxNode, | 2132 | pub(crate) syntax: SyntaxNode, |
@@ -1126,7 +2137,18 @@ impl Condition { | |||
1126 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 2137 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1127 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 2138 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1128 | } | 2139 | } |
1129 | 2140 | /// Parameter list **declaration**. | |
2141 | /// | ||
2142 | /// ``` | ||
2143 | /// fn foo❰ (a: u32, b: bool) ❱ -> u32 {} | ||
2144 | /// let bar = ❰ |a, b| ❱ {}; | ||
2145 | /// | ||
2146 | /// impl Baz { | ||
2147 | /// fn bruh❰ (&self, a: u32) ❱ {} | ||
2148 | /// } | ||
2149 | /// ``` | ||
2150 | /// | ||
2151 | /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script | ||
1130 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2152 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1131 | pub struct ParamList { | 2153 | pub struct ParamList { |
1132 | pub(crate) syntax: SyntaxNode, | 2154 | pub(crate) syntax: SyntaxNode, |
@@ -1137,7 +2159,19 @@ impl ParamList { | |||
1137 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | 2159 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } |
1138 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 2160 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
1139 | } | 2161 | } |
1140 | 2162 | /// Self parameter **declaration**. | |
2163 | /// | ||
2164 | /// ``` | ||
2165 | /// impl Bruh { | ||
2166 | /// fn foo(❰ self ❱) {} | ||
2167 | /// fn bar(❰ &self ❱) {} | ||
2168 | /// fn baz(❰ &mut self ❱) {} | ||
2169 | /// fn blah<'a>(❰ &'a self ❱) {} | ||
2170 | /// fn blin(❰ self: Box<Self> ❱) {} | ||
2171 | /// } | ||
2172 | /// ``` | ||
2173 | /// | ||
2174 | /// [Reference](https://doc.rust-lang.org/reference/items/functions.html) | ||
1141 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2175 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1142 | pub struct SelfParam { | 2176 | pub struct SelfParam { |
1143 | pub(crate) syntax: SyntaxNode, | 2177 | pub(crate) syntax: SyntaxNode, |
@@ -1152,7 +2186,17 @@ impl SelfParam { | |||
1152 | } | 2186 | } |
1153 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | 2187 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } |
1154 | } | 2188 | } |
1155 | 2189 | /// Parameter **declaration**. | |
2190 | /// | ||
2191 | /// ``` | ||
2192 | /// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {} | ||
2193 | /// | ||
2194 | /// extern "C" { | ||
2195 | /// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32; | ||
2196 | /// } | ||
2197 | /// ``` | ||
2198 | /// | ||
2199 | /// [Reference](https://doc.rust-lang.org/reference/items/functions.html) | ||
1156 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2200 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1157 | pub struct Param { | 2201 | pub struct Param { |
1158 | pub(crate) syntax: SyntaxNode, | 2202 | pub(crate) syntax: SyntaxNode, |
@@ -1163,7 +2207,16 @@ impl Param { | |||
1163 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 2207 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
1164 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | 2208 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } |
1165 | } | 2209 | } |
1166 | 2210 | /// Use declaration. | |
2211 | /// | ||
2212 | /// ``` | ||
2213 | /// ❰ #[attr] pub use foo; ❱ | ||
2214 | /// ❰ use bar as baz; ❱ | ||
2215 | /// ❰ use bruh::{self, bruuh}; ❱ | ||
2216 | /// ❰ use { blin::blen, blah::* }; | ||
2217 | /// ``` | ||
2218 | /// | ||
2219 | /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html) | ||
1167 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2220 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1168 | pub struct UseItem { | 2221 | pub struct UseItem { |
1169 | pub(crate) syntax: SyntaxNode, | 2222 | pub(crate) syntax: SyntaxNode, |
@@ -1174,7 +2227,16 @@ impl UseItem { | |||
1174 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } | 2227 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } |
1175 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } | 2228 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } |
1176 | } | 2229 | } |
1177 | 2230 | /// Use tree. | |
2231 | /// | ||
2232 | /// ``` | ||
2233 | /// pub use ❰ foo::❰ * ❱ ❱; | ||
2234 | /// use ❰ bar as baz ❱; | ||
2235 | /// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱; | ||
2236 | /// use ❰ { ❰ blin::blen ❱ } ❱ // TODO: clarify if top-level curlies are `UseTree` | ||
2237 | /// ``` | ||
2238 | /// | ||
2239 | /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html) | ||
1178 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2240 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1179 | pub struct UseTree { | 2241 | pub struct UseTree { |
1180 | pub(crate) syntax: SyntaxNode, | 2242 | pub(crate) syntax: SyntaxNode, |
@@ -1185,7 +2247,16 @@ impl UseTree { | |||
1185 | pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } | 2247 | pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } |
1186 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | 2248 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } |
1187 | } | 2249 | } |
1188 | 2250 | /// Item alias. | |
2251 | /// Note: this is not the type alias. | ||
2252 | /// | ||
2253 | /// ``` | ||
2254 | /// use foo ❰ as bar ❱; | ||
2255 | /// use baz::{bruh ❰ as _ ❱}; | ||
2256 | /// extern crate bruuh ❰ as blin ❱; | ||
2257 | /// ``` | ||
2258 | /// | ||
2259 | /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html) | ||
1189 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2260 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1190 | pub struct Alias { | 2261 | pub struct Alias { |
1191 | pub(crate) syntax: SyntaxNode, | 2262 | pub(crate) syntax: SyntaxNode, |
@@ -1194,7 +2265,14 @@ impl ast::NameOwner for Alias {} | |||
1194 | impl Alias { | 2265 | impl Alias { |
1195 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | 2266 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } |
1196 | } | 2267 | } |
1197 | 2268 | /// Sublist of use trees. | |
2269 | /// | ||
2270 | /// ``` | ||
2271 | /// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱; | ||
2272 | /// use ❰ { blin::blen::❰ {} ❱ } ❱ | ||
2273 | /// ``` | ||
2274 | /// | ||
2275 | /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html) | ||
1198 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2276 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1199 | pub struct UseTreeList { | 2277 | pub struct UseTreeList { |
1200 | pub(crate) syntax: SyntaxNode, | 2278 | pub(crate) syntax: SyntaxNode, |
@@ -1204,7 +2282,14 @@ impl UseTreeList { | |||
1204 | pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) } | 2282 | pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) } |
1205 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 2283 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
1206 | } | 2284 | } |
1207 | 2285 | /// Extern crate item. | |
2286 | /// | ||
2287 | /// ``` | ||
2288 | /// ❰ #[attr] pub extern crate foo; ❱ | ||
2289 | /// ❰ extern crate self as bar; ❱ | ||
2290 | /// ``` | ||
2291 | /// | ||
2292 | /// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html) | ||
1208 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2293 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1209 | pub struct ExternCrateItem { | 2294 | pub struct ExternCrateItem { |
1210 | pub(crate) syntax: SyntaxNode, | 2295 | pub(crate) syntax: SyntaxNode, |
@@ -1217,7 +2302,13 @@ impl ExternCrateItem { | |||
1217 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 2302 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
1218 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | 2303 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } |
1219 | } | 2304 | } |
1220 | 2305 | /// Call site arguments list. | |
2306 | /// | ||
2307 | /// ``` | ||
2308 | /// foo::<T, U>❰ (42, true) ❱; | ||
2309 | /// ``` | ||
2310 | /// | ||
2311 | /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html) | ||
1221 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2312 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1222 | pub struct ArgList { | 2313 | pub struct ArgList { |
1223 | pub(crate) syntax: SyntaxNode, | 2314 | pub(crate) syntax: SyntaxNode, |
@@ -1227,7 +2318,17 @@ impl ArgList { | |||
1227 | pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) } | 2318 | pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) } |
1228 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 2319 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
1229 | } | 2320 | } |
1230 | 2321 | /// Path to a symbol. Includes single identifier names and elaborate paths with | |
2322 | /// generic parameters. | ||
2323 | /// | ||
2324 | /// ``` | ||
2325 | /// (0..10).❰ collect ❰ ::<Vec<_>> ❱ ❱(); | ||
2326 | /// ❰ Vec ❰ ::<u8> ❰ ::with_capacity ❱ ❱ ❱(1024); | ||
2327 | /// ❰ <Foo as Bar> ❰ ::baz ❱ ❱(); | ||
2328 | /// ❰ <bruh> ❰ ::bruuh ❱ ❱(); | ||
2329 | /// ``` | ||
2330 | /// | ||
2331 | /// [Reference](https://doc.rust-lang.org/reference/paths.html) | ||
1231 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2332 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1232 | pub struct Path { | 2333 | pub struct Path { |
1233 | pub(crate) syntax: SyntaxNode, | 2334 | pub(crate) syntax: SyntaxNode, |
@@ -1236,7 +2337,16 @@ impl Path { | |||
1236 | pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } | 2337 | pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } |
1237 | pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) } | 2338 | pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) } |
1238 | } | 2339 | } |
1239 | 2340 | /// Segment of the path to a symbol. | |
2341 | /// | ||
2342 | /// ``` | ||
2343 | /// (0..10).❰ collect ❱ ❰ ::<Vec<_>> ❱(); | ||
2344 | /// ❰ Vec >| ❰ ::<u8> ❱ ❰ ::with_capacity ❱(1024); | ||
2345 | /// ❰ <Foo as Bar> ❱ ❰ ::baz ❱(); | ||
2346 | /// ❰ <bruh> ❱ ❰ ::bruuh ❱(); | ||
2347 | /// ``` | ||
2348 | /// | ||
2349 | /// [Reference](https://doc.rust-lang.org/reference/paths.html) | ||
1240 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2350 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1241 | pub struct PathSegment { | 2351 | pub struct PathSegment { |
1242 | pub(crate) syntax: SyntaxNode, | 2352 | pub(crate) syntax: SyntaxNode, |
@@ -1254,7 +2364,15 @@ impl PathSegment { | |||
1254 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } | 2364 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } |
1255 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | 2365 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } |
1256 | } | 2366 | } |
1257 | 2367 | /// List of type arguments that are passed at generic instantiation site. | |
2368 | /// | ||
2369 | /// ``` | ||
2370 | /// use foo ❰ ::<'a, u64, Item = Bar, 42, true> ❱::bar; | ||
2371 | /// | ||
2372 | /// Vec❰ ::<bool> ❱::(); | ||
2373 | /// ``` | ||
2374 | /// | ||
2375 | /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions) | ||
1258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2376 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1259 | pub struct TypeArgList { | 2377 | pub struct TypeArgList { |
1260 | pub(crate) syntax: SyntaxNode, | 2378 | pub(crate) syntax: SyntaxNode, |
@@ -1269,7 +2387,13 @@ impl TypeArgList { | |||
1269 | pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } | 2387 | pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } |
1270 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | 2388 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } |
1271 | } | 2389 | } |
1272 | 2390 | /// Type argument that is passed at generic instantiation site. | |
2391 | /// | ||
2392 | /// ``` | ||
2393 | /// use foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::baz; | ||
2394 | /// ``` | ||
2395 | /// | ||
2396 | /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions) | ||
1273 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2397 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1274 | pub struct TypeArg { | 2398 | pub struct TypeArg { |
1275 | pub(crate) syntax: SyntaxNode, | 2399 | pub(crate) syntax: SyntaxNode, |
@@ -1277,7 +2401,13 @@ pub struct TypeArg { | |||
1277 | impl TypeArg { | 2401 | impl TypeArg { |
1278 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 2402 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1279 | } | 2403 | } |
1280 | 2404 | /// Associated type argument that is passed at generic instantiation site. | |
2405 | /// ``` | ||
2406 | /// use foo::<'a, u64, bool, ❰ Item = Bar ❱, 42>::baz; | ||
2407 | /// | ||
2408 | /// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {} | ||
2409 | /// ``` | ||
2410 | /// | ||
1281 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2411 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1282 | pub struct AssocTypeArg { | 2412 | pub struct AssocTypeArg { |
1283 | pub(crate) syntax: SyntaxNode, | 2413 | pub(crate) syntax: SyntaxNode, |
@@ -1288,7 +2418,15 @@ impl AssocTypeArg { | |||
1288 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 2418 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1289 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 2419 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1290 | } | 2420 | } |
1291 | 2421 | /// Lifetime argument that is passed at generic instantiation site. | |
2422 | /// | ||
2423 | /// ``` | ||
2424 | /// fn foo<'a>(s: &'a str) { | ||
2425 | /// bar::<❰ 'a ❱>(s); | ||
2426 | /// } | ||
2427 | /// ``` | ||
2428 | /// | ||
2429 | /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions) | ||
1292 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2430 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1293 | pub struct LifetimeArg { | 2431 | pub struct LifetimeArg { |
1294 | pub(crate) syntax: SyntaxNode, | 2432 | pub(crate) syntax: SyntaxNode, |
@@ -1298,7 +2436,15 @@ impl LifetimeArg { | |||
1298 | support::token(&self.syntax, T![lifetime]) | 2436 | support::token(&self.syntax, T![lifetime]) |
1299 | } | 2437 | } |
1300 | } | 2438 | } |
1301 | 2439 | /// Constant value argument that is passed at generic instantiation site. | |
2440 | /// | ||
2441 | /// ``` | ||
2442 | /// foo::<❰ u32 ❱, ❰ true ❱ >(); | ||
2443 | /// | ||
2444 | /// bar::<❰ { 2 + 2} ❱>(); | ||
2445 | /// ``` | ||
2446 | /// | ||
2447 | /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter) | ||
1302 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2448 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1303 | pub struct ConstArg { | 2449 | pub struct ConstArg { |
1304 | pub(crate) syntax: SyntaxNode, | 2450 | pub(crate) syntax: SyntaxNode, |
@@ -1308,14 +2454,28 @@ impl ConstArg { | |||
1308 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 2454 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1309 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 2455 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
1310 | } | 2456 | } |
1311 | 2457 | /// Macro items is a node that holds all the items created by expanding a macro. | |
2458 | /// | ||
2459 | /// ``` | ||
2460 | /// foo!(); // expands into some items -v | ||
2461 | /// // ❰ struct Foo; impl Bar for Foo; ❱ | ||
2462 | /// ``` | ||
2463 | /// | ||
2464 | /// [Reference](https://doc.rust-lang.org/reference/macros.html) | ||
1312 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2465 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1313 | pub struct MacroItems { | 2466 | pub struct MacroItems { |
1314 | pub(crate) syntax: SyntaxNode, | 2467 | pub(crate) syntax: SyntaxNode, |
1315 | } | 2468 | } |
1316 | impl ast::ModuleItemOwner for MacroItems {} | 2469 | impl ast::ModuleItemOwner for MacroItems {} |
1317 | impl MacroItems {} | 2470 | impl MacroItems {} |
1318 | 2471 | /// Macro statements is a node that holds an statements created by expanding a macro. | |
2472 | /// | ||
2473 | /// ``` | ||
2474 | /// foo!(); // expands into some statements -v | ||
2475 | /// // ❰ foo_crate::bar(); ❱ | ||
2476 | /// ``` | ||
2477 | /// | ||
2478 | /// [Reference](https://doc.rust-lang.org/reference/macros.html) | ||
1319 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2479 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1320 | pub struct MacroStmts { | 2480 | pub struct MacroStmts { |
1321 | pub(crate) syntax: SyntaxNode, | 2481 | pub(crate) syntax: SyntaxNode, |
@@ -1324,7 +2484,18 @@ impl MacroStmts { | |||
1324 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | 2484 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } |
1325 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 2485 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1326 | } | 2486 | } |
1327 | 2487 | /// List of items in an extern block. | |
2488 | /// | ||
2489 | /// ``` | ||
2490 | /// extern "C" ❰ | ||
2491 | /// { | ||
2492 | /// fn foo(); | ||
2493 | /// static var: u32; | ||
2494 | /// } | ||
2495 | /// ❱ | ||
2496 | /// ``` | ||
2497 | /// | ||
2498 | /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html) | ||
1328 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2499 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1329 | pub struct ExternItemList { | 2500 | pub struct ExternItemList { |
1330 | pub(crate) syntax: SyntaxNode, | 2501 | pub(crate) syntax: SyntaxNode, |
@@ -1335,7 +2506,18 @@ impl ExternItemList { | |||
1335 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } | 2506 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } |
1336 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 2507 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
1337 | } | 2508 | } |
1338 | 2509 | /// Extern block. | |
2510 | /// | ||
2511 | /// ``` | ||
2512 | /// ❰ | ||
2513 | /// extern "C" { | ||
2514 | /// fn foo(); | ||
2515 | /// } | ||
2516 | /// ❱ | ||
2517 | /// | ||
2518 | /// ``` | ||
2519 | /// | ||
2520 | /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html) | ||
1339 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2521 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1340 | pub struct ExternBlock { | 2522 | pub struct ExternBlock { |
1341 | pub(crate) syntax: SyntaxNode, | 2523 | pub(crate) syntax: SyntaxNode, |
@@ -1344,7 +2526,15 @@ impl ExternBlock { | |||
1344 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | 2526 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } |
1345 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } | 2527 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } |
1346 | } | 2528 | } |
1347 | 2529 | /// Meta item in an attribute. | |
2530 | /// | ||
2531 | /// ``` | ||
2532 | /// #[❰ bar::baz = "42" ❱] | ||
2533 | /// #[❰ bruh(bruuh("true")) ❱] | ||
2534 | /// struct Foo; | ||
2535 | /// ``` | ||
2536 | /// | ||
2537 | /// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax) | ||
1348 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2538 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1349 | pub struct MetaItem { | 2539 | pub struct MetaItem { |
1350 | pub(crate) syntax: SyntaxNode, | 2540 | pub(crate) syntax: SyntaxNode, |
@@ -1355,7 +2545,17 @@ impl MetaItem { | |||
1355 | pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } | 2545 | pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } |
1356 | pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } | 2546 | pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } |
1357 | } | 2547 | } |
1358 | 2548 | /// Macro definition. | |
2549 | /// | ||
2550 | /// ``` | ||
2551 | /// ❰ | ||
2552 | /// macro_rules! foo { | ||
2553 | /// ($bar:tt) => {$bar} | ||
2554 | /// } | ||
2555 | /// ❱ | ||
2556 | /// ``` | ||
2557 | /// | ||
2558 | /// [Reference](https://doc.rust-lang.org/reference/macros-by-example.html) | ||
1359 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2559 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1360 | pub struct MacroDef { | 2560 | pub struct MacroDef { |
1361 | pub(crate) syntax: SyntaxNode, | 2561 | pub(crate) syntax: SyntaxNode, |
@@ -1364,7 +2564,7 @@ impl MacroDef { | |||
1364 | pub fn name(&self) -> Option<Name> { support::child(&self.syntax) } | 2564 | pub fn name(&self) -> Option<Name> { support::child(&self.syntax) } |
1365 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | 2565 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } |
1366 | } | 2566 | } |
1367 | 2567 | /// Any kind of nominal type definition. | |
1368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2568 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1369 | pub enum NominalDef { | 2569 | pub enum NominalDef { |
1370 | StructDef(StructDef), | 2570 | StructDef(StructDef), |
@@ -1374,14 +2574,14 @@ pub enum NominalDef { | |||
1374 | impl ast::NameOwner for NominalDef {} | 2574 | impl ast::NameOwner for NominalDef {} |
1375 | impl ast::TypeParamsOwner for NominalDef {} | 2575 | impl ast::TypeParamsOwner for NominalDef {} |
1376 | impl ast::AttrsOwner for NominalDef {} | 2576 | impl ast::AttrsOwner for NominalDef {} |
1377 | 2577 | /// Any kind of **declared** generic parameter | |
1378 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2578 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1379 | pub enum GenericParam { | 2579 | pub enum GenericParam { |
1380 | LifetimeParam(LifetimeParam), | 2580 | LifetimeParam(LifetimeParam), |
1381 | TypeParam(TypeParam), | 2581 | TypeParam(TypeParam), |
1382 | ConstParam(ConstParam), | 2582 | ConstParam(ConstParam), |
1383 | } | 2583 | } |
1384 | 2584 | /// Any kind of generic argument passed at instantiation site | |
1385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2585 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1386 | pub enum GenericArg { | 2586 | pub enum GenericArg { |
1387 | LifetimeArg(LifetimeArg), | 2587 | LifetimeArg(LifetimeArg), |
@@ -1389,7 +2589,7 @@ pub enum GenericArg { | |||
1389 | ConstArg(ConstArg), | 2589 | ConstArg(ConstArg), |
1390 | AssocTypeArg(AssocTypeArg), | 2590 | AssocTypeArg(AssocTypeArg), |
1391 | } | 2591 | } |
1392 | 2592 | /// Any kind of construct valid in type context | |
1393 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2593 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1394 | pub enum TypeRef { | 2594 | pub enum TypeRef { |
1395 | ParenType(ParenType), | 2595 | ParenType(ParenType), |
@@ -1406,7 +2606,7 @@ pub enum TypeRef { | |||
1406 | ImplTraitType(ImplTraitType), | 2606 | ImplTraitType(ImplTraitType), |
1407 | DynTraitType(DynTraitType), | 2607 | DynTraitType(DynTraitType), |
1408 | } | 2608 | } |
1409 | 2609 | /// Any kind of top-level item that may appear in a module | |
1410 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2610 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1411 | pub enum ModuleItem { | 2611 | pub enum ModuleItem { |
1412 | StructDef(StructDef), | 2612 | StructDef(StructDef), |
@@ -1427,7 +2627,10 @@ pub enum ModuleItem { | |||
1427 | impl ast::NameOwner for ModuleItem {} | 2627 | impl ast::NameOwner for ModuleItem {} |
1428 | impl ast::AttrsOwner for ModuleItem {} | 2628 | impl ast::AttrsOwner for ModuleItem {} |
1429 | impl ast::VisibilityOwner for ModuleItem {} | 2629 | impl ast::VisibilityOwner for ModuleItem {} |
1430 | 2630 | /// Any kind of item that may appear in an impl block | |
2631 | /// | ||
2632 | /// // TODO: is the following a fixme? | ||
2633 | /// impl blocks can also contain MacroCall | ||
1431 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2634 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1432 | pub enum AssocItem { | 2635 | pub enum AssocItem { |
1433 | FnDef(FnDef), | 2636 | FnDef(FnDef), |
@@ -1436,7 +2639,10 @@ pub enum AssocItem { | |||
1436 | } | 2639 | } |
1437 | impl ast::NameOwner for AssocItem {} | 2640 | impl ast::NameOwner for AssocItem {} |
1438 | impl ast::AttrsOwner for AssocItem {} | 2641 | impl ast::AttrsOwner for AssocItem {} |
1439 | 2642 | /// Any kind of item that may appear in an extern block | |
2643 | /// | ||
2644 | /// // TODO: is the following a fixme? | ||
2645 | /// extern blocks can also contain MacroCall | ||
1440 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2646 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1441 | pub enum ExternItem { | 2647 | pub enum ExternItem { |
1442 | FnDef(FnDef), | 2648 | FnDef(FnDef), |
@@ -1445,7 +2651,7 @@ pub enum ExternItem { | |||
1445 | impl ast::NameOwner for ExternItem {} | 2651 | impl ast::NameOwner for ExternItem {} |
1446 | impl ast::AttrsOwner for ExternItem {} | 2652 | impl ast::AttrsOwner for ExternItem {} |
1447 | impl ast::VisibilityOwner for ExternItem {} | 2653 | impl ast::VisibilityOwner for ExternItem {} |
1448 | 2654 | /// Any kind of expression | |
1449 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2655 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1450 | pub enum Expr { | 2656 | pub enum Expr { |
1451 | TupleExpr(TupleExpr), | 2657 | TupleExpr(TupleExpr), |
@@ -1481,7 +2687,7 @@ pub enum Expr { | |||
1481 | BoxExpr(BoxExpr), | 2687 | BoxExpr(BoxExpr), |
1482 | } | 2688 | } |
1483 | impl ast::AttrsOwner for Expr {} | 2689 | impl ast::AttrsOwner for Expr {} |
1484 | 2690 | /// Any kind of pattern | |
1485 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2691 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1486 | pub enum Pat { | 2692 | pub enum Pat { |
1487 | OrPat(OrPat), | 2693 | OrPat(OrPat), |
@@ -1500,25 +2706,26 @@ pub enum Pat { | |||
1500 | LiteralPat(LiteralPat), | 2706 | LiteralPat(LiteralPat), |
1501 | MacroPat(MacroPat), | 2707 | MacroPat(MacroPat), |
1502 | } | 2708 | } |
1503 | 2709 | /// Any kind of pattern that appears directly inside of the curly | |
2710 | /// braces of a record pattern | ||
1504 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2711 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1505 | pub enum RecordInnerPat { | 2712 | pub enum RecordInnerPat { |
1506 | RecordFieldPat(RecordFieldPat), | 2713 | RecordFieldPat(RecordFieldPat), |
1507 | BindPat(BindPat), | 2714 | BindPat(BindPat), |
1508 | } | 2715 | } |
1509 | 2716 | /// Any kind of input to an attribute | |
1510 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2717 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1511 | pub enum AttrInput { | 2718 | pub enum AttrInput { |
1512 | Literal(Literal), | 2719 | Literal(Literal), |
1513 | TokenTree(TokenTree), | 2720 | TokenTree(TokenTree), |
1514 | } | 2721 | } |
1515 | 2722 | /// Any kind of statement | |
1516 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2723 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1517 | pub enum Stmt { | 2724 | pub enum Stmt { |
1518 | LetStmt(LetStmt), | 2725 | LetStmt(LetStmt), |
1519 | ExprStmt(ExprStmt), | 2726 | ExprStmt(ExprStmt), |
1520 | } | 2727 | } |
1521 | 2728 | /// Any kind of fields list (record or tuple field lists) | |
1522 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2729 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1523 | pub enum FieldDefList { | 2730 | pub enum FieldDefList { |
1524 | RecordFieldDefList(RecordFieldDefList), | 2731 | RecordFieldDefList(RecordFieldDefList), |