aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-29 18:18:53 +0100
committerGitHub <[email protected]>2020-07-29 18:18:53 +0100
commit2dfda0b984c45946b9a4148bd848350deac544f2 (patch)
tree1942eeab995b0bd191c6a998b47cb20a426e5dd3 /crates/ra_syntax
parent525ae706b3e4c0f5f8b80d197e5fede0a9974442 (diff)
parent3d28292157e1b6c9675ef64eddf53786c3e7dc5f (diff)
Merge #5572
5572: Switch to ungrammar from ast_src r=matklad a=matklad The primary advantage of ungrammar is that it (eventually) allows one to describe concrete syntax tree structure -- with alternatives and specific sequence of tokens & nodes. That should be re-usable for: * generate `make` calls * Rust reference * Hypothetical parser's evented API We loose doc comments for the time being unfortunately. I don't think we should add support for doc comments to ungrammar -- they'll make grammar file hard to read. We might supply docs as out-of band info, or maybe just via a reference, but we'll think about that once things are no longer in flux bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/expr_ext.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs3010
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs16
3 files changed, 824 insertions, 2204 deletions
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs
index db5438d68..69c85c809 100644
--- a/crates/ra_syntax/src/ast/expr_ext.rs
+++ b/crates/ra_syntax/src/ast/expr_ext.rs
@@ -7,6 +7,8 @@ use crate::{
7 SyntaxToken, T, 7 SyntaxToken, T,
8}; 8};
9 9
10impl ast::AttrsOwner for ast::Expr {}
11
10impl ast::Expr { 12impl ast::Expr {
11 pub fn is_block_like(&self) -> bool { 13 pub fn is_block_like(&self) -> bool {
12 match self { 14 match self {
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 1fe5f450a..b2d108a7c 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -5,48 +5,34 @@ use crate::{
5 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
6 SyntaxNode, SyntaxToken, T, 6 SyntaxNode, SyntaxToken, T,
7}; 7};
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)
11#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12pub struct SourceFile { 9pub struct SourceFile {
13 pub(crate) syntax: SyntaxNode, 10 pub(crate) syntax: SyntaxNode,
14} 11}
15impl ast::ModuleItemOwner for SourceFile {}
16impl ast::AttrsOwner for SourceFile {} 12impl ast::AttrsOwner for SourceFile {}
17impl ast::DocCommentsOwner for SourceFile {} 13impl ast::ModuleItemOwner for SourceFile {}
18impl SourceFile {} 14impl SourceFile {}
19/// Function definition either with body or not. 15#[derive(Debug, Clone, PartialEq, Eq, Hash)]
20/// Includes all of its attributes and doc comments. 16pub struct Attr {
21/// 17 pub(crate) syntax: SyntaxNode,
22/// ``` 18}
23/// ❰ 19impl Attr {
24/// /// Docs 20 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
25/// #[attr] 21 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
26/// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32 22 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
27/// where 23 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
28/// T: Debug 24 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
29/// { 25 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
30/// 42 26 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
31/// } 27}
32/// ❱
33///
34/// extern "C" {
35/// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
36/// }
37/// ```
38///
39/// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
40/// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
41#[derive(Debug, Clone, PartialEq, Eq, Hash)] 28#[derive(Debug, Clone, PartialEq, Eq, Hash)]
42pub struct FnDef { 29pub struct FnDef {
43 pub(crate) syntax: SyntaxNode, 30 pub(crate) syntax: SyntaxNode,
44} 31}
45impl ast::VisibilityOwner for FnDef {} 32impl ast::AttrsOwner for FnDef {}
46impl ast::NameOwner for FnDef {} 33impl ast::NameOwner for FnDef {}
34impl ast::VisibilityOwner for FnDef {}
47impl ast::TypeParamsOwner for FnDef {} 35impl ast::TypeParamsOwner for FnDef {}
48impl ast::DocCommentsOwner for FnDef {}
49impl ast::AttrsOwner for FnDef {}
50impl FnDef { 36impl FnDef {
51 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 37 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
52 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 38 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
@@ -59,13 +45,53 @@ impl FnDef {
59 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 45 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
60 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 46 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
61} 47}
62/// Return type annotation. 48#[derive(Debug, Clone, PartialEq, Eq, Hash)]
63/// 49pub struct Visibility {
64/// ``` 50 pub(crate) syntax: SyntaxNode,
65/// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) } 51}
66/// ``` 52impl Visibility {
67/// 53 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
68/// [Reference](https://doc.rust-lang.org/reference/items/functions.html) 54 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
55 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
56 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
57 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
58 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
59 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
60 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
61}
62#[derive(Debug, Clone, PartialEq, Eq, Hash)]
63pub struct Abi {
64 pub(crate) syntax: SyntaxNode,
65}
66impl Abi {}
67#[derive(Debug, Clone, PartialEq, Eq, Hash)]
68pub struct Name {
69 pub(crate) syntax: SyntaxNode,
70}
71impl Name {
72 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
73}
74#[derive(Debug, Clone, PartialEq, Eq, Hash)]
75pub struct TypeParamList {
76 pub(crate) syntax: SyntaxNode,
77}
78impl TypeParamList {
79 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
80 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
81 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
82 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
83 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
84}
85#[derive(Debug, Clone, PartialEq, Eq, Hash)]
86pub struct ParamList {
87 pub(crate) syntax: SyntaxNode,
88}
89impl ParamList {
90 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
91 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
92 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
93 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
94}
69#[derive(Debug, Clone, PartialEq, Eq, Hash)] 95#[derive(Debug, Clone, PartialEq, Eq, Hash)]
70pub struct RetType { 96pub struct RetType {
71 pub(crate) syntax: SyntaxNode, 97 pub(crate) syntax: SyntaxNode,
@@ -74,204 +100,105 @@ impl RetType {
74 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } 100 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
75 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 101 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
76} 102}
77/// Struct definition. 103#[derive(Debug, Clone, PartialEq, Eq, Hash)]
78/// Includes all of its attributes and doc comments. 104pub struct WhereClause {
79/// 105 pub(crate) syntax: SyntaxNode,
80/// ``` 106}
81/// ❰ 107impl WhereClause {
82/// /// Docs 108 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
83/// #[attr] 109 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
84/// struct Foo<T> where T: Debug { 110}
85/// /// Docs 111#[derive(Debug, Clone, PartialEq, Eq, Hash)]
86/// #[attr] 112pub struct BlockExpr {
87/// pub a: u32, 113 pub(crate) syntax: SyntaxNode,
88/// b: T, 114}
89/// } 115impl ast::AttrsOwner for BlockExpr {}
90/// ❱ 116impl ast::ModuleItemOwner for BlockExpr {}
91/// 117impl BlockExpr {
92/// ❰ struct Foo; ❱ 118 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
93/// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱ 119 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
94/// ``` 120 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
95/// 121 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
96/// [Reference](https://doc.rust-lang.org/reference/items/structs.html) 122 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
123}
97#[derive(Debug, Clone, PartialEq, Eq, Hash)] 124#[derive(Debug, Clone, PartialEq, Eq, Hash)]
98pub struct StructDef { 125pub struct StructDef {
99 pub(crate) syntax: SyntaxNode, 126 pub(crate) syntax: SyntaxNode,
100} 127}
101impl ast::VisibilityOwner for StructDef {} 128impl ast::AttrsOwner for StructDef {}
102impl ast::NameOwner for StructDef {} 129impl ast::NameOwner for StructDef {}
130impl ast::VisibilityOwner for StructDef {}
103impl ast::TypeParamsOwner for StructDef {} 131impl ast::TypeParamsOwner for StructDef {}
104impl ast::AttrsOwner for StructDef {}
105impl ast::DocCommentsOwner for StructDef {}
106impl StructDef { 132impl StructDef {
107 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } 133 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
108 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
109 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 134 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
135 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
136}
137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
138pub struct RecordFieldDefList {
139 pub(crate) syntax: SyntaxNode,
140}
141impl RecordFieldDefList {
142 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
143 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) }
144 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
145}
146#[derive(Debug, Clone, PartialEq, Eq, Hash)]
147pub struct TupleFieldDefList {
148 pub(crate) syntax: SyntaxNode,
149}
150impl TupleFieldDefList {
151 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
152 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
153 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
110} 154}
111/// Union definition.
112/// Includes all of its attributes and doc comments.
113///
114/// ```
115/// ❰
116/// /// Docs
117/// #[attr]
118/// pub union Foo<T> where T: Debug {
119/// /// Docs
120/// #[attr]
121/// a: T,
122/// b: u32,
123/// }
124/// ❱
125/// ```
126///
127/// [Reference](https://doc.rust-lang.org/reference/items/unions.html)
128#[derive(Debug, Clone, PartialEq, Eq, Hash)] 155#[derive(Debug, Clone, PartialEq, Eq, Hash)]
129pub struct UnionDef { 156pub struct UnionDef {
130 pub(crate) syntax: SyntaxNode, 157 pub(crate) syntax: SyntaxNode,
131} 158}
132impl ast::VisibilityOwner for UnionDef {} 159impl ast::AttrsOwner for UnionDef {}
133impl ast::NameOwner for UnionDef {} 160impl ast::NameOwner for UnionDef {}
161impl ast::VisibilityOwner for UnionDef {}
134impl ast::TypeParamsOwner for UnionDef {} 162impl ast::TypeParamsOwner for UnionDef {}
135impl ast::AttrsOwner for UnionDef {}
136impl ast::DocCommentsOwner for UnionDef {}
137impl UnionDef { 163impl UnionDef {
138 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } 164 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
139 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 165 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
140 support::child(&self.syntax) 166 support::child(&self.syntax)
141 } 167 }
142} 168}
143/// Record field definition list including enclosing curly braces.
144///
145/// ```
146/// struct Foo // same for union
147/// ❰
148/// {
149/// a: u32,
150/// b: bool,
151/// }
152/// ❱
153/// ```
154///
155/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
156#[derive(Debug, Clone, PartialEq, Eq, Hash)]
157pub struct RecordFieldDefList {
158 pub(crate) syntax: SyntaxNode,
159}
160impl RecordFieldDefList {
161 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
162 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) }
163 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
164}
165/// Record field definition including its attributes and doc comments.
166///
167/// ` ``
168/// same for union
169/// struct Foo {
170/// ❰
171/// /// Docs
172/// #[attr]
173/// pub a: u32
174/// ❱
175///
176/// ❰ b: bool ❱
177/// }
178/// ```
179///
180/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
181#[derive(Debug, Clone, PartialEq, Eq, Hash)] 169#[derive(Debug, Clone, PartialEq, Eq, Hash)]
182pub struct RecordFieldDef { 170pub struct RecordFieldDef {
183 pub(crate) syntax: SyntaxNode, 171 pub(crate) syntax: SyntaxNode,
184} 172}
185impl ast::VisibilityOwner for RecordFieldDef {}
186impl ast::NameOwner for RecordFieldDef {}
187impl ast::AttrsOwner for RecordFieldDef {} 173impl ast::AttrsOwner for RecordFieldDef {}
188impl ast::DocCommentsOwner for RecordFieldDef {} 174impl ast::NameOwner for RecordFieldDef {}
175impl ast::VisibilityOwner for RecordFieldDef {}
189impl ast::TypeAscriptionOwner for RecordFieldDef {} 176impl ast::TypeAscriptionOwner for RecordFieldDef {}
190impl RecordFieldDef {} 177impl RecordFieldDef {
191/// Tuple field definition list including enclosing parens. 178 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
192///
193/// ```
194/// struct Foo ❰ (u32, String, Vec<u32>) ❱;
195/// ```
196///
197/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
199pub struct TupleFieldDefList {
200 pub(crate) syntax: SyntaxNode,
201}
202impl TupleFieldDefList {
203 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
204 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
205 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
206} 179}
207/// Tuple field definition including its attributes.
208///
209/// ```
210/// struct Foo(❰ #[attr] u32 ❱);
211/// ```
212///
213/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
214#[derive(Debug, Clone, PartialEq, Eq, Hash)] 180#[derive(Debug, Clone, PartialEq, Eq, Hash)]
215pub struct TupleFieldDef { 181pub struct TupleFieldDef {
216 pub(crate) syntax: SyntaxNode, 182 pub(crate) syntax: SyntaxNode,
217} 183}
218impl ast::VisibilityOwner for TupleFieldDef {}
219impl ast::AttrsOwner for TupleFieldDef {} 184impl ast::AttrsOwner for TupleFieldDef {}
185impl ast::NameOwner for TupleFieldDef {}
186impl ast::VisibilityOwner for TupleFieldDef {}
220impl TupleFieldDef { 187impl TupleFieldDef {
221 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 188 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
222} 189}
223/// Enum definition.
224/// Includes all of its attributes and doc comments.
225///
226/// ```
227/// ❰
228/// /// Docs
229/// #[attr]
230/// pub enum Foo<T> where T: Debug {
231/// /// Docs
232/// #[attr]
233/// Bar,
234/// Baz(#[attr] u32),
235/// Bruh {
236/// a: u32,
237/// /// Docs
238/// #[attr]
239/// b: T,
240/// }
241/// }
242/// ❱
243/// ```
244///
245/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
246#[derive(Debug, Clone, PartialEq, Eq, Hash)] 190#[derive(Debug, Clone, PartialEq, Eq, Hash)]
247pub struct EnumDef { 191pub struct EnumDef {
248 pub(crate) syntax: SyntaxNode, 192 pub(crate) syntax: SyntaxNode,
249} 193}
250impl ast::VisibilityOwner for EnumDef {} 194impl ast::AttrsOwner for EnumDef {}
251impl ast::NameOwner for EnumDef {} 195impl ast::NameOwner for EnumDef {}
196impl ast::VisibilityOwner for EnumDef {}
252impl ast::TypeParamsOwner for EnumDef {} 197impl ast::TypeParamsOwner for EnumDef {}
253impl ast::AttrsOwner for EnumDef {}
254impl ast::DocCommentsOwner for EnumDef {}
255impl EnumDef { 198impl EnumDef {
256 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } 199 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
257 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } 200 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
258} 201}
259/// Enum variant definition list including enclosing curly braces.
260///
261/// ```
262/// enum Foo
263/// ❰
264/// {
265/// Bar,
266/// Baz(u32),
267/// Bruh {
268/// a: u32
269/// }
270/// }
271/// ❱
272/// ```
273///
274/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
275#[derive(Debug, Clone, PartialEq, Eq, Hash)] 202#[derive(Debug, Clone, PartialEq, Eq, Hash)]
276pub struct EnumVariantList { 203pub struct EnumVariantList {
277 pub(crate) syntax: SyntaxNode, 204 pub(crate) syntax: SyntaxNode,
@@ -281,56 +208,25 @@ impl EnumVariantList {
281 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 208 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) }
282 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 209 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
283} 210}
284/// Enum variant definition including its attributes and discriminant value definition.
285///
286/// ```
287/// enum Foo {
288/// ❰
289/// /// Docs
290/// #[attr]
291/// Bar
292/// ❱
293///
294/// // same for tuple and record variants
295/// }
296/// ```
297///
298/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
299#[derive(Debug, Clone, PartialEq, Eq, Hash)] 211#[derive(Debug, Clone, PartialEq, Eq, Hash)]
300pub struct EnumVariant { 212pub struct EnumVariant {
301 pub(crate) syntax: SyntaxNode, 213 pub(crate) syntax: SyntaxNode,
302} 214}
303impl ast::VisibilityOwner for EnumVariant {}
304impl ast::NameOwner for EnumVariant {}
305impl ast::DocCommentsOwner for EnumVariant {}
306impl ast::AttrsOwner for EnumVariant {} 215impl ast::AttrsOwner for EnumVariant {}
216impl ast::NameOwner for EnumVariant {}
217impl ast::VisibilityOwner for EnumVariant {}
307impl EnumVariant { 218impl EnumVariant {
308 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 219 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
309 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 220 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
310 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 221 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
311} 222}
312/// Trait definition.
313/// Includes all of its attributes and doc comments.
314///
315/// ```
316/// ❰
317/// /// Docs
318/// #[attr]
319/// pub unsafe trait Foo<T>: Debug where T: Debug {
320/// // ...
321/// }
322/// ❱
323/// ```
324///
325/// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
326#[derive(Debug, Clone, PartialEq, Eq, Hash)] 223#[derive(Debug, Clone, PartialEq, Eq, Hash)]
327pub struct TraitDef { 224pub struct TraitDef {
328 pub(crate) syntax: SyntaxNode, 225 pub(crate) syntax: SyntaxNode,
329} 226}
330impl ast::VisibilityOwner for TraitDef {}
331impl ast::NameOwner for TraitDef {}
332impl ast::AttrsOwner for TraitDef {} 227impl ast::AttrsOwner for TraitDef {}
333impl ast::DocCommentsOwner for TraitDef {} 228impl ast::NameOwner for TraitDef {}
229impl ast::VisibilityOwner for TraitDef {}
334impl ast::TypeParamsOwner for TraitDef {} 230impl ast::TypeParamsOwner for TraitDef {}
335impl ast::TypeBoundsOwner for TraitDef {} 231impl ast::TypeBoundsOwner for TraitDef {}
336impl TraitDef { 232impl TraitDef {
@@ -339,62 +235,13 @@ impl TraitDef {
339 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } 235 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
340 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 236 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
341} 237}
342/// Module definition either with body or not.
343/// Includes all of its inner and outer attributes, module items, doc comments.
344///
345/// ```
346/// ❰
347/// /// Docs
348/// #[attr]
349/// pub mod foo;
350/// ❱
351///
352/// ❰
353/// /// Docs
354/// #[attr]
355/// pub mod bar {
356/// //! Inner docs
357/// #![inner_attr]
358/// }
359/// ❱
360/// ```
361///
362/// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
363#[derive(Debug, Clone, PartialEq, Eq, Hash)] 238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
364pub struct Module { 239pub struct TypeBoundList {
365 pub(crate) syntax: SyntaxNode, 240 pub(crate) syntax: SyntaxNode,
366} 241}
367impl ast::VisibilityOwner for Module {} 242impl TypeBoundList {
368impl ast::NameOwner for Module {} 243 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
369impl ast::AttrsOwner for Module {}
370impl ast::DocCommentsOwner for Module {}
371impl Module {
372 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
373 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
374 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
375} 244}
376/// Item defintion list.
377/// This is used for both top-level items and impl block items.
378///
379/// ```
380/// ❰
381/// fn foo {}
382/// struct Bar;
383/// enum Baz;
384/// trait Bruh;
385/// const BRUUH: u32 = 42;
386/// ❱
387///
388/// impl Foo
389/// ❰
390/// {
391/// fn bar() {}
392/// const BAZ: u32 = 42;
393/// }
394/// ❱
395/// ```
396///
397/// [Reference](https://doc.rust-lang.org/reference/items.html)
398#[derive(Debug, Clone, PartialEq, Eq, Hash)] 245#[derive(Debug, Clone, PartialEq, Eq, Hash)]
399pub struct ItemList { 246pub struct ItemList {
400 pub(crate) syntax: SyntaxNode, 247 pub(crate) syntax: SyntaxNode,
@@ -405,91 +252,58 @@ impl ItemList {
405 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } 252 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) }
406 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 253 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
407} 254}
408/// Constant variable definition. 255#[derive(Debug, Clone, PartialEq, Eq, Hash)]
409/// Includes all of its attributes and doc comments. 256pub struct Module {
410/// 257 pub(crate) syntax: SyntaxNode,
411/// ``` 258}
412/// 259impl ast::AttrsOwner for Module {}
413/// /// Docs 260impl ast::NameOwner for Module {}
414/// #[attr] 261impl ast::VisibilityOwner for Module {}
415/// pub const FOO: u32 = 42; 262impl Module {
416/// 263 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
417/// ``` 264 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
418/// 265 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
419/// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html) 266}
420#[derive(Debug, Clone, PartialEq, Eq, Hash)] 267#[derive(Debug, Clone, PartialEq, Eq, Hash)]
421pub struct ConstDef { 268pub struct ConstDef {
422 pub(crate) syntax: SyntaxNode, 269 pub(crate) syntax: SyntaxNode,
423} 270}
424impl ast::VisibilityOwner for ConstDef {}
425impl ast::NameOwner for ConstDef {}
426impl ast::TypeParamsOwner for ConstDef {}
427impl ast::AttrsOwner for ConstDef {} 271impl ast::AttrsOwner for ConstDef {}
428impl ast::DocCommentsOwner for ConstDef {} 272impl ast::NameOwner for ConstDef {}
273impl ast::VisibilityOwner for ConstDef {}
429impl ast::TypeAscriptionOwner for ConstDef {} 274impl ast::TypeAscriptionOwner for ConstDef {}
430impl ConstDef { 275impl ConstDef {
431 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 276 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
432 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 277 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
278 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
433 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 279 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
434 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 280 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
435 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 281 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
436} 282}
437/// Static variable definition.
438/// Includes all of its attributes and doc comments.
439///
440/// ```
441/// ❰
442/// /// Docs
443/// #[attr]
444/// pub static mut FOO: u32 = 42;
445/// ❱
446/// ```
447///
448/// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
449#[derive(Debug, Clone, PartialEq, Eq, Hash)] 283#[derive(Debug, Clone, PartialEq, Eq, Hash)]
450pub struct StaticDef { 284pub struct StaticDef {
451 pub(crate) syntax: SyntaxNode, 285 pub(crate) syntax: SyntaxNode,
452} 286}
453impl ast::VisibilityOwner for StaticDef {}
454impl ast::NameOwner for StaticDef {}
455impl ast::TypeParamsOwner for StaticDef {}
456impl ast::AttrsOwner for StaticDef {} 287impl ast::AttrsOwner for StaticDef {}
457impl ast::DocCommentsOwner for StaticDef {} 288impl ast::NameOwner for StaticDef {}
289impl ast::VisibilityOwner for StaticDef {}
458impl ast::TypeAscriptionOwner for StaticDef {} 290impl ast::TypeAscriptionOwner for StaticDef {}
459impl StaticDef { 291impl StaticDef {
460 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 292 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
461 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 293 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
294 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
462 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 295 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
463 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 296 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
464 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 297 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
465} 298}
466/// Type alias definition.
467/// Includes associated type clauses with type bounds.
468///
469/// ```
470/// ❰
471/// /// Docs
472/// #[attr]
473/// pub type Foo<T> where T: Debug = T;
474/// ❱
475///
476/// trait Bar {
477/// ❰ type Baz: Debug; ❱
478/// ❰ type Bruh = String; ❱
479/// ❰ type Bruuh: Debug = u32; ❱
480/// }
481/// ```
482///
483/// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
484#[derive(Debug, Clone, PartialEq, Eq, Hash)] 299#[derive(Debug, Clone, PartialEq, Eq, Hash)]
485pub struct TypeAliasDef { 300pub struct TypeAliasDef {
486 pub(crate) syntax: SyntaxNode, 301 pub(crate) syntax: SyntaxNode,
487} 302}
488impl ast::VisibilityOwner for TypeAliasDef {} 303impl ast::AttrsOwner for TypeAliasDef {}
489impl ast::NameOwner for TypeAliasDef {} 304impl ast::NameOwner for TypeAliasDef {}
305impl ast::VisibilityOwner for TypeAliasDef {}
490impl ast::TypeParamsOwner for TypeAliasDef {} 306impl ast::TypeParamsOwner for TypeAliasDef {}
491impl ast::AttrsOwner for TypeAliasDef {}
492impl ast::DocCommentsOwner for TypeAliasDef {}
493impl ast::TypeBoundsOwner for TypeAliasDef {} 307impl ast::TypeBoundsOwner for TypeAliasDef {}
494impl TypeAliasDef { 308impl TypeAliasDef {
495 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 309 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
@@ -498,46 +312,22 @@ impl TypeAliasDef {
498 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 312 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
499 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 313 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
500} 314}
501/// Inherent and trait impl definition.
502/// Includes all of its inner and outer attributes.
503///
504/// ```
505/// ❰
506/// #[attr]
507/// unsafe impl<T> const !Foo for Bar where T: Debug {
508/// #![inner_attr]
509/// // ...
510/// }
511/// ❱
512/// ```
513///
514/// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
515#[derive(Debug, Clone, PartialEq, Eq, Hash)] 315#[derive(Debug, Clone, PartialEq, Eq, Hash)]
516pub struct ImplDef { 316pub struct ImplDef {
517 pub(crate) syntax: SyntaxNode, 317 pub(crate) syntax: SyntaxNode,
518} 318}
519impl ast::TypeParamsOwner for ImplDef {}
520impl ast::AttrsOwner for ImplDef {} 319impl ast::AttrsOwner for ImplDef {}
521impl ast::DocCommentsOwner for ImplDef {} 320impl ast::VisibilityOwner for ImplDef {}
321impl ast::TypeParamsOwner for ImplDef {}
522impl ImplDef { 322impl ImplDef {
523 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
524 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 323 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
324 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
525 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 325 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
526 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 326 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
527 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 327 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
528 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 328 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
529 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 329 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
530} 330}
531/// Parenthesized type reference.
532/// Note: parens are only used for grouping, this is not a tuple type.
533///
534/// ```
535/// // This is effectively just `u32`.
536/// // Single-item tuple must be defined with a trailing comma: `(u32,)`
537/// type Foo = ❰ (u32) ❱;
538///
539/// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
540/// ```
541#[derive(Debug, Clone, PartialEq, Eq, Hash)] 331#[derive(Debug, Clone, PartialEq, Eq, Hash)]
542pub struct ParenType { 332pub struct ParenType {
543 pub(crate) syntax: SyntaxNode, 333 pub(crate) syntax: SyntaxNode,
@@ -547,13 +337,6 @@ impl ParenType {
547 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 337 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
548 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 338 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
549} 339}
550/// Unnamed tuple type.
551///
552/// ```
553/// let foo: ❰ (u32, bool) ❱ = (42, true);
554/// ```
555///
556/// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
557#[derive(Debug, Clone, PartialEq, Eq, Hash)] 340#[derive(Debug, Clone, PartialEq, Eq, Hash)]
558pub struct TupleType { 341pub struct TupleType {
559 pub(crate) syntax: SyntaxNode, 342 pub(crate) syntax: SyntaxNode,
@@ -563,17 +346,6 @@ impl TupleType {
563 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 346 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
564 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 347 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
565} 348}
566/// The never type (i.e. the exclamation point).
567///
568/// ```
569/// type T = ❰ ! ❱;
570///
571/// fn no_return() -> ❰ ! ❱ {
572/// loop {}
573/// }
574/// ```
575///
576/// [Reference](https://doc.rust-lang.org/reference/types/never.html)
577#[derive(Debug, Clone, PartialEq, Eq, Hash)] 349#[derive(Debug, Clone, PartialEq, Eq, Hash)]
578pub struct NeverType { 350pub struct NeverType {
579 pub(crate) syntax: SyntaxNode, 351 pub(crate) syntax: SyntaxNode,
@@ -581,17 +353,6 @@ pub struct NeverType {
581impl NeverType { 353impl NeverType {
582 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 354 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
583} 355}
584/// Path to a type.
585/// Includes single identifier type names and elaborate paths with
586/// generic parameters.
587///
588/// ```
589/// type Foo = ❰ String ❱;
590/// type Bar = ❰ std::vec::Vec<T> ❱;
591/// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
592/// ```
593///
594/// [Reference](https://doc.rust-lang.org/reference/paths.html)
595#[derive(Debug, Clone, PartialEq, Eq, Hash)] 356#[derive(Debug, Clone, PartialEq, Eq, Hash)]
596pub struct PathType { 357pub struct PathType {
597 pub(crate) syntax: SyntaxNode, 358 pub(crate) syntax: SyntaxNode,
@@ -599,14 +360,15 @@ pub struct PathType {
599impl PathType { 360impl PathType {
600 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 361 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
601} 362}
602/// Raw pointer type. 363#[derive(Debug, Clone, PartialEq, Eq, Hash)]
603/// 364pub struct Path {
604/// ``` 365 pub(crate) syntax: SyntaxNode,
605/// type Foo = ❰ *const u32 ❱; 366}
606/// type Bar = ❰ *mut u32 ❱; 367impl Path {
607/// ``` 368 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
608/// 369 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
609/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut) 370 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
371}
610#[derive(Debug, Clone, PartialEq, Eq, Hash)] 372#[derive(Debug, Clone, PartialEq, Eq, Hash)]
611pub struct PointerType { 373pub struct PointerType {
612 pub(crate) syntax: SyntaxNode, 374 pub(crate) syntax: SyntaxNode,
@@ -617,13 +379,6 @@ impl PointerType {
617 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 379 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
618 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 380 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
619} 381}
620/// Array type.
621///
622/// ```
623/// type Foo = ❰ [u32; 24 - 3] ❱;
624/// ```
625///
626/// [Reference](https://doc.rust-lang.org/reference/types/array.html)
627#[derive(Debug, Clone, PartialEq, Eq, Hash)] 382#[derive(Debug, Clone, PartialEq, Eq, Hash)]
628pub struct ArrayType { 383pub struct ArrayType {
629 pub(crate) syntax: SyntaxNode, 384 pub(crate) syntax: SyntaxNode,
@@ -635,13 +390,6 @@ impl ArrayType {
635 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 390 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
636 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 391 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
637} 392}
638/// Slice type.
639///
640/// ```
641/// type Foo = ❰ [u8] ❱;
642/// ```
643///
644/// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
645#[derive(Debug, Clone, PartialEq, Eq, Hash)] 393#[derive(Debug, Clone, PartialEq, Eq, Hash)]
646pub struct SliceType { 394pub struct SliceType {
647 pub(crate) syntax: SyntaxNode, 395 pub(crate) syntax: SyntaxNode,
@@ -651,13 +399,6 @@ impl SliceType {
651 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 399 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
652 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 400 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
653} 401}
654/// Reference type.
655///
656/// ```
657/// type Foo = ❰ &'static str ❱;
658/// ```
659///
660/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
661#[derive(Debug, Clone, PartialEq, Eq, Hash)] 402#[derive(Debug, Clone, PartialEq, Eq, Hash)]
662pub struct ReferenceType { 403pub struct ReferenceType {
663 pub(crate) syntax: SyntaxNode, 404 pub(crate) syntax: SyntaxNode,
@@ -670,13 +411,6 @@ impl ReferenceType {
670 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 411 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
671 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 412 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
672} 413}
673/// Placeholder type (i.e. the underscore).
674///
675/// ```
676/// let foo: ❰ _ ❱ = 42_u32;
677/// ```
678///
679/// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
680#[derive(Debug, Clone, PartialEq, Eq, Hash)] 414#[derive(Debug, Clone, PartialEq, Eq, Hash)]
681pub struct PlaceholderType { 415pub struct PlaceholderType {
682 pub(crate) syntax: SyntaxNode, 416 pub(crate) syntax: SyntaxNode,
@@ -684,15 +418,6 @@ pub struct PlaceholderType {
684impl PlaceholderType { 418impl PlaceholderType {
685 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 419 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
686} 420}
687/// Function pointer type (not to be confused with `Fn*` family of traits).
688///
689/// ```
690/// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
691///
692/// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
693/// ```
694///
695/// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
696#[derive(Debug, Clone, PartialEq, Eq, Hash)] 421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
697pub struct FnPointerType { 422pub struct FnPointerType {
698 pub(crate) syntax: SyntaxNode, 423 pub(crate) syntax: SyntaxNode,
@@ -704,13 +429,6 @@ impl FnPointerType {
704 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 429 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
705 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 430 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
706} 431}
707/// Higher order type.
708///
709/// ```
710/// type Foo = ❰ for<'a> fn(&'a str) ❱;
711/// ```
712///
713/// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
714#[derive(Debug, Clone, PartialEq, Eq, Hash)] 432#[derive(Debug, Clone, PartialEq, Eq, Hash)]
715pub struct ForType { 433pub struct ForType {
716 pub(crate) syntax: SyntaxNode, 434 pub(crate) syntax: SyntaxNode,
@@ -720,43 +438,22 @@ impl ForType {
720 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 438 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
721 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 439 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
722} 440}
723/// Opaque `impl Trait` type.
724///
725/// ```
726/// fn foo(bar: ❰ impl Debug + Eq ❱) {}
727/// ```
728///
729/// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
730#[derive(Debug, Clone, PartialEq, Eq, Hash)] 441#[derive(Debug, Clone, PartialEq, Eq, Hash)]
731pub struct ImplTraitType { 442pub struct ImplTraitType {
732 pub(crate) syntax: SyntaxNode, 443 pub(crate) syntax: SyntaxNode,
733} 444}
734impl ast::TypeBoundsOwner for ImplTraitType {}
735impl ImplTraitType { 445impl ImplTraitType {
736 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 446 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
447 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
737} 448}
738/// Trait object type.
739///
740/// ```
741/// type Foo = ❰ dyn Debug ❱;
742/// ```
743///
744/// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
745#[derive(Debug, Clone, PartialEq, Eq, Hash)] 449#[derive(Debug, Clone, PartialEq, Eq, Hash)]
746pub struct DynTraitType { 450pub struct DynTraitType {
747 pub(crate) syntax: SyntaxNode, 451 pub(crate) syntax: SyntaxNode,
748} 452}
749impl ast::TypeBoundsOwner for DynTraitType {}
750impl DynTraitType { 453impl DynTraitType {
751 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) } 454 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
455 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
752} 456}
753/// Tuple literal.
754///
755/// ```
756/// ❰ (42, true) ❱;
757/// ```
758///
759/// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
760#[derive(Debug, Clone, PartialEq, Eq, Hash)] 457#[derive(Debug, Clone, PartialEq, Eq, Hash)]
761pub struct TupleExpr { 458pub struct TupleExpr {
762 pub(crate) syntax: SyntaxNode, 459 pub(crate) syntax: SyntaxNode,
@@ -767,15 +464,6 @@ impl TupleExpr {
767 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 464 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
768 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 465 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
769} 466}
770/// Array literal.
771///
772/// ```
773/// ❰ [#![inner_attr] true, false, true] ❱;
774///
775/// ❰ ["baz"; 24] ❱;
776/// ```
777///
778/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
779#[derive(Debug, Clone, PartialEq, Eq, Hash)] 467#[derive(Debug, Clone, PartialEq, Eq, Hash)]
780pub struct ArrayExpr { 468pub struct ArrayExpr {
781 pub(crate) syntax: SyntaxNode, 469 pub(crate) syntax: SyntaxNode,
@@ -784,17 +472,10 @@ impl ast::AttrsOwner for ArrayExpr {}
784impl ArrayExpr { 472impl ArrayExpr {
785 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 473 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
786 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 474 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
475 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
787 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 476 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
788 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 477 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
789} 478}
790/// Parenthesized expression.
791/// Note: parens are only used for grouping, this is not a tuple literal.
792///
793/// ```
794/// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
795/// ```
796///
797/// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
798#[derive(Debug, Clone, PartialEq, Eq, Hash)] 479#[derive(Debug, Clone, PartialEq, Eq, Hash)]
799pub struct ParenExpr { 480pub struct ParenExpr {
800 pub(crate) syntax: SyntaxNode, 481 pub(crate) syntax: SyntaxNode,
@@ -805,19 +486,6 @@ impl ParenExpr {
805 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 486 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
806 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 487 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
807} 488}
808/// Path to a symbol in expression context.
809/// Includes single identifier variable names and elaborate paths with
810/// generic parameters.
811///
812/// ```
813/// ❰ Some::<i32> ❱;
814/// ❰ foo ❱ + 42;
815/// ❰ Vec::<i32>::push ❱;
816/// ❰ <[i32]>::reverse ❱;
817/// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
818/// ```
819///
820/// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
821#[derive(Debug, Clone, PartialEq, Eq, Hash)] 489#[derive(Debug, Clone, PartialEq, Eq, Hash)]
822pub struct PathExpr { 490pub struct PathExpr {
823 pub(crate) syntax: SyntaxNode, 491 pub(crate) syntax: SyntaxNode,
@@ -825,17 +493,6 @@ pub struct PathExpr {
825impl PathExpr { 493impl PathExpr {
826 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 494 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
827} 495}
828/// Anonymous callable object literal a.k.a. closure, lambda or functor.
829///
830/// ```
831/// ❰ || 42 ❱;
832/// ❰ |a: u32| val + 1 ❱;
833/// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
834/// ❰ move || baz ❱;
835/// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
836/// ```
837///
838/// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
839#[derive(Debug, Clone, PartialEq, Eq, Hash)] 496#[derive(Debug, Clone, PartialEq, Eq, Hash)]
840pub struct LambdaExpr { 497pub struct LambdaExpr {
841 pub(crate) syntax: SyntaxNode, 498 pub(crate) syntax: SyntaxNode,
@@ -849,25 +506,6 @@ impl LambdaExpr {
849 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 506 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
850 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 507 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
851} 508}
852/// If expression. Includes both regular `if` and `if let` forms.
853/// Beware that `else if` is a special case syntax sugar, because in general
854/// there has to be block expression after `else`.
855///
856/// ```
857/// ❰ if bool_cond { 42 } ❱
858/// ❰ if bool_cond { 42 } else { 24 } ❱
859/// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
860///
861/// ❰
862/// if let Pattern(foo) = bar {
863/// foo
864/// } else {
865/// panic!();
866/// }
867/// ❱
868/// ```
869///
870/// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
871#[derive(Debug, Clone, PartialEq, Eq, Hash)] 509#[derive(Debug, Clone, PartialEq, Eq, Hash)]
872pub struct IfExpr { 510pub struct IfExpr {
873 pub(crate) syntax: SyntaxNode, 511 pub(crate) syntax: SyntaxNode,
@@ -877,40 +515,16 @@ impl IfExpr {
877 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 515 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
878 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 516 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
879} 517}
880/// Unconditional loop expression.
881///
882/// ```
883/// ❰
884/// loop {
885/// // yeah, it's that simple...
886/// }
887/// ❱
888/// ```
889///
890/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
891#[derive(Debug, Clone, PartialEq, Eq, Hash)] 518#[derive(Debug, Clone, PartialEq, Eq, Hash)]
892pub struct LoopExpr { 519pub struct Condition {
893 pub(crate) syntax: SyntaxNode, 520 pub(crate) syntax: SyntaxNode,
894} 521}
895impl ast::AttrsOwner for LoopExpr {} 522impl Condition {
896impl ast::LoopBodyOwner for LoopExpr {} 523 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
897impl LoopExpr { 524 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
898 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) } 525 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
526 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
899} 527}
900/// Block expression with an optional prefix (label, try ketword,
901/// unsafe keyword, async keyword...).
902///
903/// ```
904/// ❰
905/// 'label: try {
906/// None?
907/// }
908/// ❱
909/// ```
910///
911/// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
912/// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
913/// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
914#[derive(Debug, Clone, PartialEq, Eq, Hash)] 528#[derive(Debug, Clone, PartialEq, Eq, Hash)]
915pub struct EffectExpr { 529pub struct EffectExpr {
916 pub(crate) syntax: SyntaxNode, 530 pub(crate) syntax: SyntaxNode,
@@ -923,19 +537,24 @@ impl EffectExpr {
923 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 537 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
924 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 538 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
925} 539}
926/// For loop expression. 540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
927/// Note: record struct literals are not valid as iterable expression 541pub struct Label {
928/// due to ambiguity. 542 pub(crate) syntax: SyntaxNode,
929/// 543}
930/// ``` 544impl Label {
931/// ❰ 545 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
932/// for i in (0..4) { 546 support::token(&self.syntax, T![lifetime])
933/// dbg!(i); 547 }
934/// } 548}
935/// ❱ 549#[derive(Debug, Clone, PartialEq, Eq, Hash)]
936/// ``` 550pub struct LoopExpr {
937/// 551 pub(crate) syntax: SyntaxNode,
938/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops) 552}
553impl ast::AttrsOwner for LoopExpr {}
554impl ast::LoopBodyOwner for LoopExpr {}
555impl LoopExpr {
556 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
557}
939#[derive(Debug, Clone, PartialEq, Eq, Hash)] 558#[derive(Debug, Clone, PartialEq, Eq, Hash)]
940pub struct ForExpr { 559pub struct ForExpr {
941 pub(crate) syntax: SyntaxNode, 560 pub(crate) syntax: SyntaxNode,
@@ -948,22 +567,6 @@ impl ForExpr {
948 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } 567 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
949 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } 568 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
950} 569}
951/// While loop expression. Includes both regular `while` and `while let` forms.
952///
953/// ```
954/// ❰
955/// while bool_cond {
956/// 42;
957/// }
958/// ❱
959/// ❰
960/// while let Pattern(foo) = bar {
961/// bar += 1;
962/// }
963/// ❱
964/// ```
965///
966/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
967#[derive(Debug, Clone, PartialEq, Eq, Hash)] 570#[derive(Debug, Clone, PartialEq, Eq, Hash)]
968pub struct WhileExpr { 571pub struct WhileExpr {
969 pub(crate) syntax: SyntaxNode, 572 pub(crate) syntax: SyntaxNode,
@@ -974,22 +577,6 @@ impl WhileExpr {
974 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) } 577 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
975 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 578 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
976} 579}
977/// Continue expression.
978///
979/// ```
980/// while bool_cond {
981/// ❰ continue ❱;
982/// }
983///
984/// 'outer: loop {
985/// loop {
986/// ❰ continue 'outer ❱;
987/// }
988/// }
989///
990/// ```
991///
992/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
993#[derive(Debug, Clone, PartialEq, Eq, Hash)] 580#[derive(Debug, Clone, PartialEq, Eq, Hash)]
994pub struct ContinueExpr { 581pub struct ContinueExpr {
995 pub(crate) syntax: SyntaxNode, 582 pub(crate) syntax: SyntaxNode,
@@ -1003,25 +590,6 @@ impl ContinueExpr {
1003 support::token(&self.syntax, T![lifetime]) 590 support::token(&self.syntax, T![lifetime])
1004 } 591 }
1005} 592}
1006/// Break expression.
1007///
1008/// ```
1009/// while bool_cond {
1010/// ❰ break ❱;
1011/// }
1012/// 'outer: loop {
1013/// for foo in bar {
1014/// ❰ break 'outer ❱;
1015/// }
1016/// }
1017/// 'outer: loop {
1018/// loop {
1019/// ❰ break 'outer 42 ❱;
1020/// }
1021/// }
1022/// ```
1023///
1024/// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1025#[derive(Debug, Clone, PartialEq, Eq, Hash)] 593#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1026pub struct BreakExpr { 594pub struct BreakExpr {
1027 pub(crate) syntax: SyntaxNode, 595 pub(crate) syntax: SyntaxNode,
@@ -1034,104 +602,33 @@ impl BreakExpr {
1034 } 602 }
1035 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 603 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1036} 604}
1037/// Label.
1038///
1039/// ```
1040/// ❰ 'outer: ❱ loop {}
1041///
1042/// let foo = ❰ 'bar: ❱ loop {}
1043///
1044/// ❰ 'baz: ❱ {
1045/// break 'baz;
1046/// }
1047/// ```
1048///
1049/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1050/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1051#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1052pub struct Label {
1053 pub(crate) syntax: SyntaxNode,
1054}
1055impl Label {
1056 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1057 support::token(&self.syntax, T![lifetime])
1058 }
1059}
1060/// Block expression. Includes unsafe blocks and block labels.
1061///
1062/// ```
1063/// let foo = ❰
1064/// {
1065/// #![inner_attr]
1066/// ❰ { } ❱
1067///
1068/// ❰ 'label: { break 'label } ❱
1069/// }
1070/// ❱;
1071/// ```
1072///
1073/// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1074/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1075#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1076pub struct BlockExpr {
1077 pub(crate) syntax: SyntaxNode,
1078}
1079impl ast::AttrsOwner for BlockExpr {}
1080impl ast::ModuleItemOwner for BlockExpr {}
1081impl BlockExpr {
1082 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1083 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1084 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1085 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1086 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1087}
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)
1099#[derive(Debug, Clone, PartialEq, Eq, Hash)] 605#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1100pub struct ReturnExpr { 606pub struct ReturnExpr {
1101 pub(crate) syntax: SyntaxNode, 607 pub(crate) syntax: SyntaxNode,
1102} 608}
1103impl ast::AttrsOwner for ReturnExpr {} 609impl ast::AttrsOwner for ReturnExpr {}
1104impl ReturnExpr { 610impl ReturnExpr {
611 pub fn return_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![return]) }
1105 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 612 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1106} 613}
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)
1117#[derive(Debug, Clone, PartialEq, Eq, Hash)] 614#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1118pub struct CallExpr { 615pub struct CallExpr {
1119 pub(crate) syntax: SyntaxNode, 616 pub(crate) syntax: SyntaxNode,
1120} 617}
618impl ast::AttrsOwner for CallExpr {}
1121impl ast::ArgListOwner for CallExpr {} 619impl ast::ArgListOwner for CallExpr {}
1122impl CallExpr { 620impl CallExpr {
1123 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 621 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1124} 622}
1125/// Method call expression. 623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1126/// 624pub struct ArgList {
1127/// ``` 625 pub(crate) syntax: SyntaxNode,
1128/// ❰ receiver_expr.method() ❱; 626}
1129/// ❰ receiver_expr.method::<T>(42, true) ❱; 627impl ArgList {
1130/// 628 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1131/// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱; 629 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
1132/// ``` 630 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1133/// 631}
1134/// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1135#[derive(Debug, Clone, PartialEq, Eq, Hash)] 632#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1136pub struct MethodCallExpr { 633pub struct MethodCallExpr {
1137 pub(crate) syntax: SyntaxNode, 634 pub(crate) syntax: SyntaxNode,
@@ -1144,31 +641,26 @@ impl MethodCallExpr {
1144 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 641 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1145 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 642 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1146} 643}
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)
1154#[derive(Debug, Clone, PartialEq, Eq, Hash)] 644#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1155pub struct IndexExpr { 645pub struct NameRef {
1156 pub(crate) syntax: SyntaxNode, 646 pub(crate) syntax: SyntaxNode,
1157} 647}
1158impl ast::AttrsOwner for IndexExpr {} 648impl NameRef {
1159impl IndexExpr { 649 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
1160 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 650}
1161 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 651#[derive(Debug, Clone, PartialEq, Eq, Hash)]
652pub struct TypeArgList {
653 pub(crate) syntax: SyntaxNode,
654}
655impl TypeArgList {
656 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
657 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
658 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
659 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
660 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
661 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
662 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1162} 663}
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)
1172#[derive(Debug, Clone, PartialEq, Eq, Hash)] 664#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1173pub struct FieldExpr { 665pub struct FieldExpr {
1174 pub(crate) syntax: SyntaxNode, 666 pub(crate) syntax: SyntaxNode,
@@ -1179,13 +671,15 @@ impl FieldExpr {
1179 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 671 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1180 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 672 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1181} 673}
1182/// Await operator call expression. 674#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1183/// 675pub struct IndexExpr {
1184/// ``` 676 pub(crate) syntax: SyntaxNode,
1185/// ❰ expr.await ❱; 677}
1186/// ``` 678impl ast::AttrsOwner for IndexExpr {}
1187/// 679impl IndexExpr {
1188/// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html) 680 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
681 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
682}
1189#[derive(Debug, Clone, PartialEq, Eq, Hash)] 683#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1190pub struct AwaitExpr { 684pub struct AwaitExpr {
1191 pub(crate) syntax: SyntaxNode, 685 pub(crate) syntax: SyntaxNode,
@@ -1196,13 +690,6 @@ impl AwaitExpr {
1196 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 690 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1197 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) } 691 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1198} 692}
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)
1206#[derive(Debug, Clone, PartialEq, Eq, Hash)] 693#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1207pub struct TryExpr { 694pub struct TryExpr {
1208 pub(crate) syntax: SyntaxNode, 695 pub(crate) syntax: SyntaxNode,
@@ -1212,13 +699,6 @@ impl TryExpr {
1212 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 699 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1213 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) } 700 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1214} 701}
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)
1222#[derive(Debug, Clone, PartialEq, Eq, Hash)] 702#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1223pub struct CastExpr { 703pub struct CastExpr {
1224 pub(crate) syntax: SyntaxNode, 704 pub(crate) syntax: SyntaxNode,
@@ -1229,16 +709,6 @@ impl CastExpr {
1229 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 709 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1230 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 710 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1231} 711}
1232/// Borrow operator call.
1233///
1234/// ```
1235/// ❰ &foo ❱;
1236/// ❰ &mut bar ❱;
1237/// ❰ &raw const bar ❱;
1238/// ❰ &raw mut bar ❱;
1239/// ```
1240///
1241/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1242#[derive(Debug, Clone, PartialEq, Eq, Hash)] 712#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1243pub struct RefExpr { 713pub struct RefExpr {
1244 pub(crate) syntax: SyntaxNode, 714 pub(crate) syntax: SyntaxNode,
@@ -1251,15 +721,6 @@ impl RefExpr {
1251 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 721 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1252 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 722 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1253} 723}
1254/// Prefix operator call. This is either `!` or `*` or `-`.
1255///
1256/// ```
1257/// ❰ !foo ❱;
1258/// ❰ *bar ❱;
1259/// ❰ -42 ❱;
1260/// ```
1261///
1262/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1263#[derive(Debug, Clone, PartialEq, Eq, Hash)] 724#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1264pub struct PrefixExpr { 725pub struct PrefixExpr {
1265 pub(crate) syntax: SyntaxNode, 726 pub(crate) syntax: SyntaxNode,
@@ -1268,13 +729,6 @@ impl ast::AttrsOwner for PrefixExpr {}
1268impl PrefixExpr { 729impl PrefixExpr {
1269 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 730 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1270} 731}
1271/// Box operator call.
1272///
1273/// ```
1274/// ❰ box 42 ❱;
1275/// ```
1276///
1277/// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1278#[derive(Debug, Clone, PartialEq, Eq, Hash)] 732#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1279pub struct BoxExpr { 733pub struct BoxExpr {
1280 pub(crate) syntax: SyntaxNode, 734 pub(crate) syntax: SyntaxNode,
@@ -1284,69 +738,23 @@ impl BoxExpr {
1284 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 738 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1285 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 739 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1286} 740}
1287/// Range operator call.
1288///
1289/// ```
1290/// ❰ 0..42 ❱;
1291/// ❰ ..42 ❱;
1292/// ❰ 0.. ❱;
1293/// ❰ .. ❱;
1294/// ❰ 0..=42 ❱;
1295/// ❰ ..=42 ❱;
1296/// ```
1297///
1298/// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1299#[derive(Debug, Clone, PartialEq, Eq, Hash)] 741#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1300pub struct RangeExpr { 742pub struct RangeExpr {
1301 pub(crate) syntax: SyntaxNode, 743 pub(crate) syntax: SyntaxNode,
1302} 744}
1303impl ast::AttrsOwner for RangeExpr {} 745impl ast::AttrsOwner for RangeExpr {}
1304impl RangeExpr {} 746impl RangeExpr {}
1305/// Binary operator call.
1306/// Includes all arithmetic, logic, bitwise and assignment operators.
1307///
1308/// ```
1309/// ❰ 2 + ❰ 2 * 2 ❱ ❱;
1310/// ❰ ❰ true && false ❱ || true ❱;
1311/// ```
1312///
1313/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1314#[derive(Debug, Clone, PartialEq, Eq, Hash)] 747#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1315pub struct BinExpr { 748pub struct BinExpr {
1316 pub(crate) syntax: SyntaxNode, 749 pub(crate) syntax: SyntaxNode,
1317} 750}
1318impl ast::AttrsOwner for BinExpr {} 751impl ast::AttrsOwner for BinExpr {}
1319impl BinExpr {} 752impl BinExpr {}
1320/// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1321///
1322/// ```
1323/// ❰ "str" ❱;
1324/// ❰ br##"raw byte str"## ❱;
1325/// ❰ 'c' ❱;
1326/// ❰ b'c' ❱;
1327/// ❰ 42 ❱;
1328/// ❰ 1e9 ❱;
1329/// ❰ true ❱;
1330/// ```
1331///
1332/// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1333#[derive(Debug, Clone, PartialEq, Eq, Hash)] 753#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1334pub struct Literal { 754pub struct Literal {
1335 pub(crate) syntax: SyntaxNode, 755 pub(crate) syntax: SyntaxNode,
1336} 756}
1337impl Literal {} 757impl Literal {}
1338/// Match expression.
1339///
1340/// ```
1341/// ❰
1342/// match expr {
1343/// Pat1 => {}
1344/// Pat2(_) => 42,
1345/// }
1346/// ❱
1347/// ```
1348///
1349/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1350#[derive(Debug, Clone, PartialEq, Eq, Hash)] 758#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1351pub struct MatchExpr { 759pub struct MatchExpr {
1352 pub(crate) syntax: SyntaxNode, 760 pub(crate) syntax: SyntaxNode,
@@ -1357,40 +765,15 @@ impl MatchExpr {
1357 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 765 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1358 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } 766 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1359} 767}
1360/// Match arm list part of match expression. Includes its inner attributes.
1361///
1362/// ```
1363/// match expr
1364/// ❰
1365/// {
1366/// #![inner_attr]
1367/// Pat1 => {}
1368/// Pat2(_) => 42,
1369/// }
1370/// ❱
1371/// ```
1372///
1373/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1374#[derive(Debug, Clone, PartialEq, Eq, Hash)] 768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1375pub struct MatchArmList { 769pub struct MatchArmList {
1376 pub(crate) syntax: SyntaxNode, 770 pub(crate) syntax: SyntaxNode,
1377} 771}
1378impl ast::AttrsOwner for MatchArmList {}
1379impl MatchArmList { 772impl MatchArmList {
1380 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 773 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1381 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } 774 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1382 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 775 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1383} 776}
1384/// Match arm.
1385/// Note: record struct literals are not valid as target match expression
1386/// due to ambiguity.
1387/// ```
1388/// match expr {
1389/// ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1390/// }
1391/// ```
1392///
1393/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1394#[derive(Debug, Clone, PartialEq, Eq, Hash)] 777#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1395pub struct MatchArm { 778pub struct MatchArm {
1396 pub(crate) syntax: SyntaxNode, 779 pub(crate) syntax: SyntaxNode,
@@ -1402,15 +785,6 @@ impl MatchArm {
1402 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) } 785 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1403 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 786 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1404} 787}
1405/// Match guard.
1406///
1407/// ```
1408/// match expr {
1409/// Pattern(it) ❰ if bool_cond ❱ => it,
1410/// }
1411/// ```
1412///
1413/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1414#[derive(Debug, Clone, PartialEq, Eq, Hash)] 788#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1415pub struct MatchGuard { 789pub struct MatchGuard {
1416 pub(crate) syntax: SyntaxNode, 790 pub(crate) syntax: SyntaxNode,
@@ -1419,21 +793,6 @@ impl MatchGuard {
1419 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 793 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1420 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 794 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1421} 795}
1422/// Record literal expression. The same syntax is used for structs,
1423/// unions and record enum variants.
1424///
1425/// ```
1426/// ❰
1427/// foo::Bar {
1428/// #![inner_attr]
1429/// baz: 42,
1430/// bruh: true,
1431/// ..spread
1432/// }
1433/// ❱
1434/// ```
1435///
1436/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1437#[derive(Debug, Clone, PartialEq, Eq, Hash)] 796#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1438pub struct RecordLit { 797pub struct RecordLit {
1439 pub(crate) syntax: SyntaxNode, 798 pub(crate) syntax: SyntaxNode,
@@ -1442,16 +801,6 @@ impl RecordLit {
1442 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 801 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1443 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } 802 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
1444} 803}
1445/// Record field list including enclosing curly braces.
1446///
1447/// foo::Bar ❰
1448/// {
1449/// baz: 42,
1450/// ..spread
1451/// }
1452/// ❱
1453///
1454/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1455#[derive(Debug, Clone, PartialEq, Eq, Hash)] 804#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1456pub struct RecordFieldList { 805pub struct RecordFieldList {
1457 pub(crate) syntax: SyntaxNode, 806 pub(crate) syntax: SyntaxNode,
@@ -1463,15 +812,6 @@ impl RecordFieldList {
1463 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } 812 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1464 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 813 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1465} 814}
1466/// Record field.
1467///
1468/// ```
1469/// foo::Bar {
1470/// ❰ #[attr] baz: 42 ❱
1471/// }
1472/// ```
1473///
1474/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1475#[derive(Debug, Clone, PartialEq, Eq, Hash)] 815#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1476pub struct RecordField { 816pub struct RecordField {
1477 pub(crate) syntax: SyntaxNode, 817 pub(crate) syntax: SyntaxNode,
@@ -1482,13 +822,6 @@ impl RecordField {
1482 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 822 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1483 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 823 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1484} 824}
1485/// Disjunction of patterns.
1486///
1487/// ```
1488/// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1489/// ```
1490///
1491/// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1492#[derive(Debug, Clone, PartialEq, Eq, Hash)] 825#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1493pub struct OrPat { 826pub struct OrPat {
1494 pub(crate) syntax: SyntaxNode, 827 pub(crate) syntax: SyntaxNode,
@@ -1496,14 +829,6 @@ pub struct OrPat {
1496impl OrPat { 829impl OrPat {
1497 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 830 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1498} 831}
1499/// Parenthesized pattern.
1500/// Note: parens are only used for grouping, this is not a tuple pattern.
1501///
1502/// ```
1503/// if let ❰ &(0..=42) ❱ = foo {}
1504/// ```
1505///
1506/// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1507#[derive(Debug, Clone, PartialEq, Eq, Hash)] 832#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1508pub struct ParenPat { 833pub struct ParenPat {
1509 pub(crate) syntax: SyntaxNode, 834 pub(crate) syntax: SyntaxNode,
@@ -1513,16 +838,6 @@ impl ParenPat {
1513 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 838 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1514 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 839 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1515} 840}
1516/// Reference pattern.
1517/// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1518///
1519/// ```
1520/// let ❰ &mut foo ❱ = bar;
1521///
1522/// let ❰ & ❰ &mut ❰ &_ ❱ ❱ ❱ = baz;
1523/// ```
1524///
1525/// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1526#[derive(Debug, Clone, PartialEq, Eq, Hash)] 841#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1527pub struct RefPat { 842pub struct RefPat {
1528 pub(crate) syntax: SyntaxNode, 843 pub(crate) syntax: SyntaxNode,
@@ -1532,31 +847,14 @@ impl RefPat {
1532 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 847 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1533 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 848 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1534} 849}
1535/// Box pattern.
1536///
1537/// ```
1538/// let ❰ box foo ❱ = box 42;
1539/// ```
1540///
1541/// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1542#[derive(Debug, Clone, PartialEq, Eq, Hash)] 850#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1543pub struct BoxPat { 851pub struct BoxPat {
1544 pub(crate) syntax: SyntaxNode, 852 pub(crate) syntax: SyntaxNode,
1545} 853}
1546impl BoxPat { 854impl BoxPat {
1547 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 855 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1548 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 856 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1549} 857}
1550/// Bind pattern.
1551///
1552/// ```
1553/// match foo {
1554/// Some(❰ ref mut bar ❱) => {}
1555/// ❰ baz @ None ❱ => {}
1556/// }
1557/// ```
1558///
1559/// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1560#[derive(Debug, Clone, PartialEq, Eq, Hash)] 858#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1561pub struct BindPat { 859pub struct BindPat {
1562 pub(crate) syntax: SyntaxNode, 860 pub(crate) syntax: SyntaxNode,
@@ -1569,13 +867,6 @@ impl BindPat {
1569 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } 867 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1570 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 868 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1571} 869}
1572/// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1573///
1574/// ```
1575/// let ❰ _ ❱ = foo;
1576/// ```
1577///
1578/// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1579#[derive(Debug, Clone, PartialEq, Eq, Hash)] 870#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1580pub struct PlaceholderPat { 871pub struct PlaceholderPat {
1581 pub(crate) syntax: SyntaxNode, 872 pub(crate) syntax: SyntaxNode,
@@ -1583,16 +874,6 @@ pub struct PlaceholderPat {
1583impl PlaceholderPat { 874impl PlaceholderPat {
1584 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 875 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1585} 876}
1586/// Rest-of-the record/tuple pattern.
1587/// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1588///
1589/// ```
1590/// let Foo { bar, ❰ .. ❱ } = baz;
1591/// let (❰ .. ❱, bruh) = (42, 24, 42);
1592/// let Bruuh(❰ .. ❱) = bruuuh;
1593/// ```
1594///
1595/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1596#[derive(Debug, Clone, PartialEq, Eq, Hash)] 877#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1597pub struct DotDotPat { 878pub struct DotDotPat {
1598 pub(crate) syntax: SyntaxNode, 879 pub(crate) syntax: SyntaxNode,
@@ -1600,15 +881,6 @@ pub struct DotDotPat {
1600impl DotDotPat { 881impl DotDotPat {
1601 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 882 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1602} 883}
1603/// Path pattern.
1604/// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1605///
1606/// ```
1607/// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1608/// if let ❰ CONST ❱ = 42 {}
1609/// ```
1610///
1611/// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1612#[derive(Debug, Clone, PartialEq, Eq, Hash)] 884#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1613pub struct PathPat { 885pub struct PathPat {
1614 pub(crate) syntax: SyntaxNode, 886 pub(crate) syntax: SyntaxNode,
@@ -1616,13 +888,6 @@ pub struct PathPat {
1616impl PathPat { 888impl PathPat {
1617 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 889 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1618} 890}
1619/// Slice pattern.
1620///
1621/// ```
1622/// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1623/// ```
1624///
1625/// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1626#[derive(Debug, Clone, PartialEq, Eq, Hash)] 891#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1627pub struct SlicePat { 892pub struct SlicePat {
1628 pub(crate) syntax: SyntaxNode, 893 pub(crate) syntax: SyntaxNode,
@@ -1632,33 +897,14 @@ impl SlicePat {
1632 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 897 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1633 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 898 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1634} 899}
1635/// Range pattern.
1636///
1637/// ```
1638/// match foo {
1639/// ❰ 0..42 ❱ => {}
1640/// ❰ 0..=42 ❱ => {}
1641/// }
1642/// ```
1643///
1644/// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1645#[derive(Debug, Clone, PartialEq, Eq, Hash)] 900#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1646pub struct RangePat { 901pub struct RangePat {
1647 pub(crate) syntax: SyntaxNode, 902 pub(crate) syntax: SyntaxNode,
1648} 903}
1649impl RangePat {} 904impl RangePat {
1650/// Literal pattern. 905 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1651/// Includes only bool, number, char, and string literals. 906 pub fn dotdoteq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..=]) }
1652/// 907}
1653/// ```
1654/// match foo {
1655/// Number(❰ 42 ❱) => {}
1656/// String(❰ "42" ❱) => {}
1657/// Bool(❰ true ❱) => {}
1658/// }
1659/// ```
1660///
1661/// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1662#[derive(Debug, Clone, PartialEq, Eq, Hash)] 908#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1663pub struct LiteralPat { 909pub struct LiteralPat {
1664 pub(crate) syntax: SyntaxNode, 910 pub(crate) syntax: SyntaxNode,
@@ -1666,13 +912,6 @@ pub struct LiteralPat {
1666impl LiteralPat { 912impl LiteralPat {
1667 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 913 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1668} 914}
1669/// Macro invocation in pattern position.
1670///
1671/// ```
1672/// let ❰ foo!(my custom syntax) ❱ = baz;
1673///
1674/// ```
1675/// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1676#[derive(Debug, Clone, PartialEq, Eq, Hash)] 915#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1677pub struct MacroPat { 916pub struct MacroPat {
1678 pub(crate) syntax: SyntaxNode, 917 pub(crate) syntax: SyntaxNode,
@@ -1680,30 +919,28 @@ pub struct MacroPat {
1680impl MacroPat { 919impl MacroPat {
1681 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } 920 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1682} 921}
1683/// Record literal pattern. 922#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1684/// 923pub struct MacroCall {
1685/// ``` 924 pub(crate) syntax: SyntaxNode,
1686/// let ❰ foo::Bar { baz, .. } ❱ = bruh; 925}
1687/// ``` 926impl ast::AttrsOwner for MacroCall {}
1688/// 927impl ast::NameOwner for MacroCall {}
1689/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns) 928impl MacroCall {
929 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
930 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
931 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
932 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
933}
1690#[derive(Debug, Clone, PartialEq, Eq, Hash)] 934#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1691pub struct RecordPat { 935pub struct RecordPat {
1692 pub(crate) syntax: SyntaxNode, 936 pub(crate) syntax: SyntaxNode,
1693} 937}
1694impl RecordPat { 938impl RecordPat {
939 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1695 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { 940 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
1696 support::child(&self.syntax) 941 support::child(&self.syntax)
1697 } 942 }
1698 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1699} 943}
1700/// Record literal's field patterns list including enclosing curly braces.
1701///
1702/// ```
1703/// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1704/// ``
1705///
1706/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1707#[derive(Debug, Clone, PartialEq, Eq, Hash)] 944#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1708pub struct RecordFieldPatList { 945pub struct RecordFieldPatList {
1709 pub(crate) syntax: SyntaxNode, 946 pub(crate) syntax: SyntaxNode,
@@ -1717,15 +954,6 @@ impl RecordFieldPatList {
1717 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 954 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1718 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 955 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1719} 956}
1720/// Record literal's field pattern.
1721/// Note: record literal can also match tuple structs.
1722///
1723/// ```
1724/// let Foo { ❰ bar: _ ❱ } = baz;
1725/// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1726/// ```
1727///
1728/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1729#[derive(Debug, Clone, PartialEq, Eq, Hash)] 957#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1730pub struct RecordFieldPat { 958pub struct RecordFieldPat {
1731 pub(crate) syntax: SyntaxNode, 959 pub(crate) syntax: SyntaxNode,
@@ -1736,13 +964,6 @@ impl RecordFieldPat {
1736 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 964 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1737 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 965 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1738} 966}
1739/// Tuple struct literal pattern.
1740///
1741/// ```
1742/// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1743/// ```
1744///
1745/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1746#[derive(Debug, Clone, PartialEq, Eq, Hash)] 967#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1747pub struct TupleStructPat { 968pub struct TupleStructPat {
1748 pub(crate) syntax: SyntaxNode, 969 pub(crate) syntax: SyntaxNode,
@@ -1753,14 +974,6 @@ impl TupleStructPat {
1753 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 974 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1754 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 975 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1755} 976}
1756/// Tuple pattern.
1757/// Note: this doesn't include tuple structs (see `TupleStructPat`)
1758///
1759/// ```
1760/// let ❰ (foo, bar, .., baz) ❱ = bruh;
1761/// ```
1762///
1763/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1764#[derive(Debug, Clone, PartialEq, Eq, Hash)] 977#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1765pub struct TuplePat { 978pub struct TuplePat {
1766 pub(crate) syntax: SyntaxNode, 979 pub(crate) syntax: SyntaxNode,
@@ -1770,209 +983,51 @@ impl TuplePat {
1770 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 983 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1771 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 984 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1772} 985}
1773/// Visibility.
1774///
1775/// ```
1776/// ❰ pub mod ❱ foo;
1777/// ❰ pub(crate) ❱ struct Bar;
1778/// ❰ pub(self) ❱ enum Baz {}
1779/// ❰ pub(super) ❱ fn bruh() {}
1780/// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1781/// ```
1782///
1783/// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1784#[derive(Debug, Clone, PartialEq, Eq, Hash)] 986#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1785pub struct Visibility { 987pub struct TokenTree {
1786 pub(crate) syntax: SyntaxNode,
1787}
1788impl Visibility {
1789 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
1790 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
1791 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1792 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1793}
1794/// Single identifier.
1795/// Note(@matklad): `Name` is for things that install a new name into the scope,
1796/// `NameRef` is a usage of a name. Most of the time, this definition/reference
1797/// distinction can be determined purely syntactically, ie in
1798/// ```
1799/// fn foo() { foo() }
1800/// ```
1801/// the first foo is `Name`, the second one is `NameRef`.
1802/// The notable exception are patterns, where in
1803/// ``
1804/// let x = 92
1805/// ```
1806/// `x` can be semantically either a name or a name ref, depeding on
1807/// wether there's an `x` constant in scope.
1808/// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1809///
1810/// ```
1811/// let ❰ foo ❱ = bar;
1812/// struct ❰ Baz ❱;
1813/// fn ❰ bruh ❱() {}
1814/// ```
1815///
1816/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1817#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1818pub struct Name {
1819 pub(crate) syntax: SyntaxNode, 988 pub(crate) syntax: SyntaxNode,
1820} 989}
1821impl Name { 990impl TokenTree {
1822 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 991 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1823} 992 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1824/// Reference to a name. 993 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1825/// See the explanation on the difference between `Name` and `NameRef` 994 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1826/// in `Name` ast node docs. 995 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1827/// 996 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1828/// ```
1829/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1830/// ```
1831///
1832/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1833#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1834pub struct NameRef {
1835 pub(crate) syntax: SyntaxNode,
1836} 997}
1837impl NameRef {}
1838/// Macro call.
1839/// Includes all of its attributes and doc comments.
1840///
1841/// ```
1842/// ❰
1843/// /// Docs
1844/// #[attr]
1845/// macro_rules! foo { // macro rules is also a macro call
1846/// ($bar: tt) => {}
1847/// }
1848/// ❱
1849///
1850/// // semicolon is a part of `MacroCall` when it is used in item positions
1851/// ❰ foo!(); ❱
1852///
1853/// fn main() {
1854/// ❰ foo!() ❱; // macro call in expression positions doesn't include the semi
1855/// }
1856/// ```
1857///
1858/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1859#[derive(Debug, Clone, PartialEq, Eq, Hash)] 998#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1860pub struct MacroCall { 999pub struct MacroDef {
1861 pub(crate) syntax: SyntaxNode, 1000 pub(crate) syntax: SyntaxNode,
1862} 1001}
1863impl ast::NameOwner for MacroCall {} 1002impl ast::NameOwner for MacroDef {}
1864impl ast::AttrsOwner for MacroCall {} 1003impl MacroDef {
1865impl ast::DocCommentsOwner for MacroCall {}
1866impl MacroCall {
1867 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1868 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1869 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 1004 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1870 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1871}
1872/// Attribute.
1873///
1874/// ```
1875/// ❰ #![inner_attr] ❱
1876///
1877/// ❰ #[attr] ❱
1878/// ❰ #[foo = "bar"] ❱
1879/// ❰ #[baz(bruh::bruuh = "42")] ❱
1880/// struct Foo;
1881/// ```
1882///
1883/// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1884#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1885pub struct Attr {
1886 pub(crate) syntax: SyntaxNode,
1887} 1005}
1888impl Attr {
1889 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1890 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1891 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1892 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1893 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1894 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1895 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1896}
1897/// Stores a list of lexer tokens and other `TokenTree`s.
1898/// It appears in attributes, macro_rules and macro call (foo!)
1899///
1900/// ```
1901/// macro_call! ❰ { my syntax here } ❱;
1902/// ```
1903///
1904/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1905#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1006#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1906pub struct TokenTree { 1007pub struct MacroItems {
1907 pub(crate) syntax: SyntaxNode, 1008 pub(crate) syntax: SyntaxNode,
1908} 1009}
1909impl TokenTree {} 1010impl ast::ModuleItemOwner for MacroItems {}
1910/// Generic lifetime, type and constants parameters list **declaration**. 1011impl MacroItems {}
1911///
1912/// ```
1913/// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1914///
1915/// struct Baz❰ <T> ❱(T);
1916///
1917/// impl❰ <T> ❱ Bruh<T> {}
1918///
1919/// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1920/// ```
1921///
1922/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1923#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1012#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1924pub struct TypeParamList { 1013pub struct MacroStmts {
1925 pub(crate) syntax: SyntaxNode, 1014 pub(crate) syntax: SyntaxNode,
1926} 1015}
1927impl TypeParamList { 1016impl MacroStmts {
1928 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } 1017 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1929 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) } 1018 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1930 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1931 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1932 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1933} 1019}
1934/// Single type parameter **declaration**.
1935///
1936/// ```
1937/// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1938/// ```
1939///
1940/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1941#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1020#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1942pub struct TypeParam { 1021pub struct TypeParam {
1943 pub(crate) syntax: SyntaxNode, 1022 pub(crate) syntax: SyntaxNode,
1944} 1023}
1945impl ast::NameOwner for TypeParam {}
1946impl ast::AttrsOwner for TypeParam {} 1024impl ast::AttrsOwner for TypeParam {}
1025impl ast::NameOwner for TypeParam {}
1947impl ast::TypeBoundsOwner for TypeParam {} 1026impl ast::TypeBoundsOwner for TypeParam {}
1948impl TypeParam { 1027impl TypeParam {
1949 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1028 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1950 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1029 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1951} 1030}
1952/// Const generic parameter **declaration**.
1953/// ```
1954/// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1955/// ```
1956///
1957/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1958#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1959pub struct ConstParam {
1960 pub(crate) syntax: SyntaxNode,
1961}
1962impl ast::NameOwner for ConstParam {}
1963impl ast::AttrsOwner for ConstParam {}
1964impl ast::TypeAscriptionOwner for ConstParam {}
1965impl ConstParam {
1966 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1967 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1968}
1969/// Lifetime parameter **declaration**.
1970///
1971/// ```
1972/// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1973/// ```
1974///
1975/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1976#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1031#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1977pub struct LifetimeParam { 1032pub struct LifetimeParam {
1978 pub(crate) syntax: SyntaxNode, 1033 pub(crate) syntax: SyntaxNode,
@@ -1983,20 +1038,19 @@ impl LifetimeParam {
1983 support::token(&self.syntax, T![lifetime]) 1038 support::token(&self.syntax, T![lifetime])
1984 } 1039 }
1985} 1040}
1986/// Type bound declaration clause. 1041#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1987/// 1042pub struct ConstParam {
1988/// ``` 1043 pub(crate) syntax: SyntaxNode,
1989/// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {} 1044}
1990/// 1045impl ast::AttrsOwner for ConstParam {}
1991/// trait Bar<T> 1046impl ast::NameOwner for ConstParam {}
1992/// where 1047impl ast::TypeAscriptionOwner for ConstParam {}
1993/// T: ❰ Send ❱ + ❰ Sync ❱ 1048impl ConstParam {
1994/// { 1049 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1995/// type Baz: ❰ !Sync ❱ + ❰ Debug ❱ + ❰ ?const Add ❱; 1050 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1996/// } 1051 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1997/// ``` 1052 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1998/// 1053}
1999/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2000#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1054#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2001pub struct TypeBound { 1055pub struct TypeBound {
2002 pub(crate) syntax: SyntaxNode, 1056 pub(crate) syntax: SyntaxNode,
@@ -2008,40 +1062,6 @@ impl TypeBound {
2008 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1062 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
2009 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1063 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2010} 1064}
2011/// Type bounds list.
2012///
2013/// ```
2014///
2015/// fn foo<T: ❰ ?Sized + Debug ❱>() {}
2016///
2017/// trait Bar<T>
2018/// where
2019/// T: ❰ Send + Sync ❱
2020/// {
2021/// type Baz: ❰ !Sync + Debug ❱;
2022/// }
2023/// ```
2024///
2025/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2026#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2027pub struct TypeBoundList {
2028 pub(crate) syntax: SyntaxNode,
2029}
2030impl TypeBoundList {
2031 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2032}
2033/// Single where predicate.
2034///
2035/// ```
2036/// trait Foo<'a, 'b, T>
2037/// where
2038/// ❰ 'a: 'b ❱,
2039/// ❰ T: IntoIterator ❱,
2040/// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
2041/// {}
2042/// ```
2043///
2044/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2045#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1065#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2046pub struct WherePred { 1066pub struct WherePred {
2047 pub(crate) syntax: SyntaxNode, 1067 pub(crate) syntax: SyntaxNode,
@@ -2055,58 +1075,6 @@ impl WherePred {
2055 } 1075 }
2056 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1076 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2057} 1077}
2058/// Where clause.
2059///
2060/// ```
2061/// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
2062///
2063/// ```
2064///
2065/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2066#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2067pub struct WhereClause {
2068 pub(crate) syntax: SyntaxNode,
2069}
2070impl WhereClause {
2071 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
2072 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2073}
2074/// Abi declaration.
2075/// Note: the abi string is optional.
2076///
2077/// ```
2078/// ❰ extern "C" ❱ {
2079/// fn foo() {}
2080/// }
2081///
2082/// type Bar = ❰ extern ❱ fn() -> u32;
2083///
2084/// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
2085/// ```
2086///
2087/// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2088/// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
2089#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2090pub struct Abi {
2091 pub(crate) syntax: SyntaxNode,
2092}
2093impl Abi {}
2094/// Expression statement.
2095///
2096/// ```
2097/// ❰ 42; ❱
2098/// ❰ foo(); ❱
2099/// ❰ (); ❱
2100/// ❰ {}; ❱
2101///
2102/// // constructions with trailing curly brace can omit the semicolon
2103/// // but only when there are satements immediately after them (this is important!)
2104/// ❰ if bool_cond { } ❱
2105/// ❰ loop {} ❱
2106/// ❰ somestatment; ❱
2107/// ```
2108///
2109/// [Reference](https://doc.rust-lang.org/reference/statements.html)
2110#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1078#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2111pub struct ExprStmt { 1079pub struct ExprStmt {
2112 pub(crate) syntax: SyntaxNode, 1080 pub(crate) syntax: SyntaxNode,
@@ -2116,16 +1084,6 @@ impl ExprStmt {
2116 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1084 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2117 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1085 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2118} 1086}
2119/// Let statement.
2120///
2121/// ```
2122/// ❰ #[attr] let foo; ❱
2123/// ❰ let bar: u64; ❱
2124/// ❰ let baz = 42; ❱
2125/// ❰ let bruh: bool = true; ❱
2126/// ```
2127///
2128/// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
2129#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1087#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2130pub struct LetStmt { 1088pub struct LetStmt {
2131 pub(crate) syntax: SyntaxNode, 1089 pub(crate) syntax: SyntaxNode,
@@ -2135,112 +1093,37 @@ impl ast::TypeAscriptionOwner for LetStmt {}
2135impl LetStmt { 1093impl LetStmt {
2136 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } 1094 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2137 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1095 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1096 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
2138 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1097 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2139 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 1098 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2140 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1099 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2141} 1100}
2142/// Condition of `if` or `while` expression.
2143///
2144/// ```
2145/// if ❰ true ❱ {}
2146/// if ❰ let Pat(foo) = bar ❱ {}
2147///
2148/// while ❰ true ❱ {}
2149/// while ❰ let Pat(baz) = bruh ❱ {}
2150/// ```
2151///
2152/// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
2153/// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
2154#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2155pub struct Condition {
2156 pub(crate) syntax: SyntaxNode,
2157}
2158impl Condition {
2159 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2160 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2161 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2162 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2163}
2164/// Parameter list **declaration**.
2165///
2166/// ```
2167/// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
2168/// let bar = ❰ |a, b| ❱ {};
2169///
2170/// impl Baz {
2171/// fn bruh❰ (&self, a: u32) ❱ {}
2172/// }
2173/// ```
2174///
2175/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
2176#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2177pub struct ParamList {
2178 pub(crate) syntax: SyntaxNode,
2179}
2180impl ParamList {
2181 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2182 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2183 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2184 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2185}
2186/// Self parameter **declaration**.
2187///
2188/// ```
2189/// impl Bruh {
2190/// fn foo(❰ self ❱) {}
2191/// fn bar(❰ &self ❱) {}
2192/// fn baz(❰ &mut self ❱) {}
2193/// fn blah<'a>(❰ &'a self ❱) {}
2194/// fn blin(❰ self: Box<Self> ❱) {}
2195/// }
2196/// ```
2197///
2198/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2199#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1101#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2200pub struct SelfParam { 1102pub struct SelfParam {
2201 pub(crate) syntax: SyntaxNode, 1103 pub(crate) syntax: SyntaxNode,
2202} 1104}
2203impl ast::TypeAscriptionOwner for SelfParam {}
2204impl ast::AttrsOwner for SelfParam {} 1105impl ast::AttrsOwner for SelfParam {}
1106impl ast::TypeAscriptionOwner for SelfParam {}
2205impl SelfParam { 1107impl SelfParam {
2206 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 1108 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2207 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2208 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1109 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2209 support::token(&self.syntax, T![lifetime]) 1110 support::token(&self.syntax, T![lifetime])
2210 } 1111 }
1112 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2211 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } 1113 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1114 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
2212} 1115}
2213/// Parameter **declaration**.
2214///
2215/// ```
2216/// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
2217///
2218/// extern "C" {
2219/// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
2220/// }
2221/// ```
2222///
2223/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2224#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2225pub struct Param { 1117pub struct Param {
2226 pub(crate) syntax: SyntaxNode, 1118 pub(crate) syntax: SyntaxNode,
2227} 1119}
2228impl ast::TypeAscriptionOwner for Param {}
2229impl ast::AttrsOwner for Param {} 1120impl ast::AttrsOwner for Param {}
1121impl ast::TypeAscriptionOwner for Param {}
2230impl Param { 1122impl Param {
2231 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1123 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1124 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
2232 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } 1125 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2233} 1126}
2234/// Use declaration.
2235///
2236/// ```
2237/// ❰ #[attr] pub use foo; ❱
2238/// ❰ use bar as baz; ❱
2239/// ❰ use bruh::{self, bruuh}; ❱
2240/// ❰ use { blin::blen, blah::* };
2241/// ```
2242///
2243/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2244#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1127#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2245pub struct UseItem { 1128pub struct UseItem {
2246 pub(crate) syntax: SyntaxNode, 1129 pub(crate) syntax: SyntaxNode,
@@ -2250,53 +1133,19 @@ impl ast::VisibilityOwner for UseItem {}
2250impl UseItem { 1133impl UseItem {
2251 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) } 1134 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2252 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } 1135 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
1136 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2253} 1137}
2254/// Use tree.
2255///
2256/// ```
2257/// pub use ❰ foo::❰ * ❱ ❱;
2258/// use ❰ bar as baz ❱;
2259/// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
2260/// use ❰ { ❰ blin::blen ❱ } ❱
2261/// ```
2262///
2263/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2264#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1138#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2265pub struct UseTree { 1139pub struct UseTree {
2266 pub(crate) syntax: SyntaxNode, 1140 pub(crate) syntax: SyntaxNode,
2267} 1141}
2268impl UseTree { 1142impl UseTree {
2269 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1143 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1144 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2270 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 1145 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2271 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } 1146 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2272 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 1147 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2273} 1148}
2274/// Item alias.
2275/// Note: this is not the type alias.
2276///
2277/// ```
2278/// use foo ❰ as bar ❱;
2279/// use baz::{bruh ❰ as _ ❱};
2280/// extern crate bruuh ❰ as blin ❱;
2281/// ```
2282///
2283/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2285pub struct Alias {
2286 pub(crate) syntax: SyntaxNode,
2287}
2288impl ast::NameOwner for Alias {}
2289impl Alias {
2290 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2291}
2292/// Sublist of use trees.
2293///
2294/// ```
2295/// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
2296/// use ❰ { blin::blen::❰ {} ❱ } ❱
2297/// ```
2298///
2299/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2300#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1149#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2301pub struct UseTreeList { 1150pub struct UseTreeList {
2302 pub(crate) syntax: SyntaxNode, 1151 pub(crate) syntax: SyntaxNode,
@@ -2306,14 +1155,14 @@ impl UseTreeList {
2306 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) } 1155 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2307 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 1156 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2308} 1157}
2309/// Extern crate item. 1158#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2310/// 1159pub struct Alias {
2311/// ``` 1160 pub(crate) syntax: SyntaxNode,
2312/// ❰ #[attr] pub extern crate foo; ❱ 1161}
2313/// ❰ extern crate self as bar; ❱ 1162impl ast::NameOwner for Alias {}
2314/// ``` 1163impl Alias {
2315/// 1164 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2316/// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html) 1165}
2317#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1166#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2318pub struct ExternCrateItem { 1167pub struct ExternCrateItem {
2319 pub(crate) syntax: SyntaxNode, 1168 pub(crate) syntax: SyntaxNode,
@@ -2324,59 +1173,10 @@ impl ExternCrateItem {
2324 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } 1173 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2325 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } 1174 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2326 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1175 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1176 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2327 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 1177 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
1178 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2328} 1179}
2329/// Call site arguments list.
2330///
2331/// ```
2332/// foo::<T, U>❰ (42, true) ❱;
2333/// ```
2334///
2335/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
2336#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2337pub struct ArgList {
2338 pub(crate) syntax: SyntaxNode,
2339}
2340impl ArgList {
2341 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2342 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2343 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2344}
2345/// Path to a symbol. Includes single identifier names and elaborate paths with
2346/// generic parameters.
2347///
2348/// ```
2349/// (0..10).❰ ❰ collect ❱ ::<Vec<_>> ❱();
2350/// ❰ ❰ ❰ Vec ❱ ::<u8> ❱ ::with_capacity ❱(1024);
2351/// ❰ ❰ <❰ Foo ❱ as ❰ ❰ bar ❱ ::Bar ❱> ❱ ::baz ❱();
2352/// ❰ ❰ <❰ bruh ❱> ❱ ::bruuh ❱();
2353/// ```
2354///
2355/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2356#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2357pub struct Path {
2358 pub(crate) syntax: SyntaxNode,
2359}
2360impl Path {
2361 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2362 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2363 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2364}
2365/// Segment of the path to a symbol.
2366/// Only path segment of an absolute path holds the `::` token,
2367/// all other `::` tokens that connect path segments reside under `Path` itself.`
2368///
2369/// ```
2370/// (0..10).❰ collect ❱ :: ❰ <Vec<_>> ❱();
2371/// ❰ Vec ❱ :: ❰ <u8> ❱ :: ❰ with_capacity ❱(1024);
2372/// ❰ <❰ Foo ❱ as ❰ bar ❱ :: ❰ Bar ❱> ❱ :: ❰ baz ❱();
2373/// ❰ <❰ bruh ❱> ❱ :: ❰ bruuh ❱();
2374///
2375/// // Note that only in this case `::` token is inlcuded:
2376/// ❰ ::foo ❱;
2377/// ```
2378///
2379/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2380#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1180#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2381pub struct PathSegment { 1181pub struct PathSegment {
2382 pub(crate) syntax: SyntaxNode, 1182 pub(crate) syntax: SyntaxNode,
@@ -2394,50 +1194,22 @@ impl PathSegment {
2394 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } 1194 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2395 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } 1195 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2396} 1196}
2397/// List of type arguments that are passed at generic instantiation site.
2398///
2399/// ```
2400/// type _ = Foo ❰ ::<'a, u64, Item = Bar, 42, {true}> ❱::Bar;
2401///
2402/// Vec❰ ::<bool> ❱::();
2403/// ```
2404///
2405/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2406#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1197#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2407pub struct TypeArgList { 1198pub struct TypeArg {
2408 pub(crate) syntax: SyntaxNode, 1199 pub(crate) syntax: SyntaxNode,
2409} 1200}
2410impl TypeArgList { 1201impl TypeArg {
2411 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 1202 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2412 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2413 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2414 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2415 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2416 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2417 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2418 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2419} 1203}
2420/// Type argument that is passed at generic instantiation site.
2421///
2422/// ```
2423/// type _ = Foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::Baz;
2424/// ```
2425///
2426/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2427#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1204#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2428pub struct TypeArg { 1205pub struct LifetimeArg {
2429 pub(crate) syntax: SyntaxNode, 1206 pub(crate) syntax: SyntaxNode,
2430} 1207}
2431impl TypeArg { 1208impl LifetimeArg {
2432 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1209 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1210 support::token(&self.syntax, T![lifetime])
1211 }
2433} 1212}
2434/// Associated type argument that is passed at generic instantiation site.
2435/// ```
2436/// type Foo = Bar::<'a, u64, bool, ❰ Item = Baz ❱, 42>::Bruh;
2437///
2438/// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
2439/// ```
2440///
2441#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1213#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2442pub struct AssocTypeArg { 1214pub struct AssocTypeArg {
2443 pub(crate) syntax: SyntaxNode, 1215 pub(crate) syntax: SyntaxNode,
@@ -2448,33 +1220,6 @@ impl AssocTypeArg {
2448 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1220 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2449 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1221 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2450} 1222}
2451/// Lifetime argument that is passed at generic instantiation site.
2452///
2453/// ```
2454/// fn foo<'a>(s: &'a str) {
2455/// bar::<❰ 'a ❱>(s);
2456/// }
2457/// ```
2458///
2459/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2460#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2461pub struct LifetimeArg {
2462 pub(crate) syntax: SyntaxNode,
2463}
2464impl LifetimeArg {
2465 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2466 support::token(&self.syntax, T![lifetime])
2467 }
2468}
2469/// Constant value argument that is passed at generic instantiation site.
2470///
2471/// ```
2472/// foo::<u32, ❰ { true } ❱>();
2473///
2474/// bar::<❰ { 2 + 2} ❱>();
2475/// ```
2476///
2477/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
2478#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1223#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2479pub struct ConstArg { 1224pub struct ConstArg {
2480 pub(crate) syntax: SyntaxNode, 1225 pub(crate) syntax: SyntaxNode,
@@ -2483,83 +1228,24 @@ impl ConstArg {
2483 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1228 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2484 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 1229 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2485} 1230}
2486/// FIXME: (@edwin0cheng) Remove it to use ItemList instead
2487/// https://github.com/rust-analyzer/rust-analyzer/pull/4083#discussion_r422666243
2488///
2489/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2490#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2491pub struct MacroItems {
2492 pub(crate) syntax: SyntaxNode,
2493}
2494impl ast::ModuleItemOwner for MacroItems {}
2495impl MacroItems {}
2496/// FIXME: (@edwin0cheng) add some documentation here. As per the writing
2497/// of this comment this ast node is not used.
2498///
2499/// ```
2500/// // FIXME: example here
2501/// ```
2502///
2503/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2504#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1231#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2505pub struct MacroStmts { 1232pub struct ExternBlock {
2506 pub(crate) syntax: SyntaxNode, 1233 pub(crate) syntax: SyntaxNode,
2507} 1234}
2508impl MacroStmts { 1235impl ast::AttrsOwner for ExternBlock {}
2509 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } 1236impl ExternBlock {
2510 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1237 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
1238 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2511} 1239}
2512/// List of items in an extern block.
2513///
2514/// ```
2515/// extern "C" ❰
2516/// {
2517/// fn foo();
2518/// static var: u32;
2519/// }
2520/// ❱
2521/// ```
2522///
2523/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2524#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1240#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2525pub struct ExternItemList { 1241pub struct ExternItemList {
2526 pub(crate) syntax: SyntaxNode, 1242 pub(crate) syntax: SyntaxNode,
2527} 1243}
2528impl ast::ModuleItemOwner for ExternItemList {}
2529impl ExternItemList { 1244impl ExternItemList {
2530 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 1245 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2531 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } 1246 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2532 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 1247 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2533} 1248}
2534/// Extern block.
2535///
2536/// ```
2537/// ❰
2538/// extern "C" {
2539/// fn foo();
2540/// }
2541/// ❱
2542///
2543/// ```
2544///
2545/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2546#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2547pub struct ExternBlock {
2548 pub(crate) syntax: SyntaxNode,
2549}
2550impl ExternBlock {
2551 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2552 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2553}
2554/// Meta item in an attribute.
2555///
2556/// ```
2557/// #[❰ bar::baz = "42" ❱]
2558/// #[❰ bruh(bruuh("true")) ❱]
2559/// struct Foo;
2560/// ```
2561///
2562/// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2563#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1249#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2564pub struct MetaItem { 1250pub struct MetaItem {
2565 pub(crate) syntax: SyntaxNode, 1251 pub(crate) syntax: SyntaxNode,
@@ -2570,59 +1256,6 @@ impl MetaItem {
2570 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } 1256 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2571 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } 1257 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2572} 1258}
2573/// Macro 2.0 definition.
2574/// Their syntax is still WIP by rustc team...
2575/// ```
2576/// ❰
2577/// macro foo { }
2578/// ❱
2579/// ```
2580///
2581/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md)
2582#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2583pub struct MacroDef {
2584 pub(crate) syntax: SyntaxNode,
2585}
2586impl MacroDef {
2587 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2588 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2589}
2590/// Any kind of nominal type definition.
2591#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2592pub enum NominalDef {
2593 StructDef(StructDef),
2594 EnumDef(EnumDef),
2595 UnionDef(UnionDef),
2596}
2597impl ast::NameOwner for NominalDef {}
2598impl ast::TypeParamsOwner for NominalDef {}
2599impl ast::AttrsOwner for NominalDef {}
2600/// Any kind of generic argument passed at instantiation site
2601#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2602pub enum GenericArg {
2603 LifetimeArg(LifetimeArg),
2604 TypeArg(TypeArg),
2605 ConstArg(ConstArg),
2606 AssocTypeArg(AssocTypeArg),
2607}
2608/// Any kind of construct valid in type context
2609#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2610pub enum TypeRef {
2611 ParenType(ParenType),
2612 TupleType(TupleType),
2613 NeverType(NeverType),
2614 PathType(PathType),
2615 PointerType(PointerType),
2616 ArrayType(ArrayType),
2617 SliceType(SliceType),
2618 ReferenceType(ReferenceType),
2619 PlaceholderType(PlaceholderType),
2620 FnPointerType(FnPointerType),
2621 ForType(ForType),
2622 ImplTraitType(ImplTraitType),
2623 DynTraitType(DynTraitType),
2624}
2625/// Any kind of top-level item that may appear in a module
2626#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1259#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2627pub enum ModuleItem { 1260pub enum ModuleItem {
2628 StructDef(StructDef), 1261 StructDef(StructDef),
@@ -2640,32 +1273,28 @@ pub enum ModuleItem {
2640 MacroCall(MacroCall), 1273 MacroCall(MacroCall),
2641 ExternBlock(ExternBlock), 1274 ExternBlock(ExternBlock),
2642} 1275}
2643impl ast::NameOwner for ModuleItem {}
2644impl ast::AttrsOwner for ModuleItem {} 1276impl ast::AttrsOwner for ModuleItem {}
2645impl ast::VisibilityOwner for ModuleItem {}
2646/// Any kind of item that may appear in an impl block
2647///
2648/// // FIXME: impl blocks can also contain MacroCall
2649#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1277#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2650pub enum AssocItem { 1278pub enum TypeRef {
2651 FnDef(FnDef), 1279 ParenType(ParenType),
2652 TypeAliasDef(TypeAliasDef), 1280 TupleType(TupleType),
2653 ConstDef(ConstDef), 1281 NeverType(NeverType),
1282 PathType(PathType),
1283 PointerType(PointerType),
1284 ArrayType(ArrayType),
1285 SliceType(SliceType),
1286 ReferenceType(ReferenceType),
1287 PlaceholderType(PlaceholderType),
1288 FnPointerType(FnPointerType),
1289 ForType(ForType),
1290 ImplTraitType(ImplTraitType),
1291 DynTraitType(DynTraitType),
2654} 1292}
2655impl ast::NameOwner for AssocItem {}
2656impl ast::AttrsOwner for AssocItem {}
2657/// Any kind of item that may appear in an extern block
2658///
2659/// // FIXME: extern blocks can also contain MacroCall
2660#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1293#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2661pub enum ExternItem { 1294pub enum FieldDefList {
2662 FnDef(FnDef), 1295 RecordFieldDefList(RecordFieldDefList),
2663 StaticDef(StaticDef), 1296 TupleFieldDefList(TupleFieldDefList),
2664} 1297}
2665impl ast::NameOwner for ExternItem {}
2666impl ast::AttrsOwner for ExternItem {}
2667impl ast::VisibilityOwner for ExternItem {}
2668/// Any kind of expression
2669#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1298#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2670pub enum Expr { 1299pub enum Expr {
2671 TupleExpr(TupleExpr), 1300 TupleExpr(TupleExpr),
@@ -2700,8 +1329,15 @@ pub enum Expr {
2700 MacroCall(MacroCall), 1329 MacroCall(MacroCall),
2701 BoxExpr(BoxExpr), 1330 BoxExpr(BoxExpr),
2702} 1331}
2703impl ast::AttrsOwner for Expr {} 1332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2704/// Any kind of pattern 1333pub enum AssocItem {
1334 FnDef(FnDef),
1335 TypeAliasDef(TypeAliasDef),
1336 ConstDef(ConstDef),
1337}
1338impl ast::AttrsOwner for AssocItem {}
1339impl ast::NameOwner for AssocItem {}
1340impl ast::VisibilityOwner for AssocItem {}
2705#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1341#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2706pub enum Pat { 1342pub enum Pat {
2707 OrPat(OrPat), 1343 OrPat(OrPat),
@@ -2720,26 +1356,35 @@ pub enum Pat {
2720 LiteralPat(LiteralPat), 1356 LiteralPat(LiteralPat),
2721 MacroPat(MacroPat), 1357 MacroPat(MacroPat),
2722} 1358}
2723/// Any kind of input to an attribute 1359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1360pub enum Stmt {
1361 LetStmt(LetStmt),
1362 ExprStmt(ExprStmt),
1363}
1364impl ast::AttrsOwner for Stmt {}
2724#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1365#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2725pub enum AttrInput { 1366pub enum AttrInput {
2726 Literal(Literal), 1367 Literal(Literal),
2727 TokenTree(TokenTree), 1368 TokenTree(TokenTree),
2728} 1369}
2729/// Any kind of statement
2730/// Note: there are no empty statements, these are just represented as
2731/// bare semicolons without a dedicated statement ast node.
2732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1370#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2733pub enum Stmt { 1371pub enum ExternItem {
2734 LetStmt(LetStmt), 1372 FnDef(FnDef),
2735 ExprStmt(ExprStmt), 1373 StaticDef(StaticDef),
2736} 1374}
2737/// Any kind of fields list (record or tuple field lists) 1375impl ast::AttrsOwner for ExternItem {}
1376impl ast::NameOwner for ExternItem {}
1377impl ast::VisibilityOwner for ExternItem {}
2738#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1378#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2739pub enum FieldDefList { 1379pub enum NominalDef {
2740 RecordFieldDefList(RecordFieldDefList), 1380 StructDef(StructDef),
2741 TupleFieldDefList(TupleFieldDefList), 1381 EnumDef(EnumDef),
1382 UnionDef(UnionDef),
2742} 1383}
1384impl ast::AttrsOwner for NominalDef {}
1385impl ast::NameOwner for NominalDef {}
1386impl ast::TypeParamsOwner for NominalDef {}
1387impl ast::VisibilityOwner for NominalDef {}
2743impl AstNode for SourceFile { 1388impl AstNode for SourceFile {
2744 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1389 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
2745 fn cast(syntax: SyntaxNode) -> Option<Self> { 1390 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2751,6 +1396,17 @@ impl AstNode for SourceFile {
2751 } 1396 }
2752 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1397 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2753} 1398}
1399impl AstNode for Attr {
1400 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
1401 fn cast(syntax: SyntaxNode) -> Option<Self> {
1402 if Self::can_cast(syntax.kind()) {
1403 Some(Self { syntax })
1404 } else {
1405 None
1406 }
1407 }
1408 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1409}
2754impl AstNode for FnDef { 1410impl AstNode for FnDef {
2755 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } 1411 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
2756 fn cast(syntax: SyntaxNode) -> Option<Self> { 1412 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2762,6 +1418,61 @@ impl AstNode for FnDef {
2762 } 1418 }
2763 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1419 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2764} 1420}
1421impl AstNode for Visibility {
1422 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
1423 fn cast(syntax: SyntaxNode) -> Option<Self> {
1424 if Self::can_cast(syntax.kind()) {
1425 Some(Self { syntax })
1426 } else {
1427 None
1428 }
1429 }
1430 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1431}
1432impl AstNode for Abi {
1433 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
1434 fn cast(syntax: SyntaxNode) -> Option<Self> {
1435 if Self::can_cast(syntax.kind()) {
1436 Some(Self { syntax })
1437 } else {
1438 None
1439 }
1440 }
1441 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1442}
1443impl AstNode for Name {
1444 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
1445 fn cast(syntax: SyntaxNode) -> Option<Self> {
1446 if Self::can_cast(syntax.kind()) {
1447 Some(Self { syntax })
1448 } else {
1449 None
1450 }
1451 }
1452 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1453}
1454impl AstNode for TypeParamList {
1455 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST }
1456 fn cast(syntax: SyntaxNode) -> Option<Self> {
1457 if Self::can_cast(syntax.kind()) {
1458 Some(Self { syntax })
1459 } else {
1460 None
1461 }
1462 }
1463 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1464}
1465impl AstNode for ParamList {
1466 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
1467 fn cast(syntax: SyntaxNode) -> Option<Self> {
1468 if Self::can_cast(syntax.kind()) {
1469 Some(Self { syntax })
1470 } else {
1471 None
1472 }
1473 }
1474 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1475}
2765impl AstNode for RetType { 1476impl AstNode for RetType {
2766 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } 1477 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
2767 fn cast(syntax: SyntaxNode) -> Option<Self> { 1478 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2773,8 +1484,8 @@ impl AstNode for RetType {
2773 } 1484 }
2774 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1485 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2775} 1486}
2776impl AstNode for StructDef { 1487impl AstNode for WhereClause {
2777 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } 1488 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
2778 fn cast(syntax: SyntaxNode) -> Option<Self> { 1489 fn cast(syntax: SyntaxNode) -> Option<Self> {
2779 if Self::can_cast(syntax.kind()) { 1490 if Self::can_cast(syntax.kind()) {
2780 Some(Self { syntax }) 1491 Some(Self { syntax })
@@ -2784,8 +1495,8 @@ impl AstNode for StructDef {
2784 } 1495 }
2785 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1496 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2786} 1497}
2787impl AstNode for UnionDef { 1498impl AstNode for BlockExpr {
2788 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } 1499 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
2789 fn cast(syntax: SyntaxNode) -> Option<Self> { 1500 fn cast(syntax: SyntaxNode) -> Option<Self> {
2790 if Self::can_cast(syntax.kind()) { 1501 if Self::can_cast(syntax.kind()) {
2791 Some(Self { syntax }) 1502 Some(Self { syntax })
@@ -2795,8 +1506,8 @@ impl AstNode for UnionDef {
2795 } 1506 }
2796 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1507 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2797} 1508}
2798impl AstNode for RecordFieldDefList { 1509impl AstNode for StructDef {
2799 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } 1510 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
2800 fn cast(syntax: SyntaxNode) -> Option<Self> { 1511 fn cast(syntax: SyntaxNode) -> Option<Self> {
2801 if Self::can_cast(syntax.kind()) { 1512 if Self::can_cast(syntax.kind()) {
2802 Some(Self { syntax }) 1513 Some(Self { syntax })
@@ -2806,8 +1517,8 @@ impl AstNode for RecordFieldDefList {
2806 } 1517 }
2807 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1518 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2808} 1519}
2809impl AstNode for RecordFieldDef { 1520impl AstNode for RecordFieldDefList {
2810 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } 1521 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
2811 fn cast(syntax: SyntaxNode) -> Option<Self> { 1522 fn cast(syntax: SyntaxNode) -> Option<Self> {
2812 if Self::can_cast(syntax.kind()) { 1523 if Self::can_cast(syntax.kind()) {
2813 Some(Self { syntax }) 1524 Some(Self { syntax })
@@ -2828,6 +1539,28 @@ impl AstNode for TupleFieldDefList {
2828 } 1539 }
2829 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1540 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2830} 1541}
1542impl AstNode for UnionDef {
1543 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
1544 fn cast(syntax: SyntaxNode) -> Option<Self> {
1545 if Self::can_cast(syntax.kind()) {
1546 Some(Self { syntax })
1547 } else {
1548 None
1549 }
1550 }
1551 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1552}
1553impl AstNode for RecordFieldDef {
1554 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
1555 fn cast(syntax: SyntaxNode) -> Option<Self> {
1556 if Self::can_cast(syntax.kind()) {
1557 Some(Self { syntax })
1558 } else {
1559 None
1560 }
1561 }
1562 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1563}
2831impl AstNode for TupleFieldDef { 1564impl AstNode for TupleFieldDef {
2832 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } 1565 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
2833 fn cast(syntax: SyntaxNode) -> Option<Self> { 1566 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2883,8 +1616,8 @@ impl AstNode for TraitDef {
2883 } 1616 }
2884 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1617 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2885} 1618}
2886impl AstNode for Module { 1619impl AstNode for TypeBoundList {
2887 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } 1620 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
2888 fn cast(syntax: SyntaxNode) -> Option<Self> { 1621 fn cast(syntax: SyntaxNode) -> Option<Self> {
2889 if Self::can_cast(syntax.kind()) { 1622 if Self::can_cast(syntax.kind()) {
2890 Some(Self { syntax }) 1623 Some(Self { syntax })
@@ -2905,6 +1638,17 @@ impl AstNode for ItemList {
2905 } 1638 }
2906 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1639 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2907} 1640}
1641impl AstNode for Module {
1642 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
1643 fn cast(syntax: SyntaxNode) -> Option<Self> {
1644 if Self::can_cast(syntax.kind()) {
1645 Some(Self { syntax })
1646 } else {
1647 None
1648 }
1649 }
1650 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1651}
2908impl AstNode for ConstDef { 1652impl AstNode for ConstDef {
2909 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } 1653 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
2910 fn cast(syntax: SyntaxNode) -> Option<Self> { 1654 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2993,6 +1737,17 @@ impl AstNode for PathType {
2993 } 1737 }
2994 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1738 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2995} 1739}
1740impl AstNode for Path {
1741 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
1742 fn cast(syntax: SyntaxNode) -> Option<Self> {
1743 if Self::can_cast(syntax.kind()) {
1744 Some(Self { syntax })
1745 } else {
1746 None
1747 }
1748 }
1749 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1750}
2996impl AstNode for PointerType { 1751impl AstNode for PointerType {
2997 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } 1752 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
2998 fn cast(syntax: SyntaxNode) -> Option<Self> { 1753 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3158,8 +1913,8 @@ impl AstNode for IfExpr {
3158 } 1913 }
3159 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1914 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3160} 1915}
3161impl AstNode for LoopExpr { 1916impl AstNode for Condition {
3162 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } 1917 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
3163 fn cast(syntax: SyntaxNode) -> Option<Self> { 1918 fn cast(syntax: SyntaxNode) -> Option<Self> {
3164 if Self::can_cast(syntax.kind()) { 1919 if Self::can_cast(syntax.kind()) {
3165 Some(Self { syntax }) 1920 Some(Self { syntax })
@@ -3180,6 +1935,28 @@ impl AstNode for EffectExpr {
3180 } 1935 }
3181 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1936 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3182} 1937}
1938impl AstNode for Label {
1939 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
1940 fn cast(syntax: SyntaxNode) -> Option<Self> {
1941 if Self::can_cast(syntax.kind()) {
1942 Some(Self { syntax })
1943 } else {
1944 None
1945 }
1946 }
1947 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1948}
1949impl AstNode for LoopExpr {
1950 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
1951 fn cast(syntax: SyntaxNode) -> Option<Self> {
1952 if Self::can_cast(syntax.kind()) {
1953 Some(Self { syntax })
1954 } else {
1955 None
1956 }
1957 }
1958 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1959}
3183impl AstNode for ForExpr { 1960impl AstNode for ForExpr {
3184 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } 1961 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR }
3185 fn cast(syntax: SyntaxNode) -> Option<Self> { 1962 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3224,8 +2001,8 @@ impl AstNode for BreakExpr {
3224 } 2001 }
3225 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2002 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3226} 2003}
3227impl AstNode for Label { 2004impl AstNode for ReturnExpr {
3228 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } 2005 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR }
3229 fn cast(syntax: SyntaxNode) -> Option<Self> { 2006 fn cast(syntax: SyntaxNode) -> Option<Self> {
3230 if Self::can_cast(syntax.kind()) { 2007 if Self::can_cast(syntax.kind()) {
3231 Some(Self { syntax }) 2008 Some(Self { syntax })
@@ -3235,8 +2012,8 @@ impl AstNode for Label {
3235 } 2012 }
3236 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2013 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3237} 2014}
3238impl AstNode for BlockExpr { 2015impl AstNode for CallExpr {
3239 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } 2016 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR }
3240 fn cast(syntax: SyntaxNode) -> Option<Self> { 2017 fn cast(syntax: SyntaxNode) -> Option<Self> {
3241 if Self::can_cast(syntax.kind()) { 2018 if Self::can_cast(syntax.kind()) {
3242 Some(Self { syntax }) 2019 Some(Self { syntax })
@@ -3246,8 +2023,8 @@ impl AstNode for BlockExpr {
3246 } 2023 }
3247 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2024 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3248} 2025}
3249impl AstNode for ReturnExpr { 2026impl AstNode for ArgList {
3250 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR } 2027 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
3251 fn cast(syntax: SyntaxNode) -> Option<Self> { 2028 fn cast(syntax: SyntaxNode) -> Option<Self> {
3252 if Self::can_cast(syntax.kind()) { 2029 if Self::can_cast(syntax.kind()) {
3253 Some(Self { syntax }) 2030 Some(Self { syntax })
@@ -3257,8 +2034,8 @@ impl AstNode for ReturnExpr {
3257 } 2034 }
3258 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2035 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3259} 2036}
3260impl AstNode for CallExpr { 2037impl AstNode for MethodCallExpr {
3261 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR } 2038 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR }
3262 fn cast(syntax: SyntaxNode) -> Option<Self> { 2039 fn cast(syntax: SyntaxNode) -> Option<Self> {
3263 if Self::can_cast(syntax.kind()) { 2040 if Self::can_cast(syntax.kind()) {
3264 Some(Self { syntax }) 2041 Some(Self { syntax })
@@ -3268,8 +2045,8 @@ impl AstNode for CallExpr {
3268 } 2045 }
3269 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2046 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3270} 2047}
3271impl AstNode for MethodCallExpr { 2048impl AstNode for NameRef {
3272 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR } 2049 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
3273 fn cast(syntax: SyntaxNode) -> Option<Self> { 2050 fn cast(syntax: SyntaxNode) -> Option<Self> {
3274 if Self::can_cast(syntax.kind()) { 2051 if Self::can_cast(syntax.kind()) {
3275 Some(Self { syntax }) 2052 Some(Self { syntax })
@@ -3279,8 +2056,8 @@ impl AstNode for MethodCallExpr {
3279 } 2056 }
3280 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2057 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3281} 2058}
3282impl AstNode for IndexExpr { 2059impl AstNode for TypeArgList {
3283 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR } 2060 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST }
3284 fn cast(syntax: SyntaxNode) -> Option<Self> { 2061 fn cast(syntax: SyntaxNode) -> Option<Self> {
3285 if Self::can_cast(syntax.kind()) { 2062 if Self::can_cast(syntax.kind()) {
3286 Some(Self { syntax }) 2063 Some(Self { syntax })
@@ -3301,6 +2078,17 @@ impl AstNode for FieldExpr {
3301 } 2078 }
3302 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2079 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3303} 2080}
2081impl AstNode for IndexExpr {
2082 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR }
2083 fn cast(syntax: SyntaxNode) -> Option<Self> {
2084 if Self::can_cast(syntax.kind()) {
2085 Some(Self { syntax })
2086 } else {
2087 None
2088 }
2089 }
2090 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2091}
3304impl AstNode for AwaitExpr { 2092impl AstNode for AwaitExpr {
3305 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR } 2093 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
3306 fn cast(syntax: SyntaxNode) -> Option<Self> { 2094 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3609,6 +2397,17 @@ impl AstNode for MacroPat {
3609 } 2397 }
3610 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2398 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3611} 2399}
2400impl AstNode for MacroCall {
2401 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
2402 fn cast(syntax: SyntaxNode) -> Option<Self> {
2403 if Self::can_cast(syntax.kind()) {
2404 Some(Self { syntax })
2405 } else {
2406 None
2407 }
2408 }
2409 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2410}
3612impl AstNode for RecordPat { 2411impl AstNode for RecordPat {
3613 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } 2412 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
3614 fn cast(syntax: SyntaxNode) -> Option<Self> { 2413 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3664,41 +2463,8 @@ impl AstNode for TuplePat {
3664 } 2463 }
3665 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2464 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3666} 2465}
3667impl AstNode for Visibility { 2466impl AstNode for TokenTree {
3668 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } 2467 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
3669 fn cast(syntax: SyntaxNode) -> Option<Self> {
3670 if Self::can_cast(syntax.kind()) {
3671 Some(Self { syntax })
3672 } else {
3673 None
3674 }
3675 }
3676 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3677}
3678impl AstNode for Name {
3679 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
3680 fn cast(syntax: SyntaxNode) -> Option<Self> {
3681 if Self::can_cast(syntax.kind()) {
3682 Some(Self { syntax })
3683 } else {
3684 None
3685 }
3686 }
3687 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3688}
3689impl AstNode for NameRef {
3690 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
3691 fn cast(syntax: SyntaxNode) -> Option<Self> {
3692 if Self::can_cast(syntax.kind()) {
3693 Some(Self { syntax })
3694 } else {
3695 None
3696 }
3697 }
3698 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3699}
3700impl AstNode for MacroCall {
3701 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
3702 fn cast(syntax: SyntaxNode) -> Option<Self> { 2468 fn cast(syntax: SyntaxNode) -> Option<Self> {
3703 if Self::can_cast(syntax.kind()) { 2469 if Self::can_cast(syntax.kind()) {
3704 Some(Self { syntax }) 2470 Some(Self { syntax })
@@ -3708,8 +2474,8 @@ impl AstNode for MacroCall {
3708 } 2474 }
3709 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2475 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3710} 2476}
3711impl AstNode for Attr { 2477impl AstNode for MacroDef {
3712 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } 2478 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF }
3713 fn cast(syntax: SyntaxNode) -> Option<Self> { 2479 fn cast(syntax: SyntaxNode) -> Option<Self> {
3714 if Self::can_cast(syntax.kind()) { 2480 if Self::can_cast(syntax.kind()) {
3715 Some(Self { syntax }) 2481 Some(Self { syntax })
@@ -3719,8 +2485,8 @@ impl AstNode for Attr {
3719 } 2485 }
3720 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2486 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3721} 2487}
3722impl AstNode for TokenTree { 2488impl AstNode for MacroItems {
3723 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } 2489 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS }
3724 fn cast(syntax: SyntaxNode) -> Option<Self> { 2490 fn cast(syntax: SyntaxNode) -> Option<Self> {
3725 if Self::can_cast(syntax.kind()) { 2491 if Self::can_cast(syntax.kind()) {
3726 Some(Self { syntax }) 2492 Some(Self { syntax })
@@ -3730,8 +2496,8 @@ impl AstNode for TokenTree {
3730 } 2496 }
3731 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2497 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3732} 2498}
3733impl AstNode for TypeParamList { 2499impl AstNode for MacroStmts {
3734 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } 2500 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS }
3735 fn cast(syntax: SyntaxNode) -> Option<Self> { 2501 fn cast(syntax: SyntaxNode) -> Option<Self> {
3736 if Self::can_cast(syntax.kind()) { 2502 if Self::can_cast(syntax.kind()) {
3737 Some(Self { syntax }) 2503 Some(Self { syntax })
@@ -3752,17 +2518,6 @@ impl AstNode for TypeParam {
3752 } 2518 }
3753 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2519 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3754} 2520}
3755impl AstNode for ConstParam {
3756 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
3757 fn cast(syntax: SyntaxNode) -> Option<Self> {
3758 if Self::can_cast(syntax.kind()) {
3759 Some(Self { syntax })
3760 } else {
3761 None
3762 }
3763 }
3764 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3765}
3766impl AstNode for LifetimeParam { 2521impl AstNode for LifetimeParam {
3767 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } 2522 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM }
3768 fn cast(syntax: SyntaxNode) -> Option<Self> { 2523 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3774,8 +2529,8 @@ impl AstNode for LifetimeParam {
3774 } 2529 }
3775 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2530 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3776} 2531}
3777impl AstNode for TypeBound { 2532impl AstNode for ConstParam {
3778 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } 2533 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
3779 fn cast(syntax: SyntaxNode) -> Option<Self> { 2534 fn cast(syntax: SyntaxNode) -> Option<Self> {
3780 if Self::can_cast(syntax.kind()) { 2535 if Self::can_cast(syntax.kind()) {
3781 Some(Self { syntax }) 2536 Some(Self { syntax })
@@ -3785,8 +2540,8 @@ impl AstNode for TypeBound {
3785 } 2540 }
3786 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2541 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3787} 2542}
3788impl AstNode for TypeBoundList { 2543impl AstNode for TypeBound {
3789 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } 2544 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
3790 fn cast(syntax: SyntaxNode) -> Option<Self> { 2545 fn cast(syntax: SyntaxNode) -> Option<Self> {
3791 if Self::can_cast(syntax.kind()) { 2546 if Self::can_cast(syntax.kind()) {
3792 Some(Self { syntax }) 2547 Some(Self { syntax })
@@ -3807,28 +2562,6 @@ impl AstNode for WherePred {
3807 } 2562 }
3808 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2563 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3809} 2564}
3810impl AstNode for WhereClause {
3811 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
3812 fn cast(syntax: SyntaxNode) -> Option<Self> {
3813 if Self::can_cast(syntax.kind()) {
3814 Some(Self { syntax })
3815 } else {
3816 None
3817 }
3818 }
3819 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3820}
3821impl AstNode for Abi {
3822 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
3823 fn cast(syntax: SyntaxNode) -> Option<Self> {
3824 if Self::can_cast(syntax.kind()) {
3825 Some(Self { syntax })
3826 } else {
3827 None
3828 }
3829 }
3830 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3831}
3832impl AstNode for ExprStmt { 2565impl AstNode for ExprStmt {
3833 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } 2566 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT }
3834 fn cast(syntax: SyntaxNode) -> Option<Self> { 2567 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3851,28 +2584,6 @@ impl AstNode for LetStmt {
3851 } 2584 }
3852 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2585 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3853} 2586}
3854impl AstNode for Condition {
3855 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
3856 fn cast(syntax: SyntaxNode) -> Option<Self> {
3857 if Self::can_cast(syntax.kind()) {
3858 Some(Self { syntax })
3859 } else {
3860 None
3861 }
3862 }
3863 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3864}
3865impl AstNode for ParamList {
3866 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
3867 fn cast(syntax: SyntaxNode) -> Option<Self> {
3868 if Self::can_cast(syntax.kind()) {
3869 Some(Self { syntax })
3870 } else {
3871 None
3872 }
3873 }
3874 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3875}
3876impl AstNode for SelfParam { 2587impl AstNode for SelfParam {
3877 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } 2588 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
3878 fn cast(syntax: SyntaxNode) -> Option<Self> { 2589 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3917,17 +2628,6 @@ impl AstNode for UseTree {
3917 } 2628 }
3918 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2629 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3919} 2630}
3920impl AstNode for Alias {
3921 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS }
3922 fn cast(syntax: SyntaxNode) -> Option<Self> {
3923 if Self::can_cast(syntax.kind()) {
3924 Some(Self { syntax })
3925 } else {
3926 None
3927 }
3928 }
3929 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3930}
3931impl AstNode for UseTreeList { 2631impl AstNode for UseTreeList {
3932 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } 2632 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
3933 fn cast(syntax: SyntaxNode) -> Option<Self> { 2633 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3939,19 +2639,8 @@ impl AstNode for UseTreeList {
3939 } 2639 }
3940 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2640 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3941} 2641}
3942impl AstNode for ExternCrateItem { 2642impl AstNode for Alias {
3943 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } 2643 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS }
3944 fn cast(syntax: SyntaxNode) -> Option<Self> {
3945 if Self::can_cast(syntax.kind()) {
3946 Some(Self { syntax })
3947 } else {
3948 None
3949 }
3950 }
3951 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3952}
3953impl AstNode for ArgList {
3954 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
3955 fn cast(syntax: SyntaxNode) -> Option<Self> { 2644 fn cast(syntax: SyntaxNode) -> Option<Self> {
3956 if Self::can_cast(syntax.kind()) { 2645 if Self::can_cast(syntax.kind()) {
3957 Some(Self { syntax }) 2646 Some(Self { syntax })
@@ -3961,8 +2650,8 @@ impl AstNode for ArgList {
3961 } 2650 }
3962 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2651 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3963} 2652}
3964impl AstNode for Path { 2653impl AstNode for ExternCrateItem {
3965 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } 2654 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM }
3966 fn cast(syntax: SyntaxNode) -> Option<Self> { 2655 fn cast(syntax: SyntaxNode) -> Option<Self> {
3967 if Self::can_cast(syntax.kind()) { 2656 if Self::can_cast(syntax.kind()) {
3968 Some(Self { syntax }) 2657 Some(Self { syntax })
@@ -3983,17 +2672,6 @@ impl AstNode for PathSegment {
3983 } 2672 }
3984 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2673 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3985} 2674}
3986impl AstNode for TypeArgList {
3987 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST }
3988 fn cast(syntax: SyntaxNode) -> Option<Self> {
3989 if Self::can_cast(syntax.kind()) {
3990 Some(Self { syntax })
3991 } else {
3992 None
3993 }
3994 }
3995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3996}
3997impl AstNode for TypeArg { 2675impl AstNode for TypeArg {
3998 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } 2676 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG }
3999 fn cast(syntax: SyntaxNode) -> Option<Self> { 2677 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -4005,17 +2683,6 @@ impl AstNode for TypeArg {
4005 } 2683 }
4006 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2684 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4007} 2685}
4008impl AstNode for AssocTypeArg {
4009 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
4010 fn cast(syntax: SyntaxNode) -> Option<Self> {
4011 if Self::can_cast(syntax.kind()) {
4012 Some(Self { syntax })
4013 } else {
4014 None
4015 }
4016 }
4017 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4018}
4019impl AstNode for LifetimeArg { 2686impl AstNode for LifetimeArg {
4020 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } 2687 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG }
4021 fn cast(syntax: SyntaxNode) -> Option<Self> { 2688 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -4027,8 +2694,8 @@ impl AstNode for LifetimeArg {
4027 } 2694 }
4028 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2695 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4029} 2696}
4030impl AstNode for ConstArg { 2697impl AstNode for AssocTypeArg {
4031 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } 2698 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
4032 fn cast(syntax: SyntaxNode) -> Option<Self> { 2699 fn cast(syntax: SyntaxNode) -> Option<Self> {
4033 if Self::can_cast(syntax.kind()) { 2700 if Self::can_cast(syntax.kind()) {
4034 Some(Self { syntax }) 2701 Some(Self { syntax })
@@ -4038,8 +2705,8 @@ impl AstNode for ConstArg {
4038 } 2705 }
4039 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2706 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4040} 2707}
4041impl AstNode for MacroItems { 2708impl AstNode for ConstArg {
4042 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } 2709 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG }
4043 fn cast(syntax: SyntaxNode) -> Option<Self> { 2710 fn cast(syntax: SyntaxNode) -> Option<Self> {
4044 if Self::can_cast(syntax.kind()) { 2711 if Self::can_cast(syntax.kind()) {
4045 Some(Self { syntax }) 2712 Some(Self { syntax })
@@ -4049,8 +2716,8 @@ impl AstNode for MacroItems {
4049 } 2716 }
4050 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2717 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4051} 2718}
4052impl AstNode for MacroStmts { 2719impl AstNode for ExternBlock {
4053 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } 2720 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
4054 fn cast(syntax: SyntaxNode) -> Option<Self> { 2721 fn cast(syntax: SyntaxNode) -> Option<Self> {
4055 if Self::can_cast(syntax.kind()) { 2722 if Self::can_cast(syntax.kind()) {
4056 Some(Self { syntax }) 2723 Some(Self { syntax })
@@ -4071,17 +2738,6 @@ impl AstNode for ExternItemList {
4071 } 2738 }
4072 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2739 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4073} 2740}
4074impl AstNode for ExternBlock {
4075 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
4076 fn cast(syntax: SyntaxNode) -> Option<Self> {
4077 if Self::can_cast(syntax.kind()) {
4078 Some(Self { syntax })
4079 } else {
4080 None
4081 }
4082 }
4083 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4084}
4085impl AstNode for MetaItem { 2741impl AstNode for MetaItem {
4086 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } 2742 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM }
4087 fn cast(syntax: SyntaxNode) -> Option<Self> { 2743 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -4093,85 +2749,93 @@ impl AstNode for MetaItem {
4093 } 2749 }
4094 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2750 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4095} 2751}
4096impl AstNode for MacroDef { 2752impl From<StructDef> for ModuleItem {
4097 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } 2753 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) }
4098 fn cast(syntax: SyntaxNode) -> Option<Self> {
4099 if Self::can_cast(syntax.kind()) {
4100 Some(Self { syntax })
4101 } else {
4102 None
4103 }
4104 }
4105 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4106} 2754}
4107impl From<StructDef> for NominalDef { 2755impl From<UnionDef> for ModuleItem {
4108 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } 2756 fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) }
4109} 2757}
4110impl From<EnumDef> for NominalDef { 2758impl From<EnumDef> for ModuleItem {
4111 fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) } 2759 fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) }
4112} 2760}
4113impl From<UnionDef> for NominalDef { 2761impl From<FnDef> for ModuleItem {
4114 fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) } 2762 fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) }
4115} 2763}
4116impl AstNode for NominalDef { 2764impl From<TraitDef> for ModuleItem {
4117 fn can_cast(kind: SyntaxKind) -> bool { 2765 fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) }
4118 match kind { 2766}
4119 STRUCT_DEF | ENUM_DEF | UNION_DEF => true, 2767impl From<TypeAliasDef> for ModuleItem {
4120 _ => false, 2768 fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) }
4121 } 2769}
4122 } 2770impl From<ImplDef> for ModuleItem {
4123 fn cast(syntax: SyntaxNode) -> Option<Self> { 2771 fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) }
4124 let res = match syntax.kind() {
4125 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
4126 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
4127 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
4128 _ => return None,
4129 };
4130 Some(res)
4131 }
4132 fn syntax(&self) -> &SyntaxNode {
4133 match self {
4134 NominalDef::StructDef(it) => &it.syntax,
4135 NominalDef::EnumDef(it) => &it.syntax,
4136 NominalDef::UnionDef(it) => &it.syntax,
4137 }
4138 }
4139} 2772}
4140impl From<LifetimeArg> for GenericArg { 2773impl From<UseItem> for ModuleItem {
4141 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } 2774 fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) }
2775}
2776impl From<ExternCrateItem> for ModuleItem {
2777 fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) }
4142} 2778}
4143impl From<TypeArg> for GenericArg { 2779impl From<ConstDef> for ModuleItem {
4144 fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) } 2780 fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) }
4145} 2781}
4146impl From<ConstArg> for GenericArg { 2782impl From<StaticDef> for ModuleItem {
4147 fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } 2783 fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) }
4148} 2784}
4149impl From<AssocTypeArg> for GenericArg { 2785impl From<Module> for ModuleItem {
4150 fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) } 2786 fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) }
4151} 2787}
4152impl AstNode for GenericArg { 2788impl From<MacroCall> for ModuleItem {
2789 fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) }
2790}
2791impl From<ExternBlock> for ModuleItem {
2792 fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) }
2793}
2794impl AstNode for ModuleItem {
4153 fn can_cast(kind: SyntaxKind) -> bool { 2795 fn can_cast(kind: SyntaxKind) -> bool {
4154 match kind { 2796 match kind {
4155 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true, 2797 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
2798 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
2799 | EXTERN_BLOCK => true,
4156 _ => false, 2800 _ => false,
4157 } 2801 }
4158 } 2802 }
4159 fn cast(syntax: SyntaxNode) -> Option<Self> { 2803 fn cast(syntax: SyntaxNode) -> Option<Self> {
4160 let res = match syntax.kind() { 2804 let res = match syntax.kind() {
4161 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }), 2805 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
4162 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), 2806 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
4163 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }), 2807 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
4164 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), 2808 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
2809 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
2810 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
2811 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
2812 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
2813 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
2814 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
2815 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
2816 MODULE => ModuleItem::Module(Module { syntax }),
2817 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
2818 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
4165 _ => return None, 2819 _ => return None,
4166 }; 2820 };
4167 Some(res) 2821 Some(res)
4168 } 2822 }
4169 fn syntax(&self) -> &SyntaxNode { 2823 fn syntax(&self) -> &SyntaxNode {
4170 match self { 2824 match self {
4171 GenericArg::LifetimeArg(it) => &it.syntax, 2825 ModuleItem::StructDef(it) => &it.syntax,
4172 GenericArg::TypeArg(it) => &it.syntax, 2826 ModuleItem::UnionDef(it) => &it.syntax,
4173 GenericArg::ConstArg(it) => &it.syntax, 2827 ModuleItem::EnumDef(it) => &it.syntax,
4174 GenericArg::AssocTypeArg(it) => &it.syntax, 2828 ModuleItem::FnDef(it) => &it.syntax,
2829 ModuleItem::TraitDef(it) => &it.syntax,
2830 ModuleItem::TypeAliasDef(it) => &it.syntax,
2831 ModuleItem::ImplDef(it) => &it.syntax,
2832 ModuleItem::UseItem(it) => &it.syntax,
2833 ModuleItem::ExternCrateItem(it) => &it.syntax,
2834 ModuleItem::ConstDef(it) => &it.syntax,
2835 ModuleItem::StaticDef(it) => &it.syntax,
2836 ModuleItem::Module(it) => &it.syntax,
2837 ModuleItem::MacroCall(it) => &it.syntax,
2838 ModuleItem::ExternBlock(it) => &it.syntax,
4175 } 2839 }
4176 } 2840 }
4177} 2841}
@@ -4260,154 +2924,33 @@ impl AstNode for TypeRef {
4260 } 2924 }
4261 } 2925 }
4262} 2926}
4263impl From<StructDef> for ModuleItem { 2927impl From<RecordFieldDefList> for FieldDefList {
4264 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) } 2928 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
4265}
4266impl From<UnionDef> for ModuleItem {
4267 fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) }
4268}
4269impl From<EnumDef> for ModuleItem {
4270 fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) }
4271}
4272impl From<FnDef> for ModuleItem {
4273 fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) }
4274}
4275impl From<TraitDef> for ModuleItem {
4276 fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) }
4277}
4278impl From<TypeAliasDef> for ModuleItem {
4279 fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) }
4280}
4281impl From<ImplDef> for ModuleItem {
4282 fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) }
4283}
4284impl From<UseItem> for ModuleItem {
4285 fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) }
4286}
4287impl From<ExternCrateItem> for ModuleItem {
4288 fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) }
4289}
4290impl From<ConstDef> for ModuleItem {
4291 fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) }
4292}
4293impl From<StaticDef> for ModuleItem {
4294 fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) }
4295}
4296impl From<Module> for ModuleItem {
4297 fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) }
4298}
4299impl From<MacroCall> for ModuleItem {
4300 fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) }
4301}
4302impl From<ExternBlock> for ModuleItem {
4303 fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) }
4304}
4305impl AstNode for ModuleItem {
4306 fn can_cast(kind: SyntaxKind) -> bool {
4307 match kind {
4308 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
4309 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
4310 | EXTERN_BLOCK => true,
4311 _ => false,
4312 }
4313 }
4314 fn cast(syntax: SyntaxNode) -> Option<Self> {
4315 let res = match syntax.kind() {
4316 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
4317 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
4318 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
4319 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
4320 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
4321 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
4322 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
4323 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
4324 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
4325 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
4326 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
4327 MODULE => ModuleItem::Module(Module { syntax }),
4328 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
4329 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
4330 _ => return None,
4331 };
4332 Some(res)
4333 }
4334 fn syntax(&self) -> &SyntaxNode {
4335 match self {
4336 ModuleItem::StructDef(it) => &it.syntax,
4337 ModuleItem::UnionDef(it) => &it.syntax,
4338 ModuleItem::EnumDef(it) => &it.syntax,
4339 ModuleItem::FnDef(it) => &it.syntax,
4340 ModuleItem::TraitDef(it) => &it.syntax,
4341 ModuleItem::TypeAliasDef(it) => &it.syntax,
4342 ModuleItem::ImplDef(it) => &it.syntax,
4343 ModuleItem::UseItem(it) => &it.syntax,
4344 ModuleItem::ExternCrateItem(it) => &it.syntax,
4345 ModuleItem::ConstDef(it) => &it.syntax,
4346 ModuleItem::StaticDef(it) => &it.syntax,
4347 ModuleItem::Module(it) => &it.syntax,
4348 ModuleItem::MacroCall(it) => &it.syntax,
4349 ModuleItem::ExternBlock(it) => &it.syntax,
4350 }
4351 }
4352}
4353impl From<FnDef> for AssocItem {
4354 fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) }
4355}
4356impl From<TypeAliasDef> for AssocItem {
4357 fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
4358}
4359impl From<ConstDef> for AssocItem {
4360 fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) }
4361}
4362impl AstNode for AssocItem {
4363 fn can_cast(kind: SyntaxKind) -> bool {
4364 match kind {
4365 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
4366 _ => false,
4367 }
4368 }
4369 fn cast(syntax: SyntaxNode) -> Option<Self> {
4370 let res = match syntax.kind() {
4371 FN_DEF => AssocItem::FnDef(FnDef { syntax }),
4372 TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
4373 CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
4374 _ => return None,
4375 };
4376 Some(res)
4377 }
4378 fn syntax(&self) -> &SyntaxNode {
4379 match self {
4380 AssocItem::FnDef(it) => &it.syntax,
4381 AssocItem::TypeAliasDef(it) => &it.syntax,
4382 AssocItem::ConstDef(it) => &it.syntax,
4383 }
4384 }
4385}
4386impl From<FnDef> for ExternItem {
4387 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
4388} 2929}
4389impl From<StaticDef> for ExternItem { 2930impl From<TupleFieldDefList> for FieldDefList {
4390 fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } 2931 fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) }
4391} 2932}
4392impl AstNode for ExternItem { 2933impl AstNode for FieldDefList {
4393 fn can_cast(kind: SyntaxKind) -> bool { 2934 fn can_cast(kind: SyntaxKind) -> bool {
4394 match kind { 2935 match kind {
4395 FN_DEF | STATIC_DEF => true, 2936 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
4396 _ => false, 2937 _ => false,
4397 } 2938 }
4398 } 2939 }
4399 fn cast(syntax: SyntaxNode) -> Option<Self> { 2940 fn cast(syntax: SyntaxNode) -> Option<Self> {
4400 let res = match syntax.kind() { 2941 let res = match syntax.kind() {
4401 FN_DEF => ExternItem::FnDef(FnDef { syntax }), 2942 RECORD_FIELD_DEF_LIST => {
4402 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), 2943 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
2944 }
2945 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
4403 _ => return None, 2946 _ => return None,
4404 }; 2947 };
4405 Some(res) 2948 Some(res)
4406 } 2949 }
4407 fn syntax(&self) -> &SyntaxNode { 2950 fn syntax(&self) -> &SyntaxNode {
4408 match self { 2951 match self {
4409 ExternItem::FnDef(it) => &it.syntax, 2952 FieldDefList::RecordFieldDefList(it) => &it.syntax,
4410 ExternItem::StaticDef(it) => &it.syntax, 2953 FieldDefList::TupleFieldDefList(it) => &it.syntax,
4411 } 2954 }
4412 } 2955 }
4413} 2956}
@@ -4590,6 +3133,39 @@ impl AstNode for Expr {
4590 } 3133 }
4591 } 3134 }
4592} 3135}
3136impl From<FnDef> for AssocItem {
3137 fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) }
3138}
3139impl From<TypeAliasDef> for AssocItem {
3140 fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
3141}
3142impl From<ConstDef> for AssocItem {
3143 fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) }
3144}
3145impl AstNode for AssocItem {
3146 fn can_cast(kind: SyntaxKind) -> bool {
3147 match kind {
3148 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
3149 _ => false,
3150 }
3151 }
3152 fn cast(syntax: SyntaxNode) -> Option<Self> {
3153 let res = match syntax.kind() {
3154 FN_DEF => AssocItem::FnDef(FnDef { syntax }),
3155 TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
3156 CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
3157 _ => return None,
3158 };
3159 Some(res)
3160 }
3161 fn syntax(&self) -> &SyntaxNode {
3162 match self {
3163 AssocItem::FnDef(it) => &it.syntax,
3164 AssocItem::TypeAliasDef(it) => &it.syntax,
3165 AssocItem::ConstDef(it) => &it.syntax,
3166 }
3167 }
3168}
4593impl From<OrPat> for Pat { 3169impl From<OrPat> for Pat {
4594 fn from(node: OrPat) -> Pat { Pat::OrPat(node) } 3170 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
4595} 3171}
@@ -4685,6 +3261,34 @@ impl AstNode for Pat {
4685 } 3261 }
4686 } 3262 }
4687} 3263}
3264impl From<LetStmt> for Stmt {
3265 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3266}
3267impl From<ExprStmt> for Stmt {
3268 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
3269}
3270impl AstNode for Stmt {
3271 fn can_cast(kind: SyntaxKind) -> bool {
3272 match kind {
3273 LET_STMT | EXPR_STMT => true,
3274 _ => false,
3275 }
3276 }
3277 fn cast(syntax: SyntaxNode) -> Option<Self> {
3278 let res = match syntax.kind() {
3279 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3280 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3281 _ => return None,
3282 };
3283 Some(res)
3284 }
3285 fn syntax(&self) -> &SyntaxNode {
3286 match self {
3287 Stmt::LetStmt(it) => &it.syntax,
3288 Stmt::ExprStmt(it) => &it.syntax,
3289 }
3290 }
3291}
4688impl From<Literal> for AttrInput { 3292impl From<Literal> for AttrInput {
4689 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } 3293 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) }
4690} 3294}
@@ -4713,80 +3317,83 @@ impl AstNode for AttrInput {
4713 } 3317 }
4714 } 3318 }
4715} 3319}
4716impl From<LetStmt> for Stmt { 3320impl From<FnDef> for ExternItem {
4717 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } 3321 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
4718} 3322}
4719impl From<ExprStmt> for Stmt { 3323impl From<StaticDef> for ExternItem {
4720 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) } 3324 fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) }
4721} 3325}
4722impl AstNode for Stmt { 3326impl AstNode for ExternItem {
4723 fn can_cast(kind: SyntaxKind) -> bool { 3327 fn can_cast(kind: SyntaxKind) -> bool {
4724 match kind { 3328 match kind {
4725 LET_STMT | EXPR_STMT => true, 3329 FN_DEF | STATIC_DEF => true,
4726 _ => false, 3330 _ => false,
4727 } 3331 }
4728 } 3332 }
4729 fn cast(syntax: SyntaxNode) -> Option<Self> { 3333 fn cast(syntax: SyntaxNode) -> Option<Self> {
4730 let res = match syntax.kind() { 3334 let res = match syntax.kind() {
4731 LET_STMT => Stmt::LetStmt(LetStmt { syntax }), 3335 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
4732 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), 3336 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
4733 _ => return None, 3337 _ => return None,
4734 }; 3338 };
4735 Some(res) 3339 Some(res)
4736 } 3340 }
4737 fn syntax(&self) -> &SyntaxNode { 3341 fn syntax(&self) -> &SyntaxNode {
4738 match self { 3342 match self {
4739 Stmt::LetStmt(it) => &it.syntax, 3343 ExternItem::FnDef(it) => &it.syntax,
4740 Stmt::ExprStmt(it) => &it.syntax, 3344 ExternItem::StaticDef(it) => &it.syntax,
4741 } 3345 }
4742 } 3346 }
4743} 3347}
4744impl From<RecordFieldDefList> for FieldDefList { 3348impl From<StructDef> for NominalDef {
4745 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } 3349 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) }
4746} 3350}
4747impl From<TupleFieldDefList> for FieldDefList { 3351impl From<EnumDef> for NominalDef {
4748 fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) } 3352 fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) }
4749} 3353}
4750impl AstNode for FieldDefList { 3354impl From<UnionDef> for NominalDef {
3355 fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) }
3356}
3357impl AstNode for NominalDef {
4751 fn can_cast(kind: SyntaxKind) -> bool { 3358 fn can_cast(kind: SyntaxKind) -> bool {
4752 match kind { 3359 match kind {
4753 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true, 3360 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
4754 _ => false, 3361 _ => false,
4755 } 3362 }
4756 } 3363 }
4757 fn cast(syntax: SyntaxNode) -> Option<Self> { 3364 fn cast(syntax: SyntaxNode) -> Option<Self> {
4758 let res = match syntax.kind() { 3365 let res = match syntax.kind() {
4759 RECORD_FIELD_DEF_LIST => { 3366 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
4760 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax }) 3367 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
4761 } 3368 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
4762 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
4763 _ => return None, 3369 _ => return None,
4764 }; 3370 };
4765 Some(res) 3371 Some(res)
4766 } 3372 }
4767 fn syntax(&self) -> &SyntaxNode { 3373 fn syntax(&self) -> &SyntaxNode {
4768 match self { 3374 match self {
4769 FieldDefList::RecordFieldDefList(it) => &it.syntax, 3375 NominalDef::StructDef(it) => &it.syntax,
4770 FieldDefList::TupleFieldDefList(it) => &it.syntax, 3376 NominalDef::EnumDef(it) => &it.syntax,
3377 NominalDef::UnionDef(it) => &it.syntax,
4771 } 3378 }
4772 } 3379 }
4773} 3380}
4774impl std::fmt::Display for NominalDef { 3381impl std::fmt::Display for ModuleItem {
4775 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3382 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4776 std::fmt::Display::fmt(self.syntax(), f) 3383 std::fmt::Display::fmt(self.syntax(), f)
4777 } 3384 }
4778} 3385}
4779impl std::fmt::Display for GenericArg { 3386impl std::fmt::Display for TypeRef {
4780 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3387 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4781 std::fmt::Display::fmt(self.syntax(), f) 3388 std::fmt::Display::fmt(self.syntax(), f)
4782 } 3389 }
4783} 3390}
4784impl std::fmt::Display for TypeRef { 3391impl std::fmt::Display for FieldDefList {
4785 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3392 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4786 std::fmt::Display::fmt(self.syntax(), f) 3393 std::fmt::Display::fmt(self.syntax(), f)
4787 } 3394 }
4788} 3395}
4789impl std::fmt::Display for ModuleItem { 3396impl std::fmt::Display for Expr {
4790 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3397 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4791 std::fmt::Display::fmt(self.syntax(), f) 3398 std::fmt::Display::fmt(self.syntax(), f)
4792 } 3399 }
@@ -4796,37 +3403,37 @@ impl std::fmt::Display for AssocItem {
4796 std::fmt::Display::fmt(self.syntax(), f) 3403 std::fmt::Display::fmt(self.syntax(), f)
4797 } 3404 }
4798} 3405}
4799impl std::fmt::Display for ExternItem { 3406impl std::fmt::Display for Pat {
4800 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3407 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4801 std::fmt::Display::fmt(self.syntax(), f) 3408 std::fmt::Display::fmt(self.syntax(), f)
4802 } 3409 }
4803} 3410}
4804impl std::fmt::Display for Expr { 3411impl std::fmt::Display for Stmt {
4805 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3412 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4806 std::fmt::Display::fmt(self.syntax(), f) 3413 std::fmt::Display::fmt(self.syntax(), f)
4807 } 3414 }
4808} 3415}
4809impl std::fmt::Display for Pat { 3416impl std::fmt::Display for AttrInput {
4810 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3417 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4811 std::fmt::Display::fmt(self.syntax(), f) 3418 std::fmt::Display::fmt(self.syntax(), f)
4812 } 3419 }
4813} 3420}
4814impl std::fmt::Display for AttrInput { 3421impl std::fmt::Display for ExternItem {
4815 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3422 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4816 std::fmt::Display::fmt(self.syntax(), f) 3423 std::fmt::Display::fmt(self.syntax(), f)
4817 } 3424 }
4818} 3425}
4819impl std::fmt::Display for Stmt { 3426impl std::fmt::Display for NominalDef {
4820 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3427 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4821 std::fmt::Display::fmt(self.syntax(), f) 3428 std::fmt::Display::fmt(self.syntax(), f)
4822 } 3429 }
4823} 3430}
4824impl std::fmt::Display for FieldDefList { 3431impl std::fmt::Display for SourceFile {
4825 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3432 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4826 std::fmt::Display::fmt(self.syntax(), f) 3433 std::fmt::Display::fmt(self.syntax(), f)
4827 } 3434 }
4828} 3435}
4829impl std::fmt::Display for SourceFile { 3436impl std::fmt::Display for Attr {
4830 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3437 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4831 std::fmt::Display::fmt(self.syntax(), f) 3438 std::fmt::Display::fmt(self.syntax(), f)
4832 } 3439 }
@@ -4836,27 +3443,52 @@ impl std::fmt::Display for FnDef {
4836 std::fmt::Display::fmt(self.syntax(), f) 3443 std::fmt::Display::fmt(self.syntax(), f)
4837 } 3444 }
4838} 3445}
3446impl std::fmt::Display for Visibility {
3447 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3448 std::fmt::Display::fmt(self.syntax(), f)
3449 }
3450}
3451impl std::fmt::Display for Abi {
3452 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3453 std::fmt::Display::fmt(self.syntax(), f)
3454 }
3455}
3456impl std::fmt::Display for Name {
3457 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3458 std::fmt::Display::fmt(self.syntax(), f)
3459 }
3460}
3461impl std::fmt::Display for TypeParamList {
3462 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3463 std::fmt::Display::fmt(self.syntax(), f)
3464 }
3465}
3466impl std::fmt::Display for ParamList {
3467 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3468 std::fmt::Display::fmt(self.syntax(), f)
3469 }
3470}
4839impl std::fmt::Display for RetType { 3471impl std::fmt::Display for RetType {
4840 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3472 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4841 std::fmt::Display::fmt(self.syntax(), f) 3473 std::fmt::Display::fmt(self.syntax(), f)
4842 } 3474 }
4843} 3475}
4844impl std::fmt::Display for StructDef { 3476impl std::fmt::Display for WhereClause {
4845 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3477 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4846 std::fmt::Display::fmt(self.syntax(), f) 3478 std::fmt::Display::fmt(self.syntax(), f)
4847 } 3479 }
4848} 3480}
4849impl std::fmt::Display for UnionDef { 3481impl std::fmt::Display for BlockExpr {
4850 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3482 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4851 std::fmt::Display::fmt(self.syntax(), f) 3483 std::fmt::Display::fmt(self.syntax(), f)
4852 } 3484 }
4853} 3485}
4854impl std::fmt::Display for RecordFieldDefList { 3486impl std::fmt::Display for StructDef {
4855 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3487 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4856 std::fmt::Display::fmt(self.syntax(), f) 3488 std::fmt::Display::fmt(self.syntax(), f)
4857 } 3489 }
4858} 3490}
4859impl std::fmt::Display for RecordFieldDef { 3491impl std::fmt::Display for RecordFieldDefList {
4860 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3492 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4861 std::fmt::Display::fmt(self.syntax(), f) 3493 std::fmt::Display::fmt(self.syntax(), f)
4862 } 3494 }
@@ -4866,6 +3498,16 @@ impl std::fmt::Display for TupleFieldDefList {
4866 std::fmt::Display::fmt(self.syntax(), f) 3498 std::fmt::Display::fmt(self.syntax(), f)
4867 } 3499 }
4868} 3500}
3501impl std::fmt::Display for UnionDef {
3502 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3503 std::fmt::Display::fmt(self.syntax(), f)
3504 }
3505}
3506impl std::fmt::Display for RecordFieldDef {
3507 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3508 std::fmt::Display::fmt(self.syntax(), f)
3509 }
3510}
4869impl std::fmt::Display for TupleFieldDef { 3511impl std::fmt::Display for TupleFieldDef {
4870 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3512 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4871 std::fmt::Display::fmt(self.syntax(), f) 3513 std::fmt::Display::fmt(self.syntax(), f)
@@ -4891,7 +3533,7 @@ impl std::fmt::Display for TraitDef {
4891 std::fmt::Display::fmt(self.syntax(), f) 3533 std::fmt::Display::fmt(self.syntax(), f)
4892 } 3534 }
4893} 3535}
4894impl std::fmt::Display for Module { 3536impl std::fmt::Display for TypeBoundList {
4895 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3537 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4896 std::fmt::Display::fmt(self.syntax(), f) 3538 std::fmt::Display::fmt(self.syntax(), f)
4897 } 3539 }
@@ -4901,6 +3543,11 @@ impl std::fmt::Display for ItemList {
4901 std::fmt::Display::fmt(self.syntax(), f) 3543 std::fmt::Display::fmt(self.syntax(), f)
4902 } 3544 }
4903} 3545}
3546impl std::fmt::Display for Module {
3547 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3548 std::fmt::Display::fmt(self.syntax(), f)
3549 }
3550}
4904impl std::fmt::Display for ConstDef { 3551impl std::fmt::Display for ConstDef {
4905 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3552 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4906 std::fmt::Display::fmt(self.syntax(), f) 3553 std::fmt::Display::fmt(self.syntax(), f)
@@ -4941,6 +3588,11 @@ impl std::fmt::Display for PathType {
4941 std::fmt::Display::fmt(self.syntax(), f) 3588 std::fmt::Display::fmt(self.syntax(), f)
4942 } 3589 }
4943} 3590}
3591impl std::fmt::Display for Path {
3592 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3593 std::fmt::Display::fmt(self.syntax(), f)
3594 }
3595}
4944impl std::fmt::Display for PointerType { 3596impl std::fmt::Display for PointerType {
4945 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3597 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4946 std::fmt::Display::fmt(self.syntax(), f) 3598 std::fmt::Display::fmt(self.syntax(), f)
@@ -5016,7 +3668,7 @@ impl std::fmt::Display for IfExpr {
5016 std::fmt::Display::fmt(self.syntax(), f) 3668 std::fmt::Display::fmt(self.syntax(), f)
5017 } 3669 }
5018} 3670}
5019impl std::fmt::Display for LoopExpr { 3671impl std::fmt::Display for Condition {
5020 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3672 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5021 std::fmt::Display::fmt(self.syntax(), f) 3673 std::fmt::Display::fmt(self.syntax(), f)
5022 } 3674 }
@@ -5026,6 +3678,16 @@ impl std::fmt::Display for EffectExpr {
5026 std::fmt::Display::fmt(self.syntax(), f) 3678 std::fmt::Display::fmt(self.syntax(), f)
5027 } 3679 }
5028} 3680}
3681impl std::fmt::Display for Label {
3682 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3683 std::fmt::Display::fmt(self.syntax(), f)
3684 }
3685}
3686impl std::fmt::Display for LoopExpr {
3687 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3688 std::fmt::Display::fmt(self.syntax(), f)
3689 }
3690}
5029impl std::fmt::Display for ForExpr { 3691impl std::fmt::Display for ForExpr {
5030 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3692 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5031 std::fmt::Display::fmt(self.syntax(), f) 3693 std::fmt::Display::fmt(self.syntax(), f)
@@ -5046,32 +3708,32 @@ impl std::fmt::Display for BreakExpr {
5046 std::fmt::Display::fmt(self.syntax(), f) 3708 std::fmt::Display::fmt(self.syntax(), f)
5047 } 3709 }
5048} 3710}
5049impl std::fmt::Display for Label { 3711impl std::fmt::Display for ReturnExpr {
5050 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3712 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5051 std::fmt::Display::fmt(self.syntax(), f) 3713 std::fmt::Display::fmt(self.syntax(), f)
5052 } 3714 }
5053} 3715}
5054impl std::fmt::Display for BlockExpr { 3716impl std::fmt::Display for CallExpr {
5055 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3717 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5056 std::fmt::Display::fmt(self.syntax(), f) 3718 std::fmt::Display::fmt(self.syntax(), f)
5057 } 3719 }
5058} 3720}
5059impl std::fmt::Display for ReturnExpr { 3721impl std::fmt::Display for ArgList {
5060 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3722 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5061 std::fmt::Display::fmt(self.syntax(), f) 3723 std::fmt::Display::fmt(self.syntax(), f)
5062 } 3724 }
5063} 3725}
5064impl std::fmt::Display for CallExpr { 3726impl std::fmt::Display for MethodCallExpr {
5065 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3727 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5066 std::fmt::Display::fmt(self.syntax(), f) 3728 std::fmt::Display::fmt(self.syntax(), f)
5067 } 3729 }
5068} 3730}
5069impl std::fmt::Display for MethodCallExpr { 3731impl std::fmt::Display for NameRef {
5070 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3732 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5071 std::fmt::Display::fmt(self.syntax(), f) 3733 std::fmt::Display::fmt(self.syntax(), f)
5072 } 3734 }
5073} 3735}
5074impl std::fmt::Display for IndexExpr { 3736impl std::fmt::Display for TypeArgList {
5075 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3737 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5076 std::fmt::Display::fmt(self.syntax(), f) 3738 std::fmt::Display::fmt(self.syntax(), f)
5077 } 3739 }
@@ -5081,6 +3743,11 @@ impl std::fmt::Display for FieldExpr {
5081 std::fmt::Display::fmt(self.syntax(), f) 3743 std::fmt::Display::fmt(self.syntax(), f)
5082 } 3744 }
5083} 3745}
3746impl std::fmt::Display for IndexExpr {
3747 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3748 std::fmt::Display::fmt(self.syntax(), f)
3749 }
3750}
5084impl std::fmt::Display for AwaitExpr { 3751impl std::fmt::Display for AwaitExpr {
5085 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3752 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5086 std::fmt::Display::fmt(self.syntax(), f) 3753 std::fmt::Display::fmt(self.syntax(), f)
@@ -5221,6 +3888,11 @@ impl std::fmt::Display for MacroPat {
5221 std::fmt::Display::fmt(self.syntax(), f) 3888 std::fmt::Display::fmt(self.syntax(), f)
5222 } 3889 }
5223} 3890}
3891impl std::fmt::Display for MacroCall {
3892 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3893 std::fmt::Display::fmt(self.syntax(), f)
3894 }
3895}
5224impl std::fmt::Display for RecordPat { 3896impl std::fmt::Display for RecordPat {
5225 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3897 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5226 std::fmt::Display::fmt(self.syntax(), f) 3898 std::fmt::Display::fmt(self.syntax(), f)
@@ -5246,37 +3918,22 @@ impl std::fmt::Display for TuplePat {
5246 std::fmt::Display::fmt(self.syntax(), f) 3918 std::fmt::Display::fmt(self.syntax(), f)
5247 } 3919 }
5248} 3920}
5249impl std::fmt::Display for Visibility { 3921impl std::fmt::Display for TokenTree {
5250 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5251 std::fmt::Display::fmt(self.syntax(), f)
5252 }
5253}
5254impl std::fmt::Display for Name {
5255 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5256 std::fmt::Display::fmt(self.syntax(), f)
5257 }
5258}
5259impl std::fmt::Display for NameRef {
5260 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5261 std::fmt::Display::fmt(self.syntax(), f)
5262 }
5263}
5264impl std::fmt::Display for MacroCall {
5265 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3922 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5266 std::fmt::Display::fmt(self.syntax(), f) 3923 std::fmt::Display::fmt(self.syntax(), f)
5267 } 3924 }
5268} 3925}
5269impl std::fmt::Display for Attr { 3926impl std::fmt::Display for MacroDef {
5270 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3927 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5271 std::fmt::Display::fmt(self.syntax(), f) 3928 std::fmt::Display::fmt(self.syntax(), f)
5272 } 3929 }
5273} 3930}
5274impl std::fmt::Display for TokenTree { 3931impl std::fmt::Display for MacroItems {
5275 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3932 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5276 std::fmt::Display::fmt(self.syntax(), f) 3933 std::fmt::Display::fmt(self.syntax(), f)
5277 } 3934 }
5278} 3935}
5279impl std::fmt::Display for TypeParamList { 3936impl std::fmt::Display for MacroStmts {
5280 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3937 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5281 std::fmt::Display::fmt(self.syntax(), f) 3938 std::fmt::Display::fmt(self.syntax(), f)
5282 } 3939 }
@@ -5286,22 +3943,17 @@ impl std::fmt::Display for TypeParam {
5286 std::fmt::Display::fmt(self.syntax(), f) 3943 std::fmt::Display::fmt(self.syntax(), f)
5287 } 3944 }
5288} 3945}
5289impl std::fmt::Display for ConstParam {
5290 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5291 std::fmt::Display::fmt(self.syntax(), f)
5292 }
5293}
5294impl std::fmt::Display for LifetimeParam { 3946impl std::fmt::Display for LifetimeParam {
5295 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3947 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5296 std::fmt::Display::fmt(self.syntax(), f) 3948 std::fmt::Display::fmt(self.syntax(), f)
5297 } 3949 }
5298} 3950}
5299impl std::fmt::Display for TypeBound { 3951impl std::fmt::Display for ConstParam {
5300 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3952 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5301 std::fmt::Display::fmt(self.syntax(), f) 3953 std::fmt::Display::fmt(self.syntax(), f)
5302 } 3954 }
5303} 3955}
5304impl std::fmt::Display for TypeBoundList { 3956impl std::fmt::Display for TypeBound {
5305 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3957 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5306 std::fmt::Display::fmt(self.syntax(), f) 3958 std::fmt::Display::fmt(self.syntax(), f)
5307 } 3959 }
@@ -5311,16 +3963,6 @@ impl std::fmt::Display for WherePred {
5311 std::fmt::Display::fmt(self.syntax(), f) 3963 std::fmt::Display::fmt(self.syntax(), f)
5312 } 3964 }
5313} 3965}
5314impl std::fmt::Display for WhereClause {
5315 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5316 std::fmt::Display::fmt(self.syntax(), f)
5317 }
5318}
5319impl std::fmt::Display for Abi {
5320 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5321 std::fmt::Display::fmt(self.syntax(), f)
5322 }
5323}
5324impl std::fmt::Display for ExprStmt { 3966impl std::fmt::Display for ExprStmt {
5325 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3967 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5326 std::fmt::Display::fmt(self.syntax(), f) 3968 std::fmt::Display::fmt(self.syntax(), f)
@@ -5331,16 +3973,6 @@ impl std::fmt::Display for LetStmt {
5331 std::fmt::Display::fmt(self.syntax(), f) 3973 std::fmt::Display::fmt(self.syntax(), f)
5332 } 3974 }
5333} 3975}
5334impl std::fmt::Display for Condition {
5335 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5336 std::fmt::Display::fmt(self.syntax(), f)
5337 }
5338}
5339impl std::fmt::Display for ParamList {
5340 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5341 std::fmt::Display::fmt(self.syntax(), f)
5342 }
5343}
5344impl std::fmt::Display for SelfParam { 3976impl std::fmt::Display for SelfParam {
5345 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3977 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5346 std::fmt::Display::fmt(self.syntax(), f) 3978 std::fmt::Display::fmt(self.syntax(), f)
@@ -5361,27 +3993,17 @@ impl std::fmt::Display for UseTree {
5361 std::fmt::Display::fmt(self.syntax(), f) 3993 std::fmt::Display::fmt(self.syntax(), f)
5362 } 3994 }
5363} 3995}
5364impl std::fmt::Display for Alias {
5365 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5366 std::fmt::Display::fmt(self.syntax(), f)
5367 }
5368}
5369impl std::fmt::Display for UseTreeList { 3996impl std::fmt::Display for UseTreeList {
5370 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3997 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5371 std::fmt::Display::fmt(self.syntax(), f) 3998 std::fmt::Display::fmt(self.syntax(), f)
5372 } 3999 }
5373} 4000}
5374impl std::fmt::Display for ExternCrateItem { 4001impl std::fmt::Display for Alias {
5375 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5376 std::fmt::Display::fmt(self.syntax(), f)
5377 }
5378}
5379impl std::fmt::Display for ArgList {
5380 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4002 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5381 std::fmt::Display::fmt(self.syntax(), f) 4003 std::fmt::Display::fmt(self.syntax(), f)
5382 } 4004 }
5383} 4005}
5384impl std::fmt::Display for Path { 4006impl std::fmt::Display for ExternCrateItem {
5385 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4007 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5386 std::fmt::Display::fmt(self.syntax(), f) 4008 std::fmt::Display::fmt(self.syntax(), f)
5387 } 4009 }
@@ -5391,37 +4013,27 @@ impl std::fmt::Display for PathSegment {
5391 std::fmt::Display::fmt(self.syntax(), f) 4013 std::fmt::Display::fmt(self.syntax(), f)
5392 } 4014 }
5393} 4015}
5394impl std::fmt::Display for TypeArgList {
5395 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5396 std::fmt::Display::fmt(self.syntax(), f)
5397 }
5398}
5399impl std::fmt::Display for TypeArg { 4016impl std::fmt::Display for TypeArg {
5400 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4017 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5401 std::fmt::Display::fmt(self.syntax(), f) 4018 std::fmt::Display::fmt(self.syntax(), f)
5402 } 4019 }
5403} 4020}
5404impl std::fmt::Display for AssocTypeArg {
5405 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5406 std::fmt::Display::fmt(self.syntax(), f)
5407 }
5408}
5409impl std::fmt::Display for LifetimeArg { 4021impl std::fmt::Display for LifetimeArg {
5410 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4022 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5411 std::fmt::Display::fmt(self.syntax(), f) 4023 std::fmt::Display::fmt(self.syntax(), f)
5412 } 4024 }
5413} 4025}
5414impl std::fmt::Display for ConstArg { 4026impl std::fmt::Display for AssocTypeArg {
5415 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4027 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5416 std::fmt::Display::fmt(self.syntax(), f) 4028 std::fmt::Display::fmt(self.syntax(), f)
5417 } 4029 }
5418} 4030}
5419impl std::fmt::Display for MacroItems { 4031impl std::fmt::Display for ConstArg {
5420 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4032 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5421 std::fmt::Display::fmt(self.syntax(), f) 4033 std::fmt::Display::fmt(self.syntax(), f)
5422 } 4034 }
5423} 4035}
5424impl std::fmt::Display for MacroStmts { 4036impl std::fmt::Display for ExternBlock {
5425 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4037 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5426 std::fmt::Display::fmt(self.syntax(), f) 4038 std::fmt::Display::fmt(self.syntax(), f)
5427 } 4039 }
@@ -5431,18 +4043,8 @@ impl std::fmt::Display for ExternItemList {
5431 std::fmt::Display::fmt(self.syntax(), f) 4043 std::fmt::Display::fmt(self.syntax(), f)
5432 } 4044 }
5433} 4045}
5434impl std::fmt::Display for ExternBlock {
5435 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5436 std::fmt::Display::fmt(self.syntax(), f)
5437 }
5438}
5439impl std::fmt::Display for MetaItem { 4046impl std::fmt::Display for MetaItem {
5440 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4047 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5441 std::fmt::Display::fmt(self.syntax(), f) 4048 std::fmt::Display::fmt(self.syntax(), f)
5442 } 4049 }
5443} 4050}
5444impl std::fmt::Display for MacroDef {
5445 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5446 std::fmt::Display::fmt(self.syntax(), f)
5447 }
5448}
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs
index 662c6f73e..242900643 100644
--- a/crates/ra_syntax/src/ast/node_ext.rs
+++ b/crates/ra_syntax/src/ast/node_ext.rs
@@ -472,3 +472,19 @@ impl ast::TokenTree {
472 .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) 472 .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']']))
473 } 473 }
474} 474}
475
476impl ast::DocCommentsOwner for ast::SourceFile {}
477impl ast::DocCommentsOwner for ast::FnDef {}
478impl ast::DocCommentsOwner for ast::StructDef {}
479impl ast::DocCommentsOwner for ast::UnionDef {}
480impl ast::DocCommentsOwner for ast::RecordFieldDef {}
481impl ast::DocCommentsOwner for ast::TupleFieldDef {}
482impl ast::DocCommentsOwner for ast::EnumDef {}
483impl ast::DocCommentsOwner for ast::EnumVariant {}
484impl ast::DocCommentsOwner for ast::TraitDef {}
485impl ast::DocCommentsOwner for ast::Module {}
486impl ast::DocCommentsOwner for ast::StaticDef {}
487impl ast::DocCommentsOwner for ast::ConstDef {}
488impl ast::DocCommentsOwner for ast::TypeAliasDef {}
489impl ast::DocCommentsOwner for ast::ImplDef {}
490impl ast::DocCommentsOwner for ast::MacroCall {}