aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--crates/ra_assists/src/handlers/add_explicit_type.rs48
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir_expand/Cargo.toml1
-rw-r--r--crates/ra_hir_expand/src/proc_macro.rs106
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs2924
-rw-r--r--crates/rust-analyzer/src/bin/args.rs16
-rw-r--r--docs/user/readme.adoc43
-rw-r--r--xtask/src/codegen/gen_syntax.rs250
9 files changed, 1773 insertions, 1620 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 37455bc57..3738cfe8c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1012,6 +1012,7 @@ dependencies = [
1012 "ra_prof", 1012 "ra_prof",
1013 "ra_syntax", 1013 "ra_syntax",
1014 "ra_tt", 1014 "ra_tt",
1015 "test_utils",
1015] 1016]
1016 1017
1017[[package]] 1018[[package]]
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs
index d86d804b2..6c56d93d8 100644
--- a/crates/ra_assists/src/handlers/add_explicit_type.rs
+++ b/crates/ra_assists/src/handlers/add_explicit_type.rs
@@ -52,21 +52,22 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> {
52 } 52 }
53 // Infer type 53 // Infer type
54 let ty = ctx.sema.type_of_expr(&expr)?; 54 let ty = ctx.sema.type_of_expr(&expr)?;
55 // Assist not applicable if the type is unknown 55
56 if ty.contains_unknown() { 56 if ty.contains_unknown() || ty.is_closure() {
57 return None; 57 return None;
58 } 58 }
59 59
60 let db = ctx.db; 60 let db = ctx.db;
61 let new_type_string = ty.display_truncated(db, None).to_string();
61 ctx.add_assist( 62 ctx.add_assist(
62 AssistId("add_explicit_type"), 63 AssistId("add_explicit_type"),
63 format!("Insert explicit type '{}'", ty.display(db)), 64 format!("Insert explicit type '{}'", new_type_string),
64 |edit| { 65 |edit| {
65 edit.target(pat_range); 66 edit.target(pat_range);
66 if let Some(ascribed_ty) = ascribed_ty { 67 if let Some(ascribed_ty) = ascribed_ty {
67 edit.replace(ascribed_ty.syntax().text_range(), format!("{}", ty.display(db))); 68 edit.replace(ascribed_ty.syntax().text_range(), new_type_string);
68 } else { 69 } else {
69 edit.insert(name_range.end(), format!(": {}", ty.display(db))); 70 edit.insert(name_range.end(), format!(": {}", new_type_string));
70 } 71 }
71 }, 72 },
72 ) 73 )
@@ -174,4 +175,41 @@ mod tests {
174 "fn f() <|>{let a = match 1 {2 => 3, 3 => 5};}", 175 "fn f() <|>{let a = match 1 {2 => 3, 3 => 5};}",
175 ) 176 )
176 } 177 }
178
179 #[test]
180 fn closure_parameters_are_not_added() {
181 check_assist_not_applicable(
182 add_explicit_type,
183 r#"
184fn main() {
185 let multiply_by_two<|> = |i| i * 3;
186 let six = multiply_by_two(2);
187}"#,
188 )
189 }
190
191 #[test]
192 fn default_generics_should_not_be_added() {
193 check_assist(
194 add_explicit_type,
195 r#"
196struct Test<K, T = u8> {
197 k: K,
198 t: T,
199}
200
201fn main() {
202 let test<|> = Test { t: 23, k: 33 };
203}"#,
204 r#"
205struct Test<K, T = u8> {
206 k: K,
207 t: T,
208}
209
210fn main() {
211 let test<|>: Test<i32> = Test { t: 23, k: 33 };
212}"#,
213 );
214 }
177} 215}
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 6e0d89466..43f932e20 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -1132,6 +1132,10 @@ impl Type {
1132 Some(self.ty.value.as_callable()?.0) 1132 Some(self.ty.value.as_callable()?.0)
1133 } 1133 }
1134 1134
1135 pub fn is_closure(&self) -> bool {
1136 matches!(&self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Closure { .. }, .. }))
1137 }
1138
1135 pub fn contains_unknown(&self) -> bool { 1139 pub fn contains_unknown(&self) -> bool {
1136 return go(&self.ty.value); 1140 return go(&self.ty.value);
1137 1141
diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml
index d6e3c1f76..2cd522766 100644
--- a/crates/ra_hir_expand/Cargo.toml
+++ b/crates/ra_hir_expand/Cargo.toml
@@ -18,3 +18,4 @@ ra_parser = { path = "../ra_parser" }
18ra_prof = { path = "../ra_prof" } 18ra_prof = { path = "../ra_prof" }
19tt = { path = "../ra_tt", package = "ra_tt" } 19tt = { path = "../ra_tt", package = "ra_tt" }
20mbe = { path = "../ra_mbe", package = "ra_mbe" } 20mbe = { path = "../ra_mbe", package = "ra_mbe" }
21test_utils = { path = "../test_utils"}
diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs
index 97d1208ec..4e0e069c8 100644
--- a/crates/ra_hir_expand/src/proc_macro.rs
+++ b/crates/ra_hir_expand/src/proc_macro.rs
@@ -2,6 +2,7 @@
2 2
3use crate::{db::AstDatabase, LazyMacroId}; 3use crate::{db::AstDatabase, LazyMacroId};
4use ra_db::{CrateId, ProcMacroId}; 4use ra_db::{CrateId, ProcMacroId};
5use tt::buffer::{Cursor, TokenBuffer};
5 6
6#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] 7#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
7pub struct ProcMacroExpander { 8pub struct ProcMacroExpander {
@@ -36,22 +37,107 @@ impl ProcMacroExpander {
36 .clone() 37 .clone()
37 .ok_or_else(|| err!("No derive macro found."))?; 38 .ok_or_else(|| err!("No derive macro found."))?;
38 39
39 let tt = remove_derive_atr(tt, &proc_macro.name) 40 let tt = remove_derive_attrs(tt)
40 .ok_or_else(|| err!("Fail to remove derive for custom derive"))?; 41 .ok_or_else(|| err!("Fail to remove derive for custom derive"))?;
41 42
42 proc_macro.expander.expand(&tt, None).map_err(mbe::ExpandError::from) 43 proc_macro.expander.expand(&tt, None).map_err(mbe::ExpandError::from)
43 } 44 }
44} 45}
45 46
46fn remove_derive_atr(tt: &tt::Subtree, _name: &str) -> Option<tt::Subtree> { 47fn eat_punct(cursor: &mut Cursor, c: char) -> bool {
47 // FIXME: proper handle the remove derive 48 if let Some(tt::TokenTree::Leaf(tt::Leaf::Punct(punct))) = cursor.token_tree() {
48 // We assume the first 2 tokens are #[derive(name)] 49 if punct.char == c {
49 if tt.token_trees.len() > 2 { 50 *cursor = cursor.bump();
50 let mut tt = tt.clone(); 51 return true;
51 tt.token_trees.remove(0); 52 }
52 tt.token_trees.remove(0);
53 return Some(tt);
54 } 53 }
54 false
55}
56
57fn eat_subtree(cursor: &mut Cursor, kind: tt::DelimiterKind) -> bool {
58 if let Some(tt::TokenTree::Subtree(subtree)) = cursor.token_tree() {
59 if Some(kind) == subtree.delimiter_kind() {
60 *cursor = cursor.bump_subtree();
61 return true;
62 }
63 }
64 false
65}
66
67fn eat_ident(cursor: &mut Cursor, t: &str) -> bool {
68 if let Some(tt::TokenTree::Leaf(tt::Leaf::Ident(ident))) = cursor.token_tree() {
69 if t == ident.text.as_str() {
70 *cursor = cursor.bump();
71 return true;
72 }
73 }
74 false
75}
76
77fn remove_derive_attrs(tt: &tt::Subtree) -> Option<tt::Subtree> {
78 let buffer = TokenBuffer::new(&tt.token_trees);
79 let mut p = buffer.begin();
80 let mut result = tt::Subtree::default();
81
82 while !p.eof() {
83 let curr = p;
55 84
56 None 85 if eat_punct(&mut p, '#') {
86 eat_punct(&mut p, '!');
87 let parent = p;
88 if eat_subtree(&mut p, tt::DelimiterKind::Bracket) {
89 if eat_ident(&mut p, "derive") {
90 p = parent.bump();
91 continue;
92 }
93 }
94 }
95
96 result.token_trees.push(curr.token_tree()?.clone());
97 p = curr.bump();
98 }
99
100 Some(result)
101}
102
103#[cfg(test)]
104mod test {
105 use super::*;
106 use test_utils::assert_eq_text;
107
108 #[test]
109 fn test_remove_derive_attrs() {
110 let tt = mbe::parse_to_token_tree(
111 r#"
112 #[allow(unused)]
113 #[derive(Copy)]
114 #[derive(Hello)]
115 struct A {
116 bar: u32
117 }
118"#,
119 )
120 .unwrap()
121 .0;
122 let result = format!("{:#?}", remove_derive_attrs(&tt).unwrap());
123
124 assert_eq_text!(
125 &result,
126 r#"
127SUBTREE $
128 PUNCH # [alone] 0
129 SUBTREE [] 1
130 IDENT allow 2
131 SUBTREE () 3
132 IDENT unused 4
133 IDENT struct 15
134 IDENT A 16
135 SUBTREE {} 17
136 IDENT bar 18
137 PUNCH : [alone] 19
138 IDENT u32 20
139"#
140 .trim()
141 );
142 }
57} 143}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 188f0df96..2cb3ad011 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -10,17 +10,6 @@ use crate::{
10pub struct SourceFile { 10pub struct SourceFile {
11 pub(crate) syntax: SyntaxNode, 11 pub(crate) syntax: SyntaxNode,
12} 12}
13impl AstNode for SourceFile {
14 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
15 fn cast(syntax: SyntaxNode) -> Option<Self> {
16 if Self::can_cast(syntax.kind()) {
17 Some(Self { syntax })
18 } else {
19 None
20 }
21 }
22 fn syntax(&self) -> &SyntaxNode { &self.syntax }
23}
24impl ast::ModuleItemOwner for SourceFile {} 13impl ast::ModuleItemOwner for SourceFile {}
25impl ast::AttrsOwner for SourceFile {} 14impl ast::AttrsOwner for SourceFile {}
26impl SourceFile { 15impl SourceFile {
@@ -31,17 +20,6 @@ impl SourceFile {
31pub struct FnDef { 20pub struct FnDef {
32 pub(crate) syntax: SyntaxNode, 21 pub(crate) syntax: SyntaxNode,
33} 22}
34impl AstNode for FnDef {
35 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
36 fn cast(syntax: SyntaxNode) -> Option<Self> {
37 if Self::can_cast(syntax.kind()) {
38 Some(Self { syntax })
39 } else {
40 None
41 }
42 }
43 fn syntax(&self) -> &SyntaxNode { &self.syntax }
44}
45impl ast::VisibilityOwner for FnDef {} 23impl ast::VisibilityOwner for FnDef {}
46impl ast::NameOwner for FnDef {} 24impl ast::NameOwner for FnDef {}
47impl ast::TypeParamsOwner for FnDef {} 25impl ast::TypeParamsOwner for FnDef {}
@@ -64,17 +42,6 @@ impl FnDef {
64pub struct RetType { 42pub struct RetType {
65 pub(crate) syntax: SyntaxNode, 43 pub(crate) syntax: SyntaxNode,
66} 44}
67impl AstNode for RetType {
68 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
69 fn cast(syntax: SyntaxNode) -> Option<Self> {
70 if Self::can_cast(syntax.kind()) {
71 Some(Self { syntax })
72 } else {
73 None
74 }
75 }
76 fn syntax(&self) -> &SyntaxNode { &self.syntax }
77}
78impl RetType { 45impl RetType {
79 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } 46 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
80 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 47 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
@@ -84,17 +51,6 @@ impl RetType {
84pub struct StructDef { 51pub struct StructDef {
85 pub(crate) syntax: SyntaxNode, 52 pub(crate) syntax: SyntaxNode,
86} 53}
87impl AstNode for StructDef {
88 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
89 fn cast(syntax: SyntaxNode) -> Option<Self> {
90 if Self::can_cast(syntax.kind()) {
91 Some(Self { syntax })
92 } else {
93 None
94 }
95 }
96 fn syntax(&self) -> &SyntaxNode { &self.syntax }
97}
98impl ast::VisibilityOwner for StructDef {} 54impl ast::VisibilityOwner for StructDef {}
99impl ast::NameOwner for StructDef {} 55impl ast::NameOwner for StructDef {}
100impl ast::TypeParamsOwner for StructDef {} 56impl ast::TypeParamsOwner for StructDef {}
@@ -110,17 +66,6 @@ impl StructDef {
110pub struct UnionDef { 66pub struct UnionDef {
111 pub(crate) syntax: SyntaxNode, 67 pub(crate) syntax: SyntaxNode,
112} 68}
113impl AstNode for UnionDef {
114 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
115 fn cast(syntax: SyntaxNode) -> Option<Self> {
116 if Self::can_cast(syntax.kind()) {
117 Some(Self { syntax })
118 } else {
119 None
120 }
121 }
122 fn syntax(&self) -> &SyntaxNode { &self.syntax }
123}
124impl ast::VisibilityOwner for UnionDef {} 69impl ast::VisibilityOwner for UnionDef {}
125impl ast::NameOwner for UnionDef {} 70impl ast::NameOwner for UnionDef {}
126impl ast::TypeParamsOwner for UnionDef {} 71impl ast::TypeParamsOwner for UnionDef {}
@@ -137,17 +82,6 @@ impl UnionDef {
137pub struct RecordFieldDefList { 82pub struct RecordFieldDefList {
138 pub(crate) syntax: SyntaxNode, 83 pub(crate) syntax: SyntaxNode,
139} 84}
140impl AstNode for RecordFieldDefList {
141 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
142 fn cast(syntax: SyntaxNode) -> Option<Self> {
143 if Self::can_cast(syntax.kind()) {
144 Some(Self { syntax })
145 } else {
146 None
147 }
148 }
149 fn syntax(&self) -> &SyntaxNode { &self.syntax }
150}
151impl RecordFieldDefList { 85impl RecordFieldDefList {
152 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 86 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
153 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } 87 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) }
@@ -158,17 +92,6 @@ impl RecordFieldDefList {
158pub struct RecordFieldDef { 92pub struct RecordFieldDef {
159 pub(crate) syntax: SyntaxNode, 93 pub(crate) syntax: SyntaxNode,
160} 94}
161impl AstNode for RecordFieldDef {
162 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
163 fn cast(syntax: SyntaxNode) -> Option<Self> {
164 if Self::can_cast(syntax.kind()) {
165 Some(Self { syntax })
166 } else {
167 None
168 }
169 }
170 fn syntax(&self) -> &SyntaxNode { &self.syntax }
171}
172impl ast::VisibilityOwner for RecordFieldDef {} 95impl ast::VisibilityOwner for RecordFieldDef {}
173impl ast::NameOwner for RecordFieldDef {} 96impl ast::NameOwner for RecordFieldDef {}
174impl ast::AttrsOwner for RecordFieldDef {} 97impl ast::AttrsOwner for RecordFieldDef {}
@@ -180,17 +103,6 @@ impl RecordFieldDef {}
180pub struct TupleFieldDefList { 103pub struct TupleFieldDefList {
181 pub(crate) syntax: SyntaxNode, 104 pub(crate) syntax: SyntaxNode,
182} 105}
183impl AstNode for TupleFieldDefList {
184 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST }
185 fn cast(syntax: SyntaxNode) -> Option<Self> {
186 if Self::can_cast(syntax.kind()) {
187 Some(Self { syntax })
188 } else {
189 None
190 }
191 }
192 fn syntax(&self) -> &SyntaxNode { &self.syntax }
193}
194impl TupleFieldDefList { 106impl TupleFieldDefList {
195 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 107 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
196 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } 108 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
@@ -201,17 +113,6 @@ impl TupleFieldDefList {
201pub struct TupleFieldDef { 113pub struct TupleFieldDef {
202 pub(crate) syntax: SyntaxNode, 114 pub(crate) syntax: SyntaxNode,
203} 115}
204impl AstNode for TupleFieldDef {
205 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
206 fn cast(syntax: SyntaxNode) -> Option<Self> {
207 if Self::can_cast(syntax.kind()) {
208 Some(Self { syntax })
209 } else {
210 None
211 }
212 }
213 fn syntax(&self) -> &SyntaxNode { &self.syntax }
214}
215impl ast::VisibilityOwner for TupleFieldDef {} 116impl ast::VisibilityOwner for TupleFieldDef {}
216impl ast::AttrsOwner for TupleFieldDef {} 117impl ast::AttrsOwner for TupleFieldDef {}
217impl TupleFieldDef { 118impl TupleFieldDef {
@@ -222,17 +123,6 @@ impl TupleFieldDef {
222pub struct EnumDef { 123pub struct EnumDef {
223 pub(crate) syntax: SyntaxNode, 124 pub(crate) syntax: SyntaxNode,
224} 125}
225impl AstNode for EnumDef {
226 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
227 fn cast(syntax: SyntaxNode) -> Option<Self> {
228 if Self::can_cast(syntax.kind()) {
229 Some(Self { syntax })
230 } else {
231 None
232 }
233 }
234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
235}
236impl ast::VisibilityOwner for EnumDef {} 126impl ast::VisibilityOwner for EnumDef {}
237impl ast::NameOwner for EnumDef {} 127impl ast::NameOwner for EnumDef {}
238impl ast::TypeParamsOwner for EnumDef {} 128impl ast::TypeParamsOwner for EnumDef {}
@@ -247,17 +137,6 @@ impl EnumDef {
247pub struct EnumVariantList { 137pub struct EnumVariantList {
248 pub(crate) syntax: SyntaxNode, 138 pub(crate) syntax: SyntaxNode,
249} 139}
250impl AstNode for EnumVariantList {
251 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST }
252 fn cast(syntax: SyntaxNode) -> Option<Self> {
253 if Self::can_cast(syntax.kind()) {
254 Some(Self { syntax })
255 } else {
256 None
257 }
258 }
259 fn syntax(&self) -> &SyntaxNode { &self.syntax }
260}
261impl EnumVariantList { 140impl EnumVariantList {
262 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 141 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
263 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 142 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) }
@@ -268,17 +147,6 @@ impl EnumVariantList {
268pub struct EnumVariant { 147pub struct EnumVariant {
269 pub(crate) syntax: SyntaxNode, 148 pub(crate) syntax: SyntaxNode,
270} 149}
271impl AstNode for EnumVariant {
272 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT }
273 fn cast(syntax: SyntaxNode) -> Option<Self> {
274 if Self::can_cast(syntax.kind()) {
275 Some(Self { syntax })
276 } else {
277 None
278 }
279 }
280 fn syntax(&self) -> &SyntaxNode { &self.syntax }
281}
282impl ast::VisibilityOwner for EnumVariant {} 150impl ast::VisibilityOwner for EnumVariant {}
283impl ast::NameOwner for EnumVariant {} 151impl ast::NameOwner for EnumVariant {}
284impl ast::DocCommentsOwner for EnumVariant {} 152impl ast::DocCommentsOwner for EnumVariant {}
@@ -293,17 +161,6 @@ impl EnumVariant {
293pub struct TraitDef { 161pub struct TraitDef {
294 pub(crate) syntax: SyntaxNode, 162 pub(crate) syntax: SyntaxNode,
295} 163}
296impl AstNode for TraitDef {
297 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF }
298 fn cast(syntax: SyntaxNode) -> Option<Self> {
299 if Self::can_cast(syntax.kind()) {
300 Some(Self { syntax })
301 } else {
302 None
303 }
304 }
305 fn syntax(&self) -> &SyntaxNode { &self.syntax }
306}
307impl ast::VisibilityOwner for TraitDef {} 164impl ast::VisibilityOwner for TraitDef {}
308impl ast::NameOwner for TraitDef {} 165impl ast::NameOwner for TraitDef {}
309impl ast::AttrsOwner for TraitDef {} 166impl ast::AttrsOwner for TraitDef {}
@@ -321,17 +178,6 @@ impl TraitDef {
321pub struct Module { 178pub struct Module {
322 pub(crate) syntax: SyntaxNode, 179 pub(crate) syntax: SyntaxNode,
323} 180}
324impl AstNode for Module {
325 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
326 fn cast(syntax: SyntaxNode) -> Option<Self> {
327 if Self::can_cast(syntax.kind()) {
328 Some(Self { syntax })
329 } else {
330 None
331 }
332 }
333 fn syntax(&self) -> &SyntaxNode { &self.syntax }
334}
335impl ast::VisibilityOwner for Module {} 181impl ast::VisibilityOwner for Module {}
336impl ast::NameOwner for Module {} 182impl ast::NameOwner for Module {}
337impl ast::AttrsOwner for Module {} 183impl ast::AttrsOwner for Module {}
@@ -346,17 +192,6 @@ impl Module {
346pub struct ItemList { 192pub struct ItemList {
347 pub(crate) syntax: SyntaxNode, 193 pub(crate) syntax: SyntaxNode,
348} 194}
349impl AstNode for ItemList {
350 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
351 fn cast(syntax: SyntaxNode) -> Option<Self> {
352 if Self::can_cast(syntax.kind()) {
353 Some(Self { syntax })
354 } else {
355 None
356 }
357 }
358 fn syntax(&self) -> &SyntaxNode { &self.syntax }
359}
360impl ast::ModuleItemOwner for ItemList {} 195impl ast::ModuleItemOwner for ItemList {}
361impl ItemList { 196impl ItemList {
362 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 197 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
@@ -368,17 +203,6 @@ impl ItemList {
368pub struct ConstDef { 203pub struct ConstDef {
369 pub(crate) syntax: SyntaxNode, 204 pub(crate) syntax: SyntaxNode,
370} 205}
371impl AstNode for ConstDef {
372 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
373 fn cast(syntax: SyntaxNode) -> Option<Self> {
374 if Self::can_cast(syntax.kind()) {
375 Some(Self { syntax })
376 } else {
377 None
378 }
379 }
380 fn syntax(&self) -> &SyntaxNode { &self.syntax }
381}
382impl ast::VisibilityOwner for ConstDef {} 206impl ast::VisibilityOwner for ConstDef {}
383impl ast::NameOwner for ConstDef {} 207impl ast::NameOwner for ConstDef {}
384impl ast::TypeParamsOwner for ConstDef {} 208impl ast::TypeParamsOwner for ConstDef {}
@@ -397,17 +221,6 @@ impl ConstDef {
397pub struct StaticDef { 221pub struct StaticDef {
398 pub(crate) syntax: SyntaxNode, 222 pub(crate) syntax: SyntaxNode,
399} 223}
400impl AstNode for StaticDef {
401 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF }
402 fn cast(syntax: SyntaxNode) -> Option<Self> {
403 if Self::can_cast(syntax.kind()) {
404 Some(Self { syntax })
405 } else {
406 None
407 }
408 }
409 fn syntax(&self) -> &SyntaxNode { &self.syntax }
410}
411impl ast::VisibilityOwner for StaticDef {} 224impl ast::VisibilityOwner for StaticDef {}
412impl ast::NameOwner for StaticDef {} 225impl ast::NameOwner for StaticDef {}
413impl ast::TypeParamsOwner for StaticDef {} 226impl ast::TypeParamsOwner for StaticDef {}
@@ -426,17 +239,6 @@ impl StaticDef {
426pub struct TypeAliasDef { 239pub struct TypeAliasDef {
427 pub(crate) syntax: SyntaxNode, 240 pub(crate) syntax: SyntaxNode,
428} 241}
429impl AstNode for TypeAliasDef {
430 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF }
431 fn cast(syntax: SyntaxNode) -> Option<Self> {
432 if Self::can_cast(syntax.kind()) {
433 Some(Self { syntax })
434 } else {
435 None
436 }
437 }
438 fn syntax(&self) -> &SyntaxNode { &self.syntax }
439}
440impl ast::VisibilityOwner for TypeAliasDef {} 242impl ast::VisibilityOwner for TypeAliasDef {}
441impl ast::NameOwner for TypeAliasDef {} 243impl ast::NameOwner for TypeAliasDef {}
442impl ast::TypeParamsOwner for TypeAliasDef {} 244impl ast::TypeParamsOwner for TypeAliasDef {}
@@ -455,17 +257,6 @@ impl TypeAliasDef {
455pub struct ImplDef { 257pub struct ImplDef {
456 pub(crate) syntax: SyntaxNode, 258 pub(crate) syntax: SyntaxNode,
457} 259}
458impl AstNode for ImplDef {
459 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF }
460 fn cast(syntax: SyntaxNode) -> Option<Self> {
461 if Self::can_cast(syntax.kind()) {
462 Some(Self { syntax })
463 } else {
464 None
465 }
466 }
467 fn syntax(&self) -> &SyntaxNode { &self.syntax }
468}
469impl ast::TypeParamsOwner for ImplDef {} 260impl ast::TypeParamsOwner for ImplDef {}
470impl ast::AttrsOwner for ImplDef {} 261impl ast::AttrsOwner for ImplDef {}
471impl ImplDef { 262impl ImplDef {
@@ -482,8 +273,1262 @@ impl ImplDef {
482pub struct ParenType { 273pub struct ParenType {
483 pub(crate) syntax: SyntaxNode, 274 pub(crate) syntax: SyntaxNode,
484} 275}
485impl AstNode for ParenType { 276impl ParenType {
486 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } 277 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
278 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
279 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
280}
281
282#[derive(Debug, Clone, PartialEq, Eq, Hash)]
283pub struct TupleType {
284 pub(crate) syntax: SyntaxNode,
285}
286impl TupleType {
287 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
288 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
289 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
290}
291
292#[derive(Debug, Clone, PartialEq, Eq, Hash)]
293pub struct NeverType {
294 pub(crate) syntax: SyntaxNode,
295}
296impl NeverType {
297 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
298}
299
300#[derive(Debug, Clone, PartialEq, Eq, Hash)]
301pub struct PathType {
302 pub(crate) syntax: SyntaxNode,
303}
304impl PathType {
305 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
306}
307
308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
309pub struct PointerType {
310 pub(crate) syntax: SyntaxNode,
311}
312impl PointerType {
313 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
314 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
315 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
316 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
317}
318
319#[derive(Debug, Clone, PartialEq, Eq, Hash)]
320pub struct ArrayType {
321 pub(crate) syntax: SyntaxNode,
322}
323impl ArrayType {
324 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
325 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
326 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
327 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
328 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
329}
330
331#[derive(Debug, Clone, PartialEq, Eq, Hash)]
332pub struct SliceType {
333 pub(crate) syntax: SyntaxNode,
334}
335impl SliceType {
336 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
337 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
338 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
339}
340
341#[derive(Debug, Clone, PartialEq, Eq, Hash)]
342pub struct ReferenceType {
343 pub(crate) syntax: SyntaxNode,
344}
345impl ReferenceType {
346 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
347 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
348 support::token(&self.syntax, T![lifetime])
349 }
350 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
351 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
352}
353
354#[derive(Debug, Clone, PartialEq, Eq, Hash)]
355pub struct PlaceholderType {
356 pub(crate) syntax: SyntaxNode,
357}
358impl PlaceholderType {
359 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
360}
361
362#[derive(Debug, Clone, PartialEq, Eq, Hash)]
363pub struct FnPointerType {
364 pub(crate) syntax: SyntaxNode,
365}
366impl FnPointerType {
367 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
368 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
369 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
370 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
371 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
372}
373
374#[derive(Debug, Clone, PartialEq, Eq, Hash)]
375pub struct ForType {
376 pub(crate) syntax: SyntaxNode,
377}
378impl ForType {
379 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
380 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
381 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
382}
383
384#[derive(Debug, Clone, PartialEq, Eq, Hash)]
385pub struct ImplTraitType {
386 pub(crate) syntax: SyntaxNode,
387}
388impl ast::TypeBoundsOwner for ImplTraitType {}
389impl ImplTraitType {
390 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
391}
392
393#[derive(Debug, Clone, PartialEq, Eq, Hash)]
394pub struct DynTraitType {
395 pub(crate) syntax: SyntaxNode,
396}
397impl ast::TypeBoundsOwner for DynTraitType {}
398impl DynTraitType {
399 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
400}
401
402#[derive(Debug, Clone, PartialEq, Eq, Hash)]
403pub struct TupleExpr {
404 pub(crate) syntax: SyntaxNode,
405}
406impl ast::AttrsOwner for TupleExpr {}
407impl TupleExpr {
408 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
409 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
410 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
411}
412
413#[derive(Debug, Clone, PartialEq, Eq, Hash)]
414pub struct ArrayExpr {
415 pub(crate) syntax: SyntaxNode,
416}
417impl ast::AttrsOwner for ArrayExpr {}
418impl ArrayExpr {
419 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
420 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
421 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
422 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
423}
424
425#[derive(Debug, Clone, PartialEq, Eq, Hash)]
426pub struct ParenExpr {
427 pub(crate) syntax: SyntaxNode,
428}
429impl ast::AttrsOwner for ParenExpr {}
430impl ParenExpr {
431 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
432 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
433 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
434}
435
436#[derive(Debug, Clone, PartialEq, Eq, Hash)]
437pub struct PathExpr {
438 pub(crate) syntax: SyntaxNode,
439}
440impl PathExpr {
441 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
442}
443
444#[derive(Debug, Clone, PartialEq, Eq, Hash)]
445pub struct LambdaExpr {
446 pub(crate) syntax: SyntaxNode,
447}
448impl ast::AttrsOwner for LambdaExpr {}
449impl LambdaExpr {
450 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
451 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
452 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
453 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
454 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
455 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
456}
457
458#[derive(Debug, Clone, PartialEq, Eq, Hash)]
459pub struct IfExpr {
460 pub(crate) syntax: SyntaxNode,
461}
462impl ast::AttrsOwner for IfExpr {}
463impl IfExpr {
464 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
465 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
466}
467
468#[derive(Debug, Clone, PartialEq, Eq, Hash)]
469pub struct LoopExpr {
470 pub(crate) syntax: SyntaxNode,
471}
472impl ast::AttrsOwner for LoopExpr {}
473impl ast::LoopBodyOwner for LoopExpr {}
474impl LoopExpr {
475 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
476}
477
478#[derive(Debug, Clone, PartialEq, Eq, Hash)]
479pub struct TryBlockExpr {
480 pub(crate) syntax: SyntaxNode,
481}
482impl ast::AttrsOwner for TryBlockExpr {}
483impl TryBlockExpr {
484 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
485 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
486}
487
488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
489pub struct ForExpr {
490 pub(crate) syntax: SyntaxNode,
491}
492impl ast::AttrsOwner for ForExpr {}
493impl ast::LoopBodyOwner for ForExpr {}
494impl ForExpr {
495 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
496 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
497 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
498 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
499}
500
501#[derive(Debug, Clone, PartialEq, Eq, Hash)]
502pub struct WhileExpr {
503 pub(crate) syntax: SyntaxNode,
504}
505impl ast::AttrsOwner for WhileExpr {}
506impl ast::LoopBodyOwner for WhileExpr {}
507impl WhileExpr {
508 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
509 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
510}
511
512#[derive(Debug, Clone, PartialEq, Eq, Hash)]
513pub struct ContinueExpr {
514 pub(crate) syntax: SyntaxNode,
515}
516impl ast::AttrsOwner for ContinueExpr {}
517impl ContinueExpr {
518 pub fn continue_token(&self) -> Option<SyntaxToken> {
519 support::token(&self.syntax, T![continue])
520 }
521 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
522 support::token(&self.syntax, T![lifetime])
523 }
524}
525
526#[derive(Debug, Clone, PartialEq, Eq, Hash)]
527pub struct BreakExpr {
528 pub(crate) syntax: SyntaxNode,
529}
530impl ast::AttrsOwner for BreakExpr {}
531impl BreakExpr {
532 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
533 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
534 support::token(&self.syntax, T![lifetime])
535 }
536 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
537}
538
539#[derive(Debug, Clone, PartialEq, Eq, Hash)]
540pub struct Label {
541 pub(crate) syntax: SyntaxNode,
542}
543impl Label {
544 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
545 support::token(&self.syntax, T![lifetime])
546 }
547}
548
549#[derive(Debug, Clone, PartialEq, Eq, Hash)]
550pub struct BlockExpr {
551 pub(crate) syntax: SyntaxNode,
552}
553impl ast::AttrsOwner for BlockExpr {}
554impl BlockExpr {
555 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
556 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
557 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
558}
559
560#[derive(Debug, Clone, PartialEq, Eq, Hash)]
561pub struct ReturnExpr {
562 pub(crate) syntax: SyntaxNode,
563}
564impl ast::AttrsOwner for ReturnExpr {}
565impl ReturnExpr {
566 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
567}
568
569#[derive(Debug, Clone, PartialEq, Eq, Hash)]
570pub struct CallExpr {
571 pub(crate) syntax: SyntaxNode,
572}
573impl ast::ArgListOwner for CallExpr {}
574impl CallExpr {
575 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
576}
577
578#[derive(Debug, Clone, PartialEq, Eq, Hash)]
579pub struct MethodCallExpr {
580 pub(crate) syntax: SyntaxNode,
581}
582impl ast::AttrsOwner for MethodCallExpr {}
583impl ast::ArgListOwner for MethodCallExpr {}
584impl MethodCallExpr {
585 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
586 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
587 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
588 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
589}
590
591#[derive(Debug, Clone, PartialEq, Eq, Hash)]
592pub struct IndexExpr {
593 pub(crate) syntax: SyntaxNode,
594}
595impl ast::AttrsOwner for IndexExpr {}
596impl IndexExpr {
597 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
598 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
599}
600
601#[derive(Debug, Clone, PartialEq, Eq, Hash)]
602pub struct FieldExpr {
603 pub(crate) syntax: SyntaxNode,
604}
605impl ast::AttrsOwner for FieldExpr {}
606impl FieldExpr {
607 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
608 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
609 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
610}
611
612#[derive(Debug, Clone, PartialEq, Eq, Hash)]
613pub struct AwaitExpr {
614 pub(crate) syntax: SyntaxNode,
615}
616impl ast::AttrsOwner for AwaitExpr {}
617impl AwaitExpr {
618 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
619 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
620 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
621}
622
623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
624pub struct TryExpr {
625 pub(crate) syntax: SyntaxNode,
626}
627impl ast::AttrsOwner for TryExpr {}
628impl TryExpr {
629 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
630 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
631}
632
633#[derive(Debug, Clone, PartialEq, Eq, Hash)]
634pub struct CastExpr {
635 pub(crate) syntax: SyntaxNode,
636}
637impl ast::AttrsOwner for CastExpr {}
638impl CastExpr {
639 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
640 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
641 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
642}
643
644#[derive(Debug, Clone, PartialEq, Eq, Hash)]
645pub struct RefExpr {
646 pub(crate) syntax: SyntaxNode,
647}
648impl ast::AttrsOwner for RefExpr {}
649impl RefExpr {
650 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
651 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) }
652 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
653 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
654}
655
656#[derive(Debug, Clone, PartialEq, Eq, Hash)]
657pub struct PrefixExpr {
658 pub(crate) syntax: SyntaxNode,
659}
660impl ast::AttrsOwner for PrefixExpr {}
661impl PrefixExpr {
662 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
663}
664
665#[derive(Debug, Clone, PartialEq, Eq, Hash)]
666pub struct BoxExpr {
667 pub(crate) syntax: SyntaxNode,
668}
669impl ast::AttrsOwner for BoxExpr {}
670impl BoxExpr {
671 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
672 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
673}
674
675#[derive(Debug, Clone, PartialEq, Eq, Hash)]
676pub struct RangeExpr {
677 pub(crate) syntax: SyntaxNode,
678}
679impl ast::AttrsOwner for RangeExpr {}
680impl RangeExpr {}
681
682#[derive(Debug, Clone, PartialEq, Eq, Hash)]
683pub struct BinExpr {
684 pub(crate) syntax: SyntaxNode,
685}
686impl ast::AttrsOwner for BinExpr {}
687impl BinExpr {}
688
689#[derive(Debug, Clone, PartialEq, Eq, Hash)]
690pub struct Literal {
691 pub(crate) syntax: SyntaxNode,
692}
693impl Literal {}
694
695#[derive(Debug, Clone, PartialEq, Eq, Hash)]
696pub struct MatchExpr {
697 pub(crate) syntax: SyntaxNode,
698}
699impl ast::AttrsOwner for MatchExpr {}
700impl MatchExpr {
701 pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) }
702 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
703 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
704}
705
706#[derive(Debug, Clone, PartialEq, Eq, Hash)]
707pub struct MatchArmList {
708 pub(crate) syntax: SyntaxNode,
709}
710impl ast::AttrsOwner for MatchArmList {}
711impl MatchArmList {
712 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
713 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
714 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
715}
716
717#[derive(Debug, Clone, PartialEq, Eq, Hash)]
718pub struct MatchArm {
719 pub(crate) syntax: SyntaxNode,
720}
721impl ast::AttrsOwner for MatchArm {}
722impl MatchArm {
723 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
724 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
725 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
726 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
727}
728
729#[derive(Debug, Clone, PartialEq, Eq, Hash)]
730pub struct MatchGuard {
731 pub(crate) syntax: SyntaxNode,
732}
733impl MatchGuard {
734 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
735 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
736}
737
738#[derive(Debug, Clone, PartialEq, Eq, Hash)]
739pub struct RecordLit {
740 pub(crate) syntax: SyntaxNode,
741}
742impl RecordLit {
743 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
744 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
745}
746
747#[derive(Debug, Clone, PartialEq, Eq, Hash)]
748pub struct RecordFieldList {
749 pub(crate) syntax: SyntaxNode,
750}
751impl RecordFieldList {
752 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
753 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
754 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
755 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
756 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
757}
758
759#[derive(Debug, Clone, PartialEq, Eq, Hash)]
760pub struct RecordField {
761 pub(crate) syntax: SyntaxNode,
762}
763impl ast::AttrsOwner for RecordField {}
764impl RecordField {
765 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
766 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
767 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
768}
769
770#[derive(Debug, Clone, PartialEq, Eq, Hash)]
771pub struct OrPat {
772 pub(crate) syntax: SyntaxNode,
773}
774impl OrPat {
775 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
776}
777
778#[derive(Debug, Clone, PartialEq, Eq, Hash)]
779pub struct ParenPat {
780 pub(crate) syntax: SyntaxNode,
781}
782impl ParenPat {
783 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
784 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
785 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
786}
787
788#[derive(Debug, Clone, PartialEq, Eq, Hash)]
789pub struct RefPat {
790 pub(crate) syntax: SyntaxNode,
791}
792impl RefPat {
793 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
794 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
795 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
796}
797
798#[derive(Debug, Clone, PartialEq, Eq, Hash)]
799pub struct BoxPat {
800 pub(crate) syntax: SyntaxNode,
801}
802impl BoxPat {
803 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
804 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
805}
806
807#[derive(Debug, Clone, PartialEq, Eq, Hash)]
808pub struct BindPat {
809 pub(crate) syntax: SyntaxNode,
810}
811impl ast::AttrsOwner for BindPat {}
812impl ast::NameOwner for BindPat {}
813impl BindPat {
814 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
815 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
816 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
817 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
818}
819
820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
821pub struct PlaceholderPat {
822 pub(crate) syntax: SyntaxNode,
823}
824impl PlaceholderPat {
825 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
826}
827
828#[derive(Debug, Clone, PartialEq, Eq, Hash)]
829pub struct DotDotPat {
830 pub(crate) syntax: SyntaxNode,
831}
832impl DotDotPat {
833 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
834}
835
836#[derive(Debug, Clone, PartialEq, Eq, Hash)]
837pub struct PathPat {
838 pub(crate) syntax: SyntaxNode,
839}
840impl PathPat {
841 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
842}
843
844#[derive(Debug, Clone, PartialEq, Eq, Hash)]
845pub struct SlicePat {
846 pub(crate) syntax: SyntaxNode,
847}
848impl SlicePat {
849 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
850 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
851 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
852}
853
854#[derive(Debug, Clone, PartialEq, Eq, Hash)]
855pub struct RangePat {
856 pub(crate) syntax: SyntaxNode,
857}
858impl RangePat {}
859
860#[derive(Debug, Clone, PartialEq, Eq, Hash)]
861pub struct LiteralPat {
862 pub(crate) syntax: SyntaxNode,
863}
864impl LiteralPat {
865 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
866}
867
868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
869pub struct MacroPat {
870 pub(crate) syntax: SyntaxNode,
871}
872impl MacroPat {
873 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
874}
875
876#[derive(Debug, Clone, PartialEq, Eq, Hash)]
877pub struct RecordPat {
878 pub(crate) syntax: SyntaxNode,
879}
880impl RecordPat {
881 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
882 support::child(&self.syntax)
883 }
884 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
885}
886
887#[derive(Debug, Clone, PartialEq, Eq, Hash)]
888pub struct RecordFieldPatList {
889 pub(crate) syntax: SyntaxNode,
890}
891impl RecordFieldPatList {
892 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
893 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
894 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
895 support::children(&self.syntax)
896 }
897 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
898 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
899 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
900}
901
902#[derive(Debug, Clone, PartialEq, Eq, Hash)]
903pub struct RecordFieldPat {
904 pub(crate) syntax: SyntaxNode,
905}
906impl ast::AttrsOwner for RecordFieldPat {}
907impl RecordFieldPat {
908 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
909 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
910 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
911}
912
913#[derive(Debug, Clone, PartialEq, Eq, Hash)]
914pub struct TupleStructPat {
915 pub(crate) syntax: SyntaxNode,
916}
917impl TupleStructPat {
918 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
919 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
920 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
921 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
922}
923
924#[derive(Debug, Clone, PartialEq, Eq, Hash)]
925pub struct TuplePat {
926 pub(crate) syntax: SyntaxNode,
927}
928impl TuplePat {
929 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
930 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
931 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
932}
933
934#[derive(Debug, Clone, PartialEq, Eq, Hash)]
935pub struct Visibility {
936 pub(crate) syntax: SyntaxNode,
937}
938impl Visibility {
939 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
940 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
941 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
942 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
943}
944
945#[derive(Debug, Clone, PartialEq, Eq, Hash)]
946pub struct Name {
947 pub(crate) syntax: SyntaxNode,
948}
949impl Name {
950 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
951}
952
953#[derive(Debug, Clone, PartialEq, Eq, Hash)]
954pub struct NameRef {
955 pub(crate) syntax: SyntaxNode,
956}
957impl NameRef {}
958
959#[derive(Debug, Clone, PartialEq, Eq, Hash)]
960pub struct MacroCall {
961 pub(crate) syntax: SyntaxNode,
962}
963impl ast::NameOwner for MacroCall {}
964impl ast::AttrsOwner for MacroCall {}
965impl ast::DocCommentsOwner for MacroCall {}
966impl MacroCall {
967 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
968 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
969 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
970 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
971}
972
973#[derive(Debug, Clone, PartialEq, Eq, Hash)]
974pub struct Attr {
975 pub(crate) syntax: SyntaxNode,
976}
977impl Attr {
978 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
979 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
980 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
981 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
982 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
983 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
984 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
985}
986
987#[derive(Debug, Clone, PartialEq, Eq, Hash)]
988pub struct TokenTree {
989 pub(crate) syntax: SyntaxNode,
990}
991impl TokenTree {}
992
993#[derive(Debug, Clone, PartialEq, Eq, Hash)]
994pub struct TypeParamList {
995 pub(crate) syntax: SyntaxNode,
996}
997impl TypeParamList {
998 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
999 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1000 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1001 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1002 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1003 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1004}
1005
1006#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1007pub struct TypeParam {
1008 pub(crate) syntax: SyntaxNode,
1009}
1010impl ast::NameOwner for TypeParam {}
1011impl ast::AttrsOwner for TypeParam {}
1012impl ast::TypeBoundsOwner for TypeParam {}
1013impl TypeParam {
1014 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1015 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1016}
1017
1018#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1019pub struct ConstParam {
1020 pub(crate) syntax: SyntaxNode,
1021}
1022impl ast::NameOwner for ConstParam {}
1023impl ast::AttrsOwner for ConstParam {}
1024impl ast::TypeAscriptionOwner for ConstParam {}
1025impl ConstParam {
1026 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1027 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1028}
1029
1030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1031pub struct LifetimeParam {
1032 pub(crate) syntax: SyntaxNode,
1033}
1034impl ast::AttrsOwner for LifetimeParam {}
1035impl LifetimeParam {
1036 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1037 support::token(&self.syntax, T![lifetime])
1038 }
1039}
1040
1041#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1042pub struct TypeBound {
1043 pub(crate) syntax: SyntaxNode,
1044}
1045impl TypeBound {
1046 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1047 support::token(&self.syntax, T![lifetime])
1048 }
1049 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1050 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1051}
1052
1053#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054pub struct TypeBoundList {
1055 pub(crate) syntax: SyntaxNode,
1056}
1057impl TypeBoundList {
1058 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
1059}
1060
1061#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1062pub struct WherePred {
1063 pub(crate) syntax: SyntaxNode,
1064}
1065impl ast::TypeBoundsOwner for WherePred {}
1066impl WherePred {
1067 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1068 support::token(&self.syntax, T![lifetime])
1069 }
1070 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1071}
1072
1073#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1074pub struct WhereClause {
1075 pub(crate) syntax: SyntaxNode,
1076}
1077impl WhereClause {
1078 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
1079 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
1080}
1081
1082#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1083pub struct Abi {
1084 pub(crate) syntax: SyntaxNode,
1085}
1086impl Abi {}
1087
1088#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1089pub struct ExprStmt {
1090 pub(crate) syntax: SyntaxNode,
1091}
1092impl ast::AttrsOwner for ExprStmt {}
1093impl ExprStmt {
1094 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1095 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1096}
1097
1098#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1099pub struct LetStmt {
1100 pub(crate) syntax: SyntaxNode,
1101}
1102impl ast::AttrsOwner for LetStmt {}
1103impl ast::TypeAscriptionOwner for LetStmt {}
1104impl LetStmt {
1105 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
1106 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1107 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1108 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
1109 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1110}
1111
1112#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1113pub struct Condition {
1114 pub(crate) syntax: SyntaxNode,
1115}
1116impl Condition {
1117 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
1118 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1119 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1120 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1121}
1122
1123#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1124pub struct Block {
1125 pub(crate) syntax: SyntaxNode,
1126}
1127impl ast::AttrsOwner for Block {}
1128impl ast::ModuleItemOwner for Block {}
1129impl Block {
1130 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1131 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1132 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1133 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1134}
1135
1136#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1137pub struct ParamList {
1138 pub(crate) syntax: SyntaxNode,
1139}
1140impl ParamList {
1141 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1142 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
1143 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
1144 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1145}
1146
1147#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1148pub struct SelfParam {
1149 pub(crate) syntax: SyntaxNode,
1150}
1151impl ast::TypeAscriptionOwner for SelfParam {}
1152impl ast::AttrsOwner for SelfParam {}
1153impl SelfParam {
1154 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1155 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1156 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1157 support::token(&self.syntax, T![lifetime])
1158 }
1159 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1160}
1161
1162#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1163pub struct Param {
1164 pub(crate) syntax: SyntaxNode,
1165}
1166impl ast::TypeAscriptionOwner for Param {}
1167impl ast::AttrsOwner for Param {}
1168impl Param {
1169 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1170 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
1171}
1172
1173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1174pub struct UseItem {
1175 pub(crate) syntax: SyntaxNode,
1176}
1177impl ast::AttrsOwner for UseItem {}
1178impl ast::VisibilityOwner for UseItem {}
1179impl UseItem {
1180 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
1181 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
1182}
1183
1184#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1185pub struct UseTree {
1186 pub(crate) syntax: SyntaxNode,
1187}
1188impl UseTree {
1189 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1190 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
1191 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
1192 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
1193}
1194
1195#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1196pub struct Alias {
1197 pub(crate) syntax: SyntaxNode,
1198}
1199impl ast::NameOwner for Alias {}
1200impl Alias {
1201 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1202}
1203
1204#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1205pub struct UseTreeList {
1206 pub(crate) syntax: SyntaxNode,
1207}
1208impl UseTreeList {
1209 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1210 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
1211 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1212}
1213
1214#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1215pub struct ExternCrateItem {
1216 pub(crate) syntax: SyntaxNode,
1217}
1218impl ast::AttrsOwner for ExternCrateItem {}
1219impl ast::VisibilityOwner for ExternCrateItem {}
1220impl ExternCrateItem {
1221 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
1222 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1223 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1224 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
1225}
1226
1227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1228pub struct ArgList {
1229 pub(crate) syntax: SyntaxNode,
1230}
1231impl ArgList {
1232 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1233 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
1234 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1235}
1236
1237#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1238pub struct Path {
1239 pub(crate) syntax: SyntaxNode,
1240}
1241impl Path {
1242 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
1243 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
1244}
1245
1246#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1247pub struct PathSegment {
1248 pub(crate) syntax: SyntaxNode,
1249}
1250impl PathSegment {
1251 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
1252 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1253 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1254 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1255 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
1256 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
1257 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
1258 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1259}
1260
1261#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1262pub struct TypeArgList {
1263 pub(crate) syntax: SyntaxNode,
1264}
1265impl TypeArgList {
1266 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
1267 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1268 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
1269 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
1270 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
1271 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
1272 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
1273 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1274}
1275
1276#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1277pub struct TypeArg {
1278 pub(crate) syntax: SyntaxNode,
1279}
1280impl TypeArg {
1281 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1282}
1283
1284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1285pub struct AssocTypeArg {
1286 pub(crate) syntax: SyntaxNode,
1287}
1288impl ast::TypeBoundsOwner for AssocTypeArg {}
1289impl AssocTypeArg {
1290 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1291 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1292 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1293}
1294
1295#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1296pub struct LifetimeArg {
1297 pub(crate) syntax: SyntaxNode,
1298}
1299impl LifetimeArg {
1300 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1301 support::token(&self.syntax, T![lifetime])
1302 }
1303}
1304
1305#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1306pub struct ConstArg {
1307 pub(crate) syntax: SyntaxNode,
1308}
1309impl ConstArg {
1310 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1311 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1312 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
1313}
1314
1315#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1316pub struct MacroItems {
1317 pub(crate) syntax: SyntaxNode,
1318}
1319impl ast::ModuleItemOwner for MacroItems {}
1320impl MacroItems {}
1321
1322#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1323pub struct MacroStmts {
1324 pub(crate) syntax: SyntaxNode,
1325}
1326impl MacroStmts {
1327 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1328 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1329}
1330
1331#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1332pub struct ExternItemList {
1333 pub(crate) syntax: SyntaxNode,
1334}
1335impl ast::ModuleItemOwner for ExternItemList {}
1336impl ExternItemList {
1337 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1338 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
1339 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1340}
1341
1342#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1343pub struct ExternBlock {
1344 pub(crate) syntax: SyntaxNode,
1345}
1346impl ExternBlock {
1347 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
1348 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
1349}
1350
1351#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1352pub struct MetaItem {
1353 pub(crate) syntax: SyntaxNode,
1354}
1355impl MetaItem {
1356 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1357 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1358 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1359 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
1360}
1361
1362#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1363pub struct MacroDef {
1364 pub(crate) syntax: SyntaxNode,
1365}
1366impl MacroDef {
1367 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
1368 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1369}
1370
1371#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1372pub enum NominalDef {
1373 StructDef(StructDef),
1374 EnumDef(EnumDef),
1375 UnionDef(UnionDef),
1376}
1377impl ast::NameOwner for NominalDef {}
1378impl ast::TypeParamsOwner for NominalDef {}
1379impl ast::AttrsOwner for NominalDef {}
1380
1381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1382pub enum GenericParam {
1383 LifetimeParam(LifetimeParam),
1384 TypeParam(TypeParam),
1385 ConstParam(ConstParam),
1386}
1387
1388#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1389pub enum GenericArg {
1390 LifetimeArg(LifetimeArg),
1391 TypeArg(TypeArg),
1392 ConstArg(ConstArg),
1393 AssocTypeArg(AssocTypeArg),
1394}
1395
1396#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1397pub enum TypeRef {
1398 ParenType(ParenType),
1399 TupleType(TupleType),
1400 NeverType(NeverType),
1401 PathType(PathType),
1402 PointerType(PointerType),
1403 ArrayType(ArrayType),
1404 SliceType(SliceType),
1405 ReferenceType(ReferenceType),
1406 PlaceholderType(PlaceholderType),
1407 FnPointerType(FnPointerType),
1408 ForType(ForType),
1409 ImplTraitType(ImplTraitType),
1410 DynTraitType(DynTraitType),
1411}
1412
1413#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1414pub enum ModuleItem {
1415 StructDef(StructDef),
1416 UnionDef(UnionDef),
1417 EnumDef(EnumDef),
1418 FnDef(FnDef),
1419 TraitDef(TraitDef),
1420 TypeAliasDef(TypeAliasDef),
1421 ImplDef(ImplDef),
1422 UseItem(UseItem),
1423 ExternCrateItem(ExternCrateItem),
1424 ConstDef(ConstDef),
1425 StaticDef(StaticDef),
1426 Module(Module),
1427 MacroCall(MacroCall),
1428 ExternBlock(ExternBlock),
1429}
1430impl ast::NameOwner for ModuleItem {}
1431impl ast::AttrsOwner for ModuleItem {}
1432impl ast::VisibilityOwner for ModuleItem {}
1433
1434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1435pub enum ImplItem {
1436 FnDef(FnDef),
1437 TypeAliasDef(TypeAliasDef),
1438 ConstDef(ConstDef),
1439}
1440impl ast::NameOwner for ImplItem {}
1441impl ast::AttrsOwner for ImplItem {}
1442
1443#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1444pub enum ExternItem {
1445 FnDef(FnDef),
1446 StaticDef(StaticDef),
1447}
1448impl ast::NameOwner for ExternItem {}
1449impl ast::AttrsOwner for ExternItem {}
1450impl ast::VisibilityOwner for ExternItem {}
1451
1452#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1453pub enum Expr {
1454 TupleExpr(TupleExpr),
1455 ArrayExpr(ArrayExpr),
1456 ParenExpr(ParenExpr),
1457 PathExpr(PathExpr),
1458 LambdaExpr(LambdaExpr),
1459 IfExpr(IfExpr),
1460 LoopExpr(LoopExpr),
1461 ForExpr(ForExpr),
1462 WhileExpr(WhileExpr),
1463 ContinueExpr(ContinueExpr),
1464 BreakExpr(BreakExpr),
1465 Label(Label),
1466 BlockExpr(BlockExpr),
1467 ReturnExpr(ReturnExpr),
1468 MatchExpr(MatchExpr),
1469 RecordLit(RecordLit),
1470 CallExpr(CallExpr),
1471 IndexExpr(IndexExpr),
1472 MethodCallExpr(MethodCallExpr),
1473 FieldExpr(FieldExpr),
1474 AwaitExpr(AwaitExpr),
1475 TryExpr(TryExpr),
1476 TryBlockExpr(TryBlockExpr),
1477 CastExpr(CastExpr),
1478 RefExpr(RefExpr),
1479 PrefixExpr(PrefixExpr),
1480 RangeExpr(RangeExpr),
1481 BinExpr(BinExpr),
1482 Literal(Literal),
1483 MacroCall(MacroCall),
1484 BoxExpr(BoxExpr),
1485}
1486impl ast::AttrsOwner for Expr {}
1487
1488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1489pub enum Pat {
1490 OrPat(OrPat),
1491 ParenPat(ParenPat),
1492 RefPat(RefPat),
1493 BoxPat(BoxPat),
1494 BindPat(BindPat),
1495 PlaceholderPat(PlaceholderPat),
1496 DotDotPat(DotDotPat),
1497 PathPat(PathPat),
1498 RecordPat(RecordPat),
1499 TupleStructPat(TupleStructPat),
1500 TuplePat(TuplePat),
1501 SlicePat(SlicePat),
1502 RangePat(RangePat),
1503 LiteralPat(LiteralPat),
1504 MacroPat(MacroPat),
1505}
1506
1507#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1508pub enum RecordInnerPat {
1509 RecordFieldPat(RecordFieldPat),
1510 BindPat(BindPat),
1511}
1512
1513#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1514pub enum AttrInput {
1515 Literal(Literal),
1516 TokenTree(TokenTree),
1517}
1518
1519#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1520pub enum Stmt {
1521 LetStmt(LetStmt),
1522 ExprStmt(ExprStmt),
1523}
1524
1525#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1526pub enum FieldDefList {
1527 RecordFieldDefList(RecordFieldDefList),
1528 TupleFieldDefList(TupleFieldDefList),
1529}
1530impl AstNode for SourceFile {
1531 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
487 fn cast(syntax: SyntaxNode) -> Option<Self> { 1532 fn cast(syntax: SyntaxNode) -> Option<Self> {
488 if Self::can_cast(syntax.kind()) { 1533 if Self::can_cast(syntax.kind()) {
489 Some(Self { syntax }) 1534 Some(Self { syntax })
@@ -493,18 +1538,30 @@ impl AstNode for ParenType {
493 } 1538 }
494 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
495} 1540}
496impl ParenType { 1541impl AstNode for FnDef {
497 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 1542 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
498 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1543 fn cast(syntax: SyntaxNode) -> Option<Self> {
499 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1544 if Self::can_cast(syntax.kind()) {
1545 Some(Self { syntax })
1546 } else {
1547 None
1548 }
1549 }
1550 fn syntax(&self) -> &SyntaxNode { &self.syntax }
500} 1551}
501 1552impl AstNode for RetType {
502#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1553 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
503pub struct TupleType { 1554 fn cast(syntax: SyntaxNode) -> Option<Self> {
504 pub(crate) syntax: SyntaxNode, 1555 if Self::can_cast(syntax.kind()) {
1556 Some(Self { syntax })
1557 } else {
1558 None
1559 }
1560 }
1561 fn syntax(&self) -> &SyntaxNode { &self.syntax }
505} 1562}
506impl AstNode for TupleType { 1563impl AstNode for StructDef {
507 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE } 1564 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
508 fn cast(syntax: SyntaxNode) -> Option<Self> { 1565 fn cast(syntax: SyntaxNode) -> Option<Self> {
509 if Self::can_cast(syntax.kind()) { 1566 if Self::can_cast(syntax.kind()) {
510 Some(Self { syntax }) 1567 Some(Self { syntax })
@@ -514,18 +1571,30 @@ impl AstNode for TupleType {
514 } 1571 }
515 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1572 fn syntax(&self) -> &SyntaxNode { &self.syntax }
516} 1573}
517impl TupleType { 1574impl AstNode for UnionDef {
518 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 1575 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
519 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 1576 fn cast(syntax: SyntaxNode) -> Option<Self> {
520 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1577 if Self::can_cast(syntax.kind()) {
1578 Some(Self { syntax })
1579 } else {
1580 None
1581 }
1582 }
1583 fn syntax(&self) -> &SyntaxNode { &self.syntax }
521} 1584}
522 1585impl AstNode for RecordFieldDefList {
523#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1586 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
524pub struct NeverType { 1587 fn cast(syntax: SyntaxNode) -> Option<Self> {
525 pub(crate) syntax: SyntaxNode, 1588 if Self::can_cast(syntax.kind()) {
1589 Some(Self { syntax })
1590 } else {
1591 None
1592 }
1593 }
1594 fn syntax(&self) -> &SyntaxNode { &self.syntax }
526} 1595}
527impl AstNode for NeverType { 1596impl AstNode for RecordFieldDef {
528 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } 1597 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
529 fn cast(syntax: SyntaxNode) -> Option<Self> { 1598 fn cast(syntax: SyntaxNode) -> Option<Self> {
530 if Self::can_cast(syntax.kind()) { 1599 if Self::can_cast(syntax.kind()) {
531 Some(Self { syntax }) 1600 Some(Self { syntax })
@@ -535,16 +1604,30 @@ impl AstNode for NeverType {
535 } 1604 }
536 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1605 fn syntax(&self) -> &SyntaxNode { &self.syntax }
537} 1606}
538impl NeverType { 1607impl AstNode for TupleFieldDefList {
539 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 1608 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST }
1609 fn cast(syntax: SyntaxNode) -> Option<Self> {
1610 if Self::can_cast(syntax.kind()) {
1611 Some(Self { syntax })
1612 } else {
1613 None
1614 }
1615 }
1616 fn syntax(&self) -> &SyntaxNode { &self.syntax }
540} 1617}
541 1618impl AstNode for TupleFieldDef {
542#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1619 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
543pub struct PathType { 1620 fn cast(syntax: SyntaxNode) -> Option<Self> {
544 pub(crate) syntax: SyntaxNode, 1621 if Self::can_cast(syntax.kind()) {
1622 Some(Self { syntax })
1623 } else {
1624 None
1625 }
1626 }
1627 fn syntax(&self) -> &SyntaxNode { &self.syntax }
545} 1628}
546impl AstNode for PathType { 1629impl AstNode for EnumDef {
547 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } 1630 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
548 fn cast(syntax: SyntaxNode) -> Option<Self> { 1631 fn cast(syntax: SyntaxNode) -> Option<Self> {
549 if Self::can_cast(syntax.kind()) { 1632 if Self::can_cast(syntax.kind()) {
550 Some(Self { syntax }) 1633 Some(Self { syntax })
@@ -554,16 +1637,30 @@ impl AstNode for PathType {
554 } 1637 }
555 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1638 fn syntax(&self) -> &SyntaxNode { &self.syntax }
556} 1639}
557impl PathType { 1640impl AstNode for EnumVariantList {
558 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1641 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST }
1642 fn cast(syntax: SyntaxNode) -> Option<Self> {
1643 if Self::can_cast(syntax.kind()) {
1644 Some(Self { syntax })
1645 } else {
1646 None
1647 }
1648 }
1649 fn syntax(&self) -> &SyntaxNode { &self.syntax }
559} 1650}
560 1651impl AstNode for EnumVariant {
561#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1652 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT }
562pub struct PointerType { 1653 fn cast(syntax: SyntaxNode) -> Option<Self> {
563 pub(crate) syntax: SyntaxNode, 1654 if Self::can_cast(syntax.kind()) {
1655 Some(Self { syntax })
1656 } else {
1657 None
1658 }
1659 }
1660 fn syntax(&self) -> &SyntaxNode { &self.syntax }
564} 1661}
565impl AstNode for PointerType { 1662impl AstNode for TraitDef {
566 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } 1663 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF }
567 fn cast(syntax: SyntaxNode) -> Option<Self> { 1664 fn cast(syntax: SyntaxNode) -> Option<Self> {
568 if Self::can_cast(syntax.kind()) { 1665 if Self::can_cast(syntax.kind()) {
569 Some(Self { syntax }) 1666 Some(Self { syntax })
@@ -573,19 +1670,30 @@ impl AstNode for PointerType {
573 } 1670 }
574 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1671 fn syntax(&self) -> &SyntaxNode { &self.syntax }
575} 1672}
576impl PointerType { 1673impl AstNode for Module {
577 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 1674 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
578 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1675 fn cast(syntax: SyntaxNode) -> Option<Self> {
579 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1676 if Self::can_cast(syntax.kind()) {
580 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1677 Some(Self { syntax })
1678 } else {
1679 None
1680 }
1681 }
1682 fn syntax(&self) -> &SyntaxNode { &self.syntax }
581} 1683}
582 1684impl AstNode for ItemList {
583#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1685 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
584pub struct ArrayType { 1686 fn cast(syntax: SyntaxNode) -> Option<Self> {
585 pub(crate) syntax: SyntaxNode, 1687 if Self::can_cast(syntax.kind()) {
1688 Some(Self { syntax })
1689 } else {
1690 None
1691 }
1692 }
1693 fn syntax(&self) -> &SyntaxNode { &self.syntax }
586} 1694}
587impl AstNode for ArrayType { 1695impl AstNode for ConstDef {
588 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE } 1696 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
589 fn cast(syntax: SyntaxNode) -> Option<Self> { 1697 fn cast(syntax: SyntaxNode) -> Option<Self> {
590 if Self::can_cast(syntax.kind()) { 1698 if Self::can_cast(syntax.kind()) {
591 Some(Self { syntax }) 1699 Some(Self { syntax })
@@ -595,20 +1703,30 @@ impl AstNode for ArrayType {
595 } 1703 }
596 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1704 fn syntax(&self) -> &SyntaxNode { &self.syntax }
597} 1705}
598impl ArrayType { 1706impl AstNode for StaticDef {
599 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 1707 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF }
600 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1708 fn cast(syntax: SyntaxNode) -> Option<Self> {
601 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1709 if Self::can_cast(syntax.kind()) {
602 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1710 Some(Self { syntax })
603 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 1711 } else {
1712 None
1713 }
1714 }
1715 fn syntax(&self) -> &SyntaxNode { &self.syntax }
604} 1716}
605 1717impl AstNode for TypeAliasDef {
606#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1718 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF }
607pub struct SliceType { 1719 fn cast(syntax: SyntaxNode) -> Option<Self> {
608 pub(crate) syntax: SyntaxNode, 1720 if Self::can_cast(syntax.kind()) {
1721 Some(Self { syntax })
1722 } else {
1723 None
1724 }
1725 }
1726 fn syntax(&self) -> &SyntaxNode { &self.syntax }
609} 1727}
610impl AstNode for SliceType { 1728impl AstNode for ImplDef {
611 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE } 1729 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF }
612 fn cast(syntax: SyntaxNode) -> Option<Self> { 1730 fn cast(syntax: SyntaxNode) -> Option<Self> {
613 if Self::can_cast(syntax.kind()) { 1731 if Self::can_cast(syntax.kind()) {
614 Some(Self { syntax }) 1732 Some(Self { syntax })
@@ -618,18 +1736,30 @@ impl AstNode for SliceType {
618 } 1736 }
619 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1737 fn syntax(&self) -> &SyntaxNode { &self.syntax }
620} 1738}
621impl SliceType { 1739impl AstNode for ParenType {
622 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 1740 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE }
623 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1741 fn cast(syntax: SyntaxNode) -> Option<Self> {
624 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 1742 if Self::can_cast(syntax.kind()) {
1743 Some(Self { syntax })
1744 } else {
1745 None
1746 }
1747 }
1748 fn syntax(&self) -> &SyntaxNode { &self.syntax }
625} 1749}
626 1750impl AstNode for TupleType {
627#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1751 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE }
628pub struct ReferenceType { 1752 fn cast(syntax: SyntaxNode) -> Option<Self> {
629 pub(crate) syntax: SyntaxNode, 1753 if Self::can_cast(syntax.kind()) {
1754 Some(Self { syntax })
1755 } else {
1756 None
1757 }
1758 }
1759 fn syntax(&self) -> &SyntaxNode { &self.syntax }
630} 1760}
631impl AstNode for ReferenceType { 1761impl AstNode for NeverType {
632 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } 1762 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
633 fn cast(syntax: SyntaxNode) -> Option<Self> { 1763 fn cast(syntax: SyntaxNode) -> Option<Self> {
634 if Self::can_cast(syntax.kind()) { 1764 if Self::can_cast(syntax.kind()) {
635 Some(Self { syntax }) 1765 Some(Self { syntax })
@@ -639,21 +1769,30 @@ impl AstNode for ReferenceType {
639 } 1769 }
640 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1770 fn syntax(&self) -> &SyntaxNode { &self.syntax }
641} 1771}
642impl ReferenceType { 1772impl AstNode for PathType {
643 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 1773 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE }
644 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1774 fn cast(syntax: SyntaxNode) -> Option<Self> {
645 support::token(&self.syntax, T![lifetime]) 1775 if Self::can_cast(syntax.kind()) {
1776 Some(Self { syntax })
1777 } else {
1778 None
1779 }
646 } 1780 }
647 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1781 fn syntax(&self) -> &SyntaxNode { &self.syntax }
648 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
649} 1782}
650 1783impl AstNode for PointerType {
651#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1784 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
652pub struct PlaceholderType { 1785 fn cast(syntax: SyntaxNode) -> Option<Self> {
653 pub(crate) syntax: SyntaxNode, 1786 if Self::can_cast(syntax.kind()) {
1787 Some(Self { syntax })
1788 } else {
1789 None
1790 }
1791 }
1792 fn syntax(&self) -> &SyntaxNode { &self.syntax }
654} 1793}
655impl AstNode for PlaceholderType { 1794impl AstNode for ArrayType {
656 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE } 1795 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE }
657 fn cast(syntax: SyntaxNode) -> Option<Self> { 1796 fn cast(syntax: SyntaxNode) -> Option<Self> {
658 if Self::can_cast(syntax.kind()) { 1797 if Self::can_cast(syntax.kind()) {
659 Some(Self { syntax }) 1798 Some(Self { syntax })
@@ -663,13 +1802,38 @@ impl AstNode for PlaceholderType {
663 } 1802 }
664 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1803 fn syntax(&self) -> &SyntaxNode { &self.syntax }
665} 1804}
666impl PlaceholderType { 1805impl AstNode for SliceType {
667 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 1806 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE }
1807 fn cast(syntax: SyntaxNode) -> Option<Self> {
1808 if Self::can_cast(syntax.kind()) {
1809 Some(Self { syntax })
1810 } else {
1811 None
1812 }
1813 }
1814 fn syntax(&self) -> &SyntaxNode { &self.syntax }
668} 1815}
669 1816impl AstNode for ReferenceType {
670#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1817 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE }
671pub struct FnPointerType { 1818 fn cast(syntax: SyntaxNode) -> Option<Self> {
672 pub(crate) syntax: SyntaxNode, 1819 if Self::can_cast(syntax.kind()) {
1820 Some(Self { syntax })
1821 } else {
1822 None
1823 }
1824 }
1825 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1826}
1827impl AstNode for PlaceholderType {
1828 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE }
1829 fn cast(syntax: SyntaxNode) -> Option<Self> {
1830 if Self::can_cast(syntax.kind()) {
1831 Some(Self { syntax })
1832 } else {
1833 None
1834 }
1835 }
1836 fn syntax(&self) -> &SyntaxNode { &self.syntax }
673} 1837}
674impl AstNode for FnPointerType { 1838impl AstNode for FnPointerType {
675 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } 1839 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE }
@@ -682,18 +1846,6 @@ impl AstNode for FnPointerType {
682 } 1846 }
683 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1847 fn syntax(&self) -> &SyntaxNode { &self.syntax }
684} 1848}
685impl FnPointerType {
686 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
687 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
688 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
689 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
690 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
691}
692
693#[derive(Debug, Clone, PartialEq, Eq, Hash)]
694pub struct ForType {
695 pub(crate) syntax: SyntaxNode,
696}
697impl AstNode for ForType { 1849impl AstNode for ForType {
698 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE } 1850 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE }
699 fn cast(syntax: SyntaxNode) -> Option<Self> { 1851 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -705,16 +1857,6 @@ impl AstNode for ForType {
705 } 1857 }
706 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1858 fn syntax(&self) -> &SyntaxNode { &self.syntax }
707} 1859}
708impl ForType {
709 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
710 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
711 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
712}
713
714#[derive(Debug, Clone, PartialEq, Eq, Hash)]
715pub struct ImplTraitType {
716 pub(crate) syntax: SyntaxNode,
717}
718impl AstNode for ImplTraitType { 1860impl AstNode for ImplTraitType {
719 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE } 1861 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE }
720 fn cast(syntax: SyntaxNode) -> Option<Self> { 1862 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -726,15 +1868,6 @@ impl AstNode for ImplTraitType {
726 } 1868 }
727 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1869 fn syntax(&self) -> &SyntaxNode { &self.syntax }
728} 1870}
729impl ast::TypeBoundsOwner for ImplTraitType {}
730impl ImplTraitType {
731 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
732}
733
734#[derive(Debug, Clone, PartialEq, Eq, Hash)]
735pub struct DynTraitType {
736 pub(crate) syntax: SyntaxNode,
737}
738impl AstNode for DynTraitType { 1871impl AstNode for DynTraitType {
739 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE } 1872 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE }
740 fn cast(syntax: SyntaxNode) -> Option<Self> { 1873 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -746,15 +1879,6 @@ impl AstNode for DynTraitType {
746 } 1879 }
747 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1880 fn syntax(&self) -> &SyntaxNode { &self.syntax }
748} 1881}
749impl ast::TypeBoundsOwner for DynTraitType {}
750impl DynTraitType {
751 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
752}
753
754#[derive(Debug, Clone, PartialEq, Eq, Hash)]
755pub struct TupleExpr {
756 pub(crate) syntax: SyntaxNode,
757}
758impl AstNode for TupleExpr { 1882impl AstNode for TupleExpr {
759 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } 1883 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR }
760 fn cast(syntax: SyntaxNode) -> Option<Self> { 1884 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -766,17 +1890,6 @@ impl AstNode for TupleExpr {
766 } 1890 }
767 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1891 fn syntax(&self) -> &SyntaxNode { &self.syntax }
768} 1892}
769impl ast::AttrsOwner for TupleExpr {}
770impl TupleExpr {
771 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
772 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
773 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
774}
775
776#[derive(Debug, Clone, PartialEq, Eq, Hash)]
777pub struct ArrayExpr {
778 pub(crate) syntax: SyntaxNode,
779}
780impl AstNode for ArrayExpr { 1893impl AstNode for ArrayExpr {
781 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR } 1894 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR }
782 fn cast(syntax: SyntaxNode) -> Option<Self> { 1895 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -788,18 +1901,6 @@ impl AstNode for ArrayExpr {
788 } 1901 }
789 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1902 fn syntax(&self) -> &SyntaxNode { &self.syntax }
790} 1903}
791impl ast::AttrsOwner for ArrayExpr {}
792impl ArrayExpr {
793 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
794 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
795 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
796 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
797}
798
799#[derive(Debug, Clone, PartialEq, Eq, Hash)]
800pub struct ParenExpr {
801 pub(crate) syntax: SyntaxNode,
802}
803impl AstNode for ParenExpr { 1904impl AstNode for ParenExpr {
804 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR } 1905 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
805 fn cast(syntax: SyntaxNode) -> Option<Self> { 1906 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -811,17 +1912,6 @@ impl AstNode for ParenExpr {
811 } 1912 }
812 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1913 fn syntax(&self) -> &SyntaxNode { &self.syntax }
813} 1914}
814impl ast::AttrsOwner for ParenExpr {}
815impl ParenExpr {
816 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
817 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
818 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
819}
820
821#[derive(Debug, Clone, PartialEq, Eq, Hash)]
822pub struct PathExpr {
823 pub(crate) syntax: SyntaxNode,
824}
825impl AstNode for PathExpr { 1915impl AstNode for PathExpr {
826 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR } 1916 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR }
827 fn cast(syntax: SyntaxNode) -> Option<Self> { 1917 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -833,14 +1923,6 @@ impl AstNode for PathExpr {
833 } 1923 }
834 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1924 fn syntax(&self) -> &SyntaxNode { &self.syntax }
835} 1925}
836impl PathExpr {
837 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
838}
839
840#[derive(Debug, Clone, PartialEq, Eq, Hash)]
841pub struct LambdaExpr {
842 pub(crate) syntax: SyntaxNode,
843}
844impl AstNode for LambdaExpr { 1926impl AstNode for LambdaExpr {
845 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } 1927 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR }
846 fn cast(syntax: SyntaxNode) -> Option<Self> { 1928 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -852,20 +1934,6 @@ impl AstNode for LambdaExpr {
852 } 1934 }
853 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1935 fn syntax(&self) -> &SyntaxNode { &self.syntax }
854} 1936}
855impl ast::AttrsOwner for LambdaExpr {}
856impl LambdaExpr {
857 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
858 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
859 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
860 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
861 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
862 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
863}
864
865#[derive(Debug, Clone, PartialEq, Eq, Hash)]
866pub struct IfExpr {
867 pub(crate) syntax: SyntaxNode,
868}
869impl AstNode for IfExpr { 1937impl AstNode for IfExpr {
870 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR } 1938 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
871 fn cast(syntax: SyntaxNode) -> Option<Self> { 1939 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -877,16 +1945,6 @@ impl AstNode for IfExpr {
877 } 1945 }
878 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1946 fn syntax(&self) -> &SyntaxNode { &self.syntax }
879} 1947}
880impl ast::AttrsOwner for IfExpr {}
881impl IfExpr {
882 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
883 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
884}
885
886#[derive(Debug, Clone, PartialEq, Eq, Hash)]
887pub struct LoopExpr {
888 pub(crate) syntax: SyntaxNode,
889}
890impl AstNode for LoopExpr { 1948impl AstNode for LoopExpr {
891 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } 1949 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
892 fn cast(syntax: SyntaxNode) -> Option<Self> { 1950 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -898,16 +1956,6 @@ impl AstNode for LoopExpr {
898 } 1956 }
899 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1957 fn syntax(&self) -> &SyntaxNode { &self.syntax }
900} 1958}
901impl ast::AttrsOwner for LoopExpr {}
902impl ast::LoopBodyOwner for LoopExpr {}
903impl LoopExpr {
904 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
905}
906
907#[derive(Debug, Clone, PartialEq, Eq, Hash)]
908pub struct TryBlockExpr {
909 pub(crate) syntax: SyntaxNode,
910}
911impl AstNode for TryBlockExpr { 1959impl AstNode for TryBlockExpr {
912 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_EXPR } 1960 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_EXPR }
913 fn cast(syntax: SyntaxNode) -> Option<Self> { 1961 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -919,16 +1967,6 @@ impl AstNode for TryBlockExpr {
919 } 1967 }
920 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1968 fn syntax(&self) -> &SyntaxNode { &self.syntax }
921} 1969}
922impl ast::AttrsOwner for TryBlockExpr {}
923impl TryBlockExpr {
924 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
925 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
926}
927
928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929pub struct ForExpr {
930 pub(crate) syntax: SyntaxNode,
931}
932impl AstNode for ForExpr { 1970impl AstNode for ForExpr {
933 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } 1971 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR }
934 fn cast(syntax: SyntaxNode) -> Option<Self> { 1972 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -940,19 +1978,6 @@ impl AstNode for ForExpr {
940 } 1978 }
941 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1979 fn syntax(&self) -> &SyntaxNode { &self.syntax }
942} 1980}
943impl ast::AttrsOwner for ForExpr {}
944impl ast::LoopBodyOwner for ForExpr {}
945impl ForExpr {
946 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
947 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
948 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
949 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
950}
951
952#[derive(Debug, Clone, PartialEq, Eq, Hash)]
953pub struct WhileExpr {
954 pub(crate) syntax: SyntaxNode,
955}
956impl AstNode for WhileExpr { 1981impl AstNode for WhileExpr {
957 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR } 1982 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR }
958 fn cast(syntax: SyntaxNode) -> Option<Self> { 1983 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -964,17 +1989,6 @@ impl AstNode for WhileExpr {
964 } 1989 }
965 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1990 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966} 1991}
967impl ast::AttrsOwner for WhileExpr {}
968impl ast::LoopBodyOwner for WhileExpr {}
969impl WhileExpr {
970 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
971 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
972}
973
974#[derive(Debug, Clone, PartialEq, Eq, Hash)]
975pub struct ContinueExpr {
976 pub(crate) syntax: SyntaxNode,
977}
978impl AstNode for ContinueExpr { 1992impl AstNode for ContinueExpr {
979 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } 1993 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR }
980 fn cast(syntax: SyntaxNode) -> Option<Self> { 1994 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -986,20 +2000,6 @@ impl AstNode for ContinueExpr {
986 } 2000 }
987 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2001 fn syntax(&self) -> &SyntaxNode { &self.syntax }
988} 2002}
989impl ast::AttrsOwner for ContinueExpr {}
990impl ContinueExpr {
991 pub fn continue_token(&self) -> Option<SyntaxToken> {
992 support::token(&self.syntax, T![continue])
993 }
994 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
995 support::token(&self.syntax, T![lifetime])
996 }
997}
998
999#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1000pub struct BreakExpr {
1001 pub(crate) syntax: SyntaxNode,
1002}
1003impl AstNode for BreakExpr { 2003impl AstNode for BreakExpr {
1004 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR } 2004 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
1005 fn cast(syntax: SyntaxNode) -> Option<Self> { 2005 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1011,19 +2011,6 @@ impl AstNode for BreakExpr {
1011 } 2011 }
1012 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2012 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1013} 2013}
1014impl ast::AttrsOwner for BreakExpr {}
1015impl BreakExpr {
1016 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
1017 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1018 support::token(&self.syntax, T![lifetime])
1019 }
1020 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1021}
1022
1023#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1024pub struct Label {
1025 pub(crate) syntax: SyntaxNode,
1026}
1027impl AstNode for Label { 2014impl AstNode for Label {
1028 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } 2015 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
1029 fn cast(syntax: SyntaxNode) -> Option<Self> { 2016 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1035,16 +2022,6 @@ impl AstNode for Label {
1035 } 2022 }
1036 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2023 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1037} 2024}
1038impl Label {
1039 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1040 support::token(&self.syntax, T![lifetime])
1041 }
1042}
1043
1044#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1045pub struct BlockExpr {
1046 pub(crate) syntax: SyntaxNode,
1047}
1048impl AstNode for BlockExpr { 2025impl AstNode for BlockExpr {
1049 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } 2026 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
1050 fn cast(syntax: SyntaxNode) -> Option<Self> { 2027 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1056,17 +2033,6 @@ impl AstNode for BlockExpr {
1056 } 2033 }
1057 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2034 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1058} 2035}
1059impl ast::AttrsOwner for BlockExpr {}
1060impl BlockExpr {
1061 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1062 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
1063 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
1064}
1065
1066#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1067pub struct ReturnExpr {
1068 pub(crate) syntax: SyntaxNode,
1069}
1070impl AstNode for ReturnExpr { 2036impl AstNode for ReturnExpr {
1071 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR } 2037 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR }
1072 fn cast(syntax: SyntaxNode) -> Option<Self> { 2038 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1078,15 +2044,6 @@ impl AstNode for ReturnExpr {
1078 } 2044 }
1079 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2045 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1080} 2046}
1081impl ast::AttrsOwner for ReturnExpr {}
1082impl ReturnExpr {
1083 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1084}
1085
1086#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1087pub struct CallExpr {
1088 pub(crate) syntax: SyntaxNode,
1089}
1090impl AstNode for CallExpr { 2047impl AstNode for CallExpr {
1091 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR } 2048 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR }
1092 fn cast(syntax: SyntaxNode) -> Option<Self> { 2049 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1098,15 +2055,6 @@ impl AstNode for CallExpr {
1098 } 2055 }
1099 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2056 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1100} 2057}
1101impl ast::ArgListOwner for CallExpr {}
1102impl CallExpr {
1103 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1104}
1105
1106#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1107pub struct MethodCallExpr {
1108 pub(crate) syntax: SyntaxNode,
1109}
1110impl AstNode for MethodCallExpr { 2058impl AstNode for MethodCallExpr {
1111 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR } 2059 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR }
1112 fn cast(syntax: SyntaxNode) -> Option<Self> { 2060 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1118,19 +2066,6 @@ impl AstNode for MethodCallExpr {
1118 } 2066 }
1119 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2067 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1120} 2068}
1121impl ast::AttrsOwner for MethodCallExpr {}
1122impl ast::ArgListOwner for MethodCallExpr {}
1123impl MethodCallExpr {
1124 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1125 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1126 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1127 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1128}
1129
1130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1131pub struct IndexExpr {
1132 pub(crate) syntax: SyntaxNode,
1133}
1134impl AstNode for IndexExpr { 2069impl AstNode for IndexExpr {
1135 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR } 2070 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR }
1136 fn cast(syntax: SyntaxNode) -> Option<Self> { 2071 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1142,16 +2077,6 @@ impl AstNode for IndexExpr {
1142 } 2077 }
1143 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2078 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1144} 2079}
1145impl ast::AttrsOwner for IndexExpr {}
1146impl IndexExpr {
1147 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1148 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1149}
1150
1151#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1152pub struct FieldExpr {
1153 pub(crate) syntax: SyntaxNode,
1154}
1155impl AstNode for FieldExpr { 2080impl AstNode for FieldExpr {
1156 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR } 2081 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR }
1157 fn cast(syntax: SyntaxNode) -> Option<Self> { 2082 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1163,17 +2088,6 @@ impl AstNode for FieldExpr {
1163 } 2088 }
1164 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2089 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1165} 2090}
1166impl ast::AttrsOwner for FieldExpr {}
1167impl FieldExpr {
1168 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1169 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1170 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1171}
1172
1173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1174pub struct AwaitExpr {
1175 pub(crate) syntax: SyntaxNode,
1176}
1177impl AstNode for AwaitExpr { 2091impl AstNode for AwaitExpr {
1178 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR } 2092 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
1179 fn cast(syntax: SyntaxNode) -> Option<Self> { 2093 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1185,17 +2099,6 @@ impl AstNode for AwaitExpr {
1185 } 2099 }
1186 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2100 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1187} 2101}
1188impl ast::AttrsOwner for AwaitExpr {}
1189impl AwaitExpr {
1190 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1191 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1192 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1193}
1194
1195#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1196pub struct TryExpr {
1197 pub(crate) syntax: SyntaxNode,
1198}
1199impl AstNode for TryExpr { 2102impl AstNode for TryExpr {
1200 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR } 2103 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR }
1201 fn cast(syntax: SyntaxNode) -> Option<Self> { 2104 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1207,16 +2110,6 @@ impl AstNode for TryExpr {
1207 } 2110 }
1208 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2111 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1209} 2112}
1210impl ast::AttrsOwner for TryExpr {}
1211impl TryExpr {
1212 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
1213 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1214}
1215
1216#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1217pub struct CastExpr {
1218 pub(crate) syntax: SyntaxNode,
1219}
1220impl AstNode for CastExpr { 2113impl AstNode for CastExpr {
1221 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR } 2114 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR }
1222 fn cast(syntax: SyntaxNode) -> Option<Self> { 2115 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1228,17 +2121,6 @@ impl AstNode for CastExpr {
1228 } 2121 }
1229 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2122 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1230} 2123}
1231impl ast::AttrsOwner for CastExpr {}
1232impl CastExpr {
1233 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1234 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1235 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1236}
1237
1238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1239pub struct RefExpr {
1240 pub(crate) syntax: SyntaxNode,
1241}
1242impl AstNode for RefExpr { 2124impl AstNode for RefExpr {
1243 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR } 2125 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR }
1244 fn cast(syntax: SyntaxNode) -> Option<Self> { 2126 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1250,18 +2132,6 @@ impl AstNode for RefExpr {
1250 } 2132 }
1251 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2133 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1252} 2134}
1253impl ast::AttrsOwner for RefExpr {}
1254impl RefExpr {
1255 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1256 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) }
1257 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1258 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1259}
1260
1261#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1262pub struct PrefixExpr {
1263 pub(crate) syntax: SyntaxNode,
1264}
1265impl AstNode for PrefixExpr { 2135impl AstNode for PrefixExpr {
1266 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR } 2136 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR }
1267 fn cast(syntax: SyntaxNode) -> Option<Self> { 2137 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1273,15 +2143,6 @@ impl AstNode for PrefixExpr {
1273 } 2143 }
1274 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2144 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1275} 2145}
1276impl ast::AttrsOwner for PrefixExpr {}
1277impl PrefixExpr {
1278 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1279}
1280
1281#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1282pub struct BoxExpr {
1283 pub(crate) syntax: SyntaxNode,
1284}
1285impl AstNode for BoxExpr { 2146impl AstNode for BoxExpr {
1286 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR } 2147 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR }
1287 fn cast(syntax: SyntaxNode) -> Option<Self> { 2148 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1293,16 +2154,6 @@ impl AstNode for BoxExpr {
1293 } 2154 }
1294 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2155 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1295} 2156}
1296impl ast::AttrsOwner for BoxExpr {}
1297impl BoxExpr {
1298 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1299 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1300}
1301
1302#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1303pub struct RangeExpr {
1304 pub(crate) syntax: SyntaxNode,
1305}
1306impl AstNode for RangeExpr { 2157impl AstNode for RangeExpr {
1307 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR } 2158 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR }
1308 fn cast(syntax: SyntaxNode) -> Option<Self> { 2159 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1314,13 +2165,6 @@ impl AstNode for RangeExpr {
1314 } 2165 }
1315 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1316} 2167}
1317impl ast::AttrsOwner for RangeExpr {}
1318impl RangeExpr {}
1319
1320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1321pub struct BinExpr {
1322 pub(crate) syntax: SyntaxNode,
1323}
1324impl AstNode for BinExpr { 2168impl AstNode for BinExpr {
1325 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR } 2169 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR }
1326 fn cast(syntax: SyntaxNode) -> Option<Self> { 2170 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1332,13 +2176,6 @@ impl AstNode for BinExpr {
1332 } 2176 }
1333 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2177 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1334} 2178}
1335impl ast::AttrsOwner for BinExpr {}
1336impl BinExpr {}
1337
1338#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1339pub struct Literal {
1340 pub(crate) syntax: SyntaxNode,
1341}
1342impl AstNode for Literal { 2179impl AstNode for Literal {
1343 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } 2180 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
1344 fn cast(syntax: SyntaxNode) -> Option<Self> { 2181 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1350,12 +2187,6 @@ impl AstNode for Literal {
1350 } 2187 }
1351 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2188 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1352} 2189}
1353impl Literal {}
1354
1355#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1356pub struct MatchExpr {
1357 pub(crate) syntax: SyntaxNode,
1358}
1359impl AstNode for MatchExpr { 2190impl AstNode for MatchExpr {
1360 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } 2191 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR }
1361 fn cast(syntax: SyntaxNode) -> Option<Self> { 2192 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1367,17 +2198,6 @@ impl AstNode for MatchExpr {
1367 } 2198 }
1368 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2199 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1369} 2200}
1370impl ast::AttrsOwner for MatchExpr {}
1371impl MatchExpr {
1372 pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) }
1373 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1374 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1375}
1376
1377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1378pub struct MatchArmList {
1379 pub(crate) syntax: SyntaxNode,
1380}
1381impl AstNode for MatchArmList { 2201impl AstNode for MatchArmList {
1382 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST } 2202 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST }
1383 fn cast(syntax: SyntaxNode) -> Option<Self> { 2203 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1389,17 +2209,6 @@ impl AstNode for MatchArmList {
1389 } 2209 }
1390 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2210 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1391} 2211}
1392impl ast::AttrsOwner for MatchArmList {}
1393impl MatchArmList {
1394 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1395 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1396 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1397}
1398
1399#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1400pub struct MatchArm {
1401 pub(crate) syntax: SyntaxNode,
1402}
1403impl AstNode for MatchArm { 2212impl AstNode for MatchArm {
1404 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM } 2213 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM }
1405 fn cast(syntax: SyntaxNode) -> Option<Self> { 2214 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1411,18 +2220,6 @@ impl AstNode for MatchArm {
1411 } 2220 }
1412 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2221 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1413} 2222}
1414impl ast::AttrsOwner for MatchArm {}
1415impl MatchArm {
1416 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1417 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
1418 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1419 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1420}
1421
1422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1423pub struct MatchGuard {
1424 pub(crate) syntax: SyntaxNode,
1425}
1426impl AstNode for MatchGuard { 2223impl AstNode for MatchGuard {
1427 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD } 2224 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD }
1428 fn cast(syntax: SyntaxNode) -> Option<Self> { 2225 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1434,15 +2231,6 @@ impl AstNode for MatchGuard {
1434 } 2231 }
1435 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2232 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1436} 2233}
1437impl MatchGuard {
1438 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1439 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1440}
1441
1442#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1443pub struct RecordLit {
1444 pub(crate) syntax: SyntaxNode,
1445}
1446impl AstNode for RecordLit { 2234impl AstNode for RecordLit {
1447 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } 2235 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT }
1448 fn cast(syntax: SyntaxNode) -> Option<Self> { 2236 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1454,15 +2242,6 @@ impl AstNode for RecordLit {
1454 } 2242 }
1455 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2243 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1456} 2244}
1457impl RecordLit {
1458 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1459 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
1460}
1461
1462#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1463pub struct RecordFieldList {
1464 pub(crate) syntax: SyntaxNode,
1465}
1466impl AstNode for RecordFieldList { 2245impl AstNode for RecordFieldList {
1467 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } 2246 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
1468 fn cast(syntax: SyntaxNode) -> Option<Self> { 2247 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1474,18 +2253,6 @@ impl AstNode for RecordFieldList {
1474 } 2253 }
1475 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2254 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1476} 2255}
1477impl RecordFieldList {
1478 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1479 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
1480 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1481 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1482 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1483}
1484
1485#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1486pub struct RecordField {
1487 pub(crate) syntax: SyntaxNode,
1488}
1489impl AstNode for RecordField { 2256impl AstNode for RecordField {
1490 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } 2257 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
1491 fn cast(syntax: SyntaxNode) -> Option<Self> { 2258 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1497,17 +2264,6 @@ impl AstNode for RecordField {
1497 } 2264 }
1498 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2265 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1499} 2266}
1500impl ast::AttrsOwner for RecordField {}
1501impl RecordField {
1502 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1503 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1504 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1505}
1506
1507#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1508pub struct OrPat {
1509 pub(crate) syntax: SyntaxNode,
1510}
1511impl AstNode for OrPat { 2267impl AstNode for OrPat {
1512 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT } 2268 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT }
1513 fn cast(syntax: SyntaxNode) -> Option<Self> { 2269 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1519,14 +2275,6 @@ impl AstNode for OrPat {
1519 } 2275 }
1520 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2276 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1521} 2277}
1522impl OrPat {
1523 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1524}
1525
1526#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1527pub struct ParenPat {
1528 pub(crate) syntax: SyntaxNode,
1529}
1530impl AstNode for ParenPat { 2278impl AstNode for ParenPat {
1531 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT } 2279 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT }
1532 fn cast(syntax: SyntaxNode) -> Option<Self> { 2280 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1538,16 +2286,6 @@ impl AstNode for ParenPat {
1538 } 2286 }
1539 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2287 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1540} 2288}
1541impl ParenPat {
1542 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1543 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1544 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1545}
1546
1547#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1548pub struct RefPat {
1549 pub(crate) syntax: SyntaxNode,
1550}
1551impl AstNode for RefPat { 2289impl AstNode for RefPat {
1552 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT } 2290 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT }
1553 fn cast(syntax: SyntaxNode) -> Option<Self> { 2291 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1559,16 +2297,6 @@ impl AstNode for RefPat {
1559 } 2297 }
1560 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2298 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1561} 2299}
1562impl RefPat {
1563 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1564 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1565 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1566}
1567
1568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1569pub struct BoxPat {
1570 pub(crate) syntax: SyntaxNode,
1571}
1572impl AstNode for BoxPat { 2300impl AstNode for BoxPat {
1573 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT } 2301 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT }
1574 fn cast(syntax: SyntaxNode) -> Option<Self> { 2302 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1580,15 +2308,6 @@ impl AstNode for BoxPat {
1580 } 2308 }
1581 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2309 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1582} 2310}
1583impl BoxPat {
1584 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1585 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1586}
1587
1588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1589pub struct BindPat {
1590 pub(crate) syntax: SyntaxNode,
1591}
1592impl AstNode for BindPat { 2311impl AstNode for BindPat {
1593 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } 2312 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT }
1594 fn cast(syntax: SyntaxNode) -> Option<Self> { 2313 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1600,19 +2319,6 @@ impl AstNode for BindPat {
1600 } 2319 }
1601 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2320 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1602} 2321}
1603impl ast::AttrsOwner for BindPat {}
1604impl ast::NameOwner for BindPat {}
1605impl BindPat {
1606 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1607 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1608 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1609 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1610}
1611
1612#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1613pub struct PlaceholderPat {
1614 pub(crate) syntax: SyntaxNode,
1615}
1616impl AstNode for PlaceholderPat { 2322impl AstNode for PlaceholderPat {
1617 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT } 2323 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT }
1618 fn cast(syntax: SyntaxNode) -> Option<Self> { 2324 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1624,14 +2330,6 @@ impl AstNode for PlaceholderPat {
1624 } 2330 }
1625 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2331 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1626} 2332}
1627impl PlaceholderPat {
1628 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1629}
1630
1631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1632pub struct DotDotPat {
1633 pub(crate) syntax: SyntaxNode,
1634}
1635impl AstNode for DotDotPat { 2333impl AstNode for DotDotPat {
1636 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT } 2334 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT }
1637 fn cast(syntax: SyntaxNode) -> Option<Self> { 2335 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1643,14 +2341,6 @@ impl AstNode for DotDotPat {
1643 } 2341 }
1644 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2342 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1645} 2343}
1646impl DotDotPat {
1647 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1648}
1649
1650#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1651pub struct PathPat {
1652 pub(crate) syntax: SyntaxNode,
1653}
1654impl AstNode for PathPat { 2344impl AstNode for PathPat {
1655 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT } 2345 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT }
1656 fn cast(syntax: SyntaxNode) -> Option<Self> { 2346 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1662,14 +2352,6 @@ impl AstNode for PathPat {
1662 } 2352 }
1663 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2353 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1664} 2354}
1665impl PathPat {
1666 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1667}
1668
1669#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1670pub struct SlicePat {
1671 pub(crate) syntax: SyntaxNode,
1672}
1673impl AstNode for SlicePat { 2355impl AstNode for SlicePat {
1674 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT } 2356 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT }
1675 fn cast(syntax: SyntaxNode) -> Option<Self> { 2357 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1681,16 +2363,6 @@ impl AstNode for SlicePat {
1681 } 2363 }
1682 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2364 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1683} 2365}
1684impl SlicePat {
1685 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1686 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1687 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1688}
1689
1690#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1691pub struct RangePat {
1692 pub(crate) syntax: SyntaxNode,
1693}
1694impl AstNode for RangePat { 2366impl AstNode for RangePat {
1695 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT } 2367 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT }
1696 fn cast(syntax: SyntaxNode) -> Option<Self> { 2368 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1702,12 +2374,6 @@ impl AstNode for RangePat {
1702 } 2374 }
1703 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2375 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1704} 2376}
1705impl RangePat {}
1706
1707#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1708pub struct LiteralPat {
1709 pub(crate) syntax: SyntaxNode,
1710}
1711impl AstNode for LiteralPat { 2377impl AstNode for LiteralPat {
1712 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT } 2378 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
1713 fn cast(syntax: SyntaxNode) -> Option<Self> { 2379 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1719,14 +2385,6 @@ impl AstNode for LiteralPat {
1719 } 2385 }
1720 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2386 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1721} 2387}
1722impl LiteralPat {
1723 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1724}
1725
1726#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1727pub struct MacroPat {
1728 pub(crate) syntax: SyntaxNode,
1729}
1730impl AstNode for MacroPat { 2388impl AstNode for MacroPat {
1731 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT } 2389 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
1732 fn cast(syntax: SyntaxNode) -> Option<Self> { 2390 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1738,14 +2396,6 @@ impl AstNode for MacroPat {
1738 } 2396 }
1739 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2397 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1740} 2398}
1741impl MacroPat {
1742 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1743}
1744
1745#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1746pub struct RecordPat {
1747 pub(crate) syntax: SyntaxNode,
1748}
1749impl AstNode for RecordPat { 2399impl AstNode for RecordPat {
1750 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } 2400 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
1751 fn cast(syntax: SyntaxNode) -> Option<Self> { 2401 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1757,17 +2407,6 @@ impl AstNode for RecordPat {
1757 } 2407 }
1758 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2408 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1759} 2409}
1760impl RecordPat {
1761 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
1762 support::child(&self.syntax)
1763 }
1764 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1765}
1766
1767#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1768pub struct RecordFieldPatList {
1769 pub(crate) syntax: SyntaxNode,
1770}
1771impl AstNode for RecordFieldPatList { 2410impl AstNode for RecordFieldPatList {
1772 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST } 2411 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST }
1773 fn cast(syntax: SyntaxNode) -> Option<Self> { 2412 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1779,21 +2418,6 @@ impl AstNode for RecordFieldPatList {
1779 } 2418 }
1780 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2419 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1781} 2420}
1782impl RecordFieldPatList {
1783 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1784 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
1785 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1786 support::children(&self.syntax)
1787 }
1788 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1789 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1790 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1791}
1792
1793#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1794pub struct RecordFieldPat {
1795 pub(crate) syntax: SyntaxNode,
1796}
1797impl AstNode for RecordFieldPat { 2421impl AstNode for RecordFieldPat {
1798 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT } 2422 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT }
1799 fn cast(syntax: SyntaxNode) -> Option<Self> { 2423 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1805,17 +2429,6 @@ impl AstNode for RecordFieldPat {
1805 } 2429 }
1806 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2430 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1807} 2431}
1808impl ast::AttrsOwner for RecordFieldPat {}
1809impl RecordFieldPat {
1810 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1811 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1812 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1813}
1814
1815#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1816pub struct TupleStructPat {
1817 pub(crate) syntax: SyntaxNode,
1818}
1819impl AstNode for TupleStructPat { 2432impl AstNode for TupleStructPat {
1820 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT } 2433 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT }
1821 fn cast(syntax: SyntaxNode) -> Option<Self> { 2434 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1827,17 +2440,6 @@ impl AstNode for TupleStructPat {
1827 } 2440 }
1828 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2441 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1829} 2442}
1830impl TupleStructPat {
1831 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1832 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1833 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1834 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1835}
1836
1837#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1838pub struct TuplePat {
1839 pub(crate) syntax: SyntaxNode,
1840}
1841impl AstNode for TuplePat { 2443impl AstNode for TuplePat {
1842 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT } 2444 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT }
1843 fn cast(syntax: SyntaxNode) -> Option<Self> { 2445 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1849,16 +2451,6 @@ impl AstNode for TuplePat {
1849 } 2451 }
1850 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2452 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1851} 2453}
1852impl TuplePat {
1853 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1854 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1855 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1856}
1857
1858#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1859pub struct Visibility {
1860 pub(crate) syntax: SyntaxNode,
1861}
1862impl AstNode for Visibility { 2454impl AstNode for Visibility {
1863 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } 2455 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
1864 fn cast(syntax: SyntaxNode) -> Option<Self> { 2456 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1870,17 +2462,6 @@ impl AstNode for Visibility {
1870 } 2462 }
1871 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2463 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1872} 2464}
1873impl Visibility {
1874 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
1875 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
1876 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1877 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1878}
1879
1880#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1881pub struct Name {
1882 pub(crate) syntax: SyntaxNode,
1883}
1884impl AstNode for Name { 2465impl AstNode for Name {
1885 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } 2466 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
1886 fn cast(syntax: SyntaxNode) -> Option<Self> { 2467 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1892,14 +2473,6 @@ impl AstNode for Name {
1892 } 2473 }
1893 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2474 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1894} 2475}
1895impl Name {
1896 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
1897}
1898
1899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1900pub struct NameRef {
1901 pub(crate) syntax: SyntaxNode,
1902}
1903impl AstNode for NameRef { 2476impl AstNode for NameRef {
1904 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } 2477 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
1905 fn cast(syntax: SyntaxNode) -> Option<Self> { 2478 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1911,12 +2484,6 @@ impl AstNode for NameRef {
1911 } 2484 }
1912 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2485 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1913} 2486}
1914impl NameRef {}
1915
1916#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1917pub struct MacroCall {
1918 pub(crate) syntax: SyntaxNode,
1919}
1920impl AstNode for MacroCall { 2487impl AstNode for MacroCall {
1921 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } 2488 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
1922 fn cast(syntax: SyntaxNode) -> Option<Self> { 2489 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1928,20 +2495,6 @@ impl AstNode for MacroCall {
1928 } 2495 }
1929 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2496 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1930} 2497}
1931impl ast::NameOwner for MacroCall {}
1932impl ast::AttrsOwner for MacroCall {}
1933impl ast::DocCommentsOwner for MacroCall {}
1934impl MacroCall {
1935 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1936 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1937 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1938 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1939}
1940
1941#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1942pub struct Attr {
1943 pub(crate) syntax: SyntaxNode,
1944}
1945impl AstNode for Attr { 2498impl AstNode for Attr {
1946 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } 2499 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
1947 fn cast(syntax: SyntaxNode) -> Option<Self> { 2500 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1953,20 +2506,6 @@ impl AstNode for Attr {
1953 } 2506 }
1954 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2507 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1955} 2508}
1956impl Attr {
1957 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1958 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1959 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1960 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1961 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1962 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1963 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1964}
1965
1966#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1967pub struct TokenTree {
1968 pub(crate) syntax: SyntaxNode,
1969}
1970impl AstNode for TokenTree { 2509impl AstNode for TokenTree {
1971 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } 2510 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
1972 fn cast(syntax: SyntaxNode) -> Option<Self> { 2511 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1978,12 +2517,6 @@ impl AstNode for TokenTree {
1978 } 2517 }
1979 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2518 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1980} 2519}
1981impl TokenTree {}
1982
1983#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1984pub struct TypeParamList {
1985 pub(crate) syntax: SyntaxNode,
1986}
1987impl AstNode for TypeParamList { 2520impl AstNode for TypeParamList {
1988 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } 2521 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST }
1989 fn cast(syntax: SyntaxNode) -> Option<Self> { 2522 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1995,19 +2528,6 @@ impl AstNode for TypeParamList {
1995 } 2528 }
1996 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2529 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1997} 2530}
1998impl TypeParamList {
1999 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2000 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
2001 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
2002 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
2003 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
2004 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2005}
2006
2007#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2008pub struct TypeParam {
2009 pub(crate) syntax: SyntaxNode,
2010}
2011impl AstNode for TypeParam { 2531impl AstNode for TypeParam {
2012 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } 2532 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM }
2013 fn cast(syntax: SyntaxNode) -> Option<Self> { 2533 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2019,18 +2539,6 @@ impl AstNode for TypeParam {
2019 } 2539 }
2020 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2540 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2021} 2541}
2022impl ast::NameOwner for TypeParam {}
2023impl ast::AttrsOwner for TypeParam {}
2024impl ast::TypeBoundsOwner for TypeParam {}
2025impl TypeParam {
2026 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2027 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2028}
2029
2030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2031pub struct ConstParam {
2032 pub(crate) syntax: SyntaxNode,
2033}
2034impl AstNode for ConstParam { 2542impl AstNode for ConstParam {
2035 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } 2543 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
2036 fn cast(syntax: SyntaxNode) -> Option<Self> { 2544 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2042,18 +2550,6 @@ impl AstNode for ConstParam {
2042 } 2550 }
2043 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2551 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2044} 2552}
2045impl ast::NameOwner for ConstParam {}
2046impl ast::AttrsOwner for ConstParam {}
2047impl ast::TypeAscriptionOwner for ConstParam {}
2048impl ConstParam {
2049 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2050 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
2051}
2052
2053#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2054pub struct LifetimeParam {
2055 pub(crate) syntax: SyntaxNode,
2056}
2057impl AstNode for LifetimeParam { 2553impl AstNode for LifetimeParam {
2058 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } 2554 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM }
2059 fn cast(syntax: SyntaxNode) -> Option<Self> { 2555 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2065,17 +2561,6 @@ impl AstNode for LifetimeParam {
2065 } 2561 }
2066 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2562 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2067} 2563}
2068impl ast::AttrsOwner for LifetimeParam {}
2069impl LifetimeParam {
2070 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2071 support::token(&self.syntax, T![lifetime])
2072 }
2073}
2074
2075#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2076pub struct TypeBound {
2077 pub(crate) syntax: SyntaxNode,
2078}
2079impl AstNode for TypeBound { 2564impl AstNode for TypeBound {
2080 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } 2565 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
2081 fn cast(syntax: SyntaxNode) -> Option<Self> { 2566 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2087,18 +2572,6 @@ impl AstNode for TypeBound {
2087 } 2572 }
2088 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2573 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2089} 2574}
2090impl TypeBound {
2091 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2092 support::token(&self.syntax, T![lifetime])
2093 }
2094 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
2095 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2096}
2097
2098#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2099pub struct TypeBoundList {
2100 pub(crate) syntax: SyntaxNode,
2101}
2102impl AstNode for TypeBoundList { 2575impl AstNode for TypeBoundList {
2103 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } 2576 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
2104 fn cast(syntax: SyntaxNode) -> Option<Self> { 2577 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2110,14 +2583,6 @@ impl AstNode for TypeBoundList {
2110 } 2583 }
2111 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2584 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2112} 2585}
2113impl TypeBoundList {
2114 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2115}
2116
2117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2118pub struct WherePred {
2119 pub(crate) syntax: SyntaxNode,
2120}
2121impl AstNode for WherePred { 2586impl AstNode for WherePred {
2122 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } 2587 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED }
2123 fn cast(syntax: SyntaxNode) -> Option<Self> { 2588 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2129,18 +2594,6 @@ impl AstNode for WherePred {
2129 } 2594 }
2130 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2595 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2131} 2596}
2132impl ast::TypeBoundsOwner for WherePred {}
2133impl WherePred {
2134 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2135 support::token(&self.syntax, T![lifetime])
2136 }
2137 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2138}
2139
2140#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2141pub struct WhereClause {
2142 pub(crate) syntax: SyntaxNode,
2143}
2144impl AstNode for WhereClause { 2597impl AstNode for WhereClause {
2145 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } 2598 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
2146 fn cast(syntax: SyntaxNode) -> Option<Self> { 2599 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2152,15 +2605,6 @@ impl AstNode for WhereClause {
2152 } 2605 }
2153 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2606 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2154} 2607}
2155impl WhereClause {
2156 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
2157 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2158}
2159
2160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2161pub struct Abi {
2162 pub(crate) syntax: SyntaxNode,
2163}
2164impl AstNode for Abi { 2608impl AstNode for Abi {
2165 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } 2609 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
2166 fn cast(syntax: SyntaxNode) -> Option<Self> { 2610 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2172,12 +2616,6 @@ impl AstNode for Abi {
2172 } 2616 }
2173 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2617 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2174} 2618}
2175impl Abi {}
2176
2177#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2178pub struct ExprStmt {
2179 pub(crate) syntax: SyntaxNode,
2180}
2181impl AstNode for ExprStmt { 2619impl AstNode for ExprStmt {
2182 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } 2620 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT }
2183 fn cast(syntax: SyntaxNode) -> Option<Self> { 2621 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2189,16 +2627,6 @@ impl AstNode for ExprStmt {
2189 } 2627 }
2190 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2628 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2191} 2629}
2192impl ast::AttrsOwner for ExprStmt {}
2193impl ExprStmt {
2194 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2195 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2196}
2197
2198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2199pub struct LetStmt {
2200 pub(crate) syntax: SyntaxNode,
2201}
2202impl AstNode for LetStmt { 2630impl AstNode for LetStmt {
2203 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } 2631 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT }
2204 fn cast(syntax: SyntaxNode) -> Option<Self> { 2632 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2210,20 +2638,6 @@ impl AstNode for LetStmt {
2210 } 2638 }
2211 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2639 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2212} 2640}
2213impl ast::AttrsOwner for LetStmt {}
2214impl ast::TypeAscriptionOwner for LetStmt {}
2215impl LetStmt {
2216 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2217 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2218 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2219 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2220 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2221}
2222
2223#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2224pub struct Condition {
2225 pub(crate) syntax: SyntaxNode,
2226}
2227impl AstNode for Condition { 2641impl AstNode for Condition {
2228 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } 2642 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
2229 fn cast(syntax: SyntaxNode) -> Option<Self> { 2643 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2235,17 +2649,6 @@ impl AstNode for Condition {
2235 } 2649 }
2236 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2650 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2237} 2651}
2238impl Condition {
2239 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2240 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2241 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2242 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2243}
2244
2245#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2246pub struct Block {
2247 pub(crate) syntax: SyntaxNode,
2248}
2249impl AstNode for Block { 2652impl AstNode for Block {
2250 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK } 2653 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK }
2251 fn cast(syntax: SyntaxNode) -> Option<Self> { 2654 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2257,19 +2660,6 @@ impl AstNode for Block {
2257 } 2660 }
2258 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2661 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2259} 2662}
2260impl ast::AttrsOwner for Block {}
2261impl ast::ModuleItemOwner for Block {}
2262impl Block {
2263 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2264 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2265 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2266 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2267}
2268
2269#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2270pub struct ParamList {
2271 pub(crate) syntax: SyntaxNode,
2272}
2273impl AstNode for ParamList { 2663impl AstNode for ParamList {
2274 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } 2664 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
2275 fn cast(syntax: SyntaxNode) -> Option<Self> { 2665 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2281,17 +2671,6 @@ impl AstNode for ParamList {
2281 } 2671 }
2282 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2672 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2283} 2673}
2284impl ParamList {
2285 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2286 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2287 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2288 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2289}
2290
2291#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2292pub struct SelfParam {
2293 pub(crate) syntax: SyntaxNode,
2294}
2295impl AstNode for SelfParam { 2674impl AstNode for SelfParam {
2296 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } 2675 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
2297 fn cast(syntax: SyntaxNode) -> Option<Self> { 2676 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2303,21 +2682,6 @@ impl AstNode for SelfParam {
2303 } 2682 }
2304 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2683 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2305} 2684}
2306impl ast::TypeAscriptionOwner for SelfParam {}
2307impl ast::AttrsOwner for SelfParam {}
2308impl SelfParam {
2309 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2310 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2311 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2312 support::token(&self.syntax, T![lifetime])
2313 }
2314 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2315}
2316
2317#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2318pub struct Param {
2319 pub(crate) syntax: SyntaxNode,
2320}
2321impl AstNode for Param { 2685impl AstNode for Param {
2322 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } 2686 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
2323 fn cast(syntax: SyntaxNode) -> Option<Self> { 2687 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2329,17 +2693,6 @@ impl AstNode for Param {
2329 } 2693 }
2330 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2694 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2331} 2695}
2332impl ast::TypeAscriptionOwner for Param {}
2333impl ast::AttrsOwner for Param {}
2334impl Param {
2335 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2336 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2337}
2338
2339#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2340pub struct UseItem {
2341 pub(crate) syntax: SyntaxNode,
2342}
2343impl AstNode for UseItem { 2696impl AstNode for UseItem {
2344 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } 2697 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM }
2345 fn cast(syntax: SyntaxNode) -> Option<Self> { 2698 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2351,17 +2704,6 @@ impl AstNode for UseItem {
2351 } 2704 }
2352 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2705 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2353} 2706}
2354impl ast::AttrsOwner for UseItem {}
2355impl ast::VisibilityOwner for UseItem {}
2356impl UseItem {
2357 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2358 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2359}
2360
2361#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2362pub struct UseTree {
2363 pub(crate) syntax: SyntaxNode,
2364}
2365impl AstNode for UseTree { 2707impl AstNode for UseTree {
2366 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } 2708 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
2367 fn cast(syntax: SyntaxNode) -> Option<Self> { 2709 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2373,17 +2715,6 @@ impl AstNode for UseTree {
2373 } 2715 }
2374 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2716 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2375} 2717}
2376impl UseTree {
2377 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2378 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2379 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2380 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2381}
2382
2383#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2384pub struct Alias {
2385 pub(crate) syntax: SyntaxNode,
2386}
2387impl AstNode for Alias { 2718impl AstNode for Alias {
2388 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } 2719 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS }
2389 fn cast(syntax: SyntaxNode) -> Option<Self> { 2720 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2395,15 +2726,6 @@ impl AstNode for Alias {
2395 } 2726 }
2396 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2727 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2397} 2728}
2398impl ast::NameOwner for Alias {}
2399impl Alias {
2400 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2401}
2402
2403#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2404pub struct UseTreeList {
2405 pub(crate) syntax: SyntaxNode,
2406}
2407impl AstNode for UseTreeList { 2729impl AstNode for UseTreeList {
2408 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } 2730 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
2409 fn cast(syntax: SyntaxNode) -> Option<Self> { 2731 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2415,16 +2737,6 @@ impl AstNode for UseTreeList {
2415 } 2737 }
2416 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2738 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2417} 2739}
2418impl UseTreeList {
2419 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2420 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2421 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2422}
2423
2424#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2425pub struct ExternCrateItem {
2426 pub(crate) syntax: SyntaxNode,
2427}
2428impl AstNode for ExternCrateItem { 2740impl AstNode for ExternCrateItem {
2429 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } 2741 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM }
2430 fn cast(syntax: SyntaxNode) -> Option<Self> { 2742 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2436,19 +2748,6 @@ impl AstNode for ExternCrateItem {
2436 } 2748 }
2437 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2749 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2438} 2750}
2439impl ast::AttrsOwner for ExternCrateItem {}
2440impl ast::VisibilityOwner for ExternCrateItem {}
2441impl ExternCrateItem {
2442 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2443 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2444 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2445 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2446}
2447
2448#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2449pub struct ArgList {
2450 pub(crate) syntax: SyntaxNode,
2451}
2452impl AstNode for ArgList { 2751impl AstNode for ArgList {
2453 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } 2752 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
2454 fn cast(syntax: SyntaxNode) -> Option<Self> { 2753 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2460,16 +2759,6 @@ impl AstNode for ArgList {
2460 } 2759 }
2461 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2760 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2462} 2761}
2463impl ArgList {
2464 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2465 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2466 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2467}
2468
2469#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2470pub struct Path {
2471 pub(crate) syntax: SyntaxNode,
2472}
2473impl AstNode for Path { 2762impl AstNode for Path {
2474 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } 2763 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
2475 fn cast(syntax: SyntaxNode) -> Option<Self> { 2764 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2481,15 +2770,6 @@ impl AstNode for Path {
2481 } 2770 }
2482 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2771 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2483} 2772}
2484impl Path {
2485 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2486 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2487}
2488
2489#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2490pub struct PathSegment {
2491 pub(crate) syntax: SyntaxNode,
2492}
2493impl AstNode for PathSegment { 2773impl AstNode for PathSegment {
2494 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } 2774 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
2495 fn cast(syntax: SyntaxNode) -> Option<Self> { 2775 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2501,21 +2781,6 @@ impl AstNode for PathSegment {
2501 } 2781 }
2502 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2782 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2503} 2783}
2504impl PathSegment {
2505 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2506 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2507 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2508 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
2509 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
2510 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
2511 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2512 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2513}
2514
2515#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2516pub struct TypeArgList {
2517 pub(crate) syntax: SyntaxNode,
2518}
2519impl AstNode for TypeArgList { 2784impl AstNode for TypeArgList {
2520 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } 2785 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST }
2521 fn cast(syntax: SyntaxNode) -> Option<Self> { 2786 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2527,21 +2792,6 @@ impl AstNode for TypeArgList {
2527 } 2792 }
2528 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2793 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2529} 2794}
2530impl TypeArgList {
2531 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2532 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2533 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2534 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2535 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2536 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2537 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2538 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2539}
2540
2541#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2542pub struct TypeArg {
2543 pub(crate) syntax: SyntaxNode,
2544}
2545impl AstNode for TypeArg { 2795impl AstNode for TypeArg {
2546 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } 2796 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG }
2547 fn cast(syntax: SyntaxNode) -> Option<Self> { 2797 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2553,14 +2803,6 @@ impl AstNode for TypeArg {
2553 } 2803 }
2554 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2804 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2555} 2805}
2556impl TypeArg {
2557 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2558}
2559
2560#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2561pub struct AssocTypeArg {
2562 pub(crate) syntax: SyntaxNode,
2563}
2564impl AstNode for AssocTypeArg { 2806impl AstNode for AssocTypeArg {
2565 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } 2807 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
2566 fn cast(syntax: SyntaxNode) -> Option<Self> { 2808 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2572,17 +2814,6 @@ impl AstNode for AssocTypeArg {
2572 } 2814 }
2573 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2815 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2574} 2816}
2575impl ast::TypeBoundsOwner for AssocTypeArg {}
2576impl AssocTypeArg {
2577 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2578 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2579 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2580}
2581
2582#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2583pub struct LifetimeArg {
2584 pub(crate) syntax: SyntaxNode,
2585}
2586impl AstNode for LifetimeArg { 2817impl AstNode for LifetimeArg {
2587 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } 2818 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG }
2588 fn cast(syntax: SyntaxNode) -> Option<Self> { 2819 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2594,16 +2825,6 @@ impl AstNode for LifetimeArg {
2594 } 2825 }
2595 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2826 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2596} 2827}
2597impl LifetimeArg {
2598 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2599 support::token(&self.syntax, T![lifetime])
2600 }
2601}
2602
2603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2604pub struct ConstArg {
2605 pub(crate) syntax: SyntaxNode,
2606}
2607impl AstNode for ConstArg { 2828impl AstNode for ConstArg {
2608 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } 2829 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG }
2609 fn cast(syntax: SyntaxNode) -> Option<Self> { 2830 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2615,16 +2836,6 @@ impl AstNode for ConstArg {
2615 } 2836 }
2616 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2837 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2617} 2838}
2618impl ConstArg {
2619 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2620 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2621 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2622}
2623
2624#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2625pub struct MacroItems {
2626 pub(crate) syntax: SyntaxNode,
2627}
2628impl AstNode for MacroItems { 2839impl AstNode for MacroItems {
2629 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } 2840 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS }
2630 fn cast(syntax: SyntaxNode) -> Option<Self> { 2841 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2636,13 +2847,6 @@ impl AstNode for MacroItems {
2636 } 2847 }
2637 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2848 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2638} 2849}
2639impl ast::ModuleItemOwner for MacroItems {}
2640impl MacroItems {}
2641
2642#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2643pub struct MacroStmts {
2644 pub(crate) syntax: SyntaxNode,
2645}
2646impl AstNode for MacroStmts { 2850impl AstNode for MacroStmts {
2647 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } 2851 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS }
2648 fn cast(syntax: SyntaxNode) -> Option<Self> { 2852 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2654,15 +2858,6 @@ impl AstNode for MacroStmts {
2654 } 2858 }
2655 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2859 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2656} 2860}
2657impl MacroStmts {
2658 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2659 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2660}
2661
2662#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2663pub struct ExternItemList {
2664 pub(crate) syntax: SyntaxNode,
2665}
2666impl AstNode for ExternItemList { 2861impl AstNode for ExternItemList {
2667 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } 2862 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
2668 fn cast(syntax: SyntaxNode) -> Option<Self> { 2863 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2674,17 +2869,6 @@ impl AstNode for ExternItemList {
2674 } 2869 }
2675 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2870 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2676} 2871}
2677impl ast::ModuleItemOwner for ExternItemList {}
2678impl ExternItemList {
2679 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2680 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2681 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2682}
2683
2684#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2685pub struct ExternBlock {
2686 pub(crate) syntax: SyntaxNode,
2687}
2688impl AstNode for ExternBlock { 2872impl AstNode for ExternBlock {
2689 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } 2873 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
2690 fn cast(syntax: SyntaxNode) -> Option<Self> { 2874 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2696,15 +2880,6 @@ impl AstNode for ExternBlock {
2696 } 2880 }
2697 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2881 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2698} 2882}
2699impl ExternBlock {
2700 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2701 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2702}
2703
2704#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2705pub struct MetaItem {
2706 pub(crate) syntax: SyntaxNode,
2707}
2708impl AstNode for MetaItem { 2883impl AstNode for MetaItem {
2709 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } 2884 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM }
2710 fn cast(syntax: SyntaxNode) -> Option<Self> { 2885 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2716,17 +2891,6 @@ impl AstNode for MetaItem {
2716 } 2891 }
2717 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2892 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2718} 2893}
2719impl MetaItem {
2720 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2721 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2722 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2723 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2724}
2725
2726#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2727pub struct MacroDef {
2728 pub(crate) syntax: SyntaxNode,
2729}
2730impl AstNode for MacroDef { 2894impl AstNode for MacroDef {
2731 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } 2895 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF }
2732 fn cast(syntax: SyntaxNode) -> Option<Self> { 2896 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2738,17 +2902,6 @@ impl AstNode for MacroDef {
2738 } 2902 }
2739 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2903 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2740} 2904}
2741impl MacroDef {
2742 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2743 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2744}
2745
2746#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2747pub enum NominalDef {
2748 StructDef(StructDef),
2749 EnumDef(EnumDef),
2750 UnionDef(UnionDef),
2751}
2752impl From<StructDef> for NominalDef { 2905impl From<StructDef> for NominalDef {
2753 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } 2906 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) }
2754} 2907}
@@ -2782,16 +2935,6 @@ impl AstNode for NominalDef {
2782 } 2935 }
2783 } 2936 }
2784} 2937}
2785impl ast::NameOwner for NominalDef {}
2786impl ast::TypeParamsOwner for NominalDef {}
2787impl ast::AttrsOwner for NominalDef {}
2788
2789#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2790pub enum GenericParam {
2791 LifetimeParam(LifetimeParam),
2792 TypeParam(TypeParam),
2793 ConstParam(ConstParam),
2794}
2795impl From<LifetimeParam> for GenericParam { 2938impl From<LifetimeParam> for GenericParam {
2796 fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) } 2939 fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) }
2797} 2940}
@@ -2825,14 +2968,6 @@ impl AstNode for GenericParam {
2825 } 2968 }
2826 } 2969 }
2827} 2970}
2828
2829#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2830pub enum GenericArg {
2831 LifetimeArg(LifetimeArg),
2832 TypeArg(TypeArg),
2833 ConstArg(ConstArg),
2834 AssocTypeArg(AssocTypeArg),
2835}
2836impl From<LifetimeArg> for GenericArg { 2971impl From<LifetimeArg> for GenericArg {
2837 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } 2972 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) }
2838} 2973}
@@ -2871,23 +3006,6 @@ impl AstNode for GenericArg {
2871 } 3006 }
2872 } 3007 }
2873} 3008}
2874
2875#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2876pub enum TypeRef {
2877 ParenType(ParenType),
2878 TupleType(TupleType),
2879 NeverType(NeverType),
2880 PathType(PathType),
2881 PointerType(PointerType),
2882 ArrayType(ArrayType),
2883 SliceType(SliceType),
2884 ReferenceType(ReferenceType),
2885 PlaceholderType(PlaceholderType),
2886 FnPointerType(FnPointerType),
2887 ForType(ForType),
2888 ImplTraitType(ImplTraitType),
2889 DynTraitType(DynTraitType),
2890}
2891impl From<ParenType> for TypeRef { 3009impl From<ParenType> for TypeRef {
2892 fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) } 3010 fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) }
2893} 3011}
@@ -2973,24 +3091,6 @@ impl AstNode for TypeRef {
2973 } 3091 }
2974 } 3092 }
2975} 3093}
2976
2977#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2978pub enum ModuleItem {
2979 StructDef(StructDef),
2980 UnionDef(UnionDef),
2981 EnumDef(EnumDef),
2982 FnDef(FnDef),
2983 TraitDef(TraitDef),
2984 TypeAliasDef(TypeAliasDef),
2985 ImplDef(ImplDef),
2986 UseItem(UseItem),
2987 ExternCrateItem(ExternCrateItem),
2988 ConstDef(ConstDef),
2989 StaticDef(StaticDef),
2990 Module(Module),
2991 MacroCall(MacroCall),
2992 ExternBlock(ExternBlock),
2993}
2994impl From<StructDef> for ModuleItem { 3094impl From<StructDef> for ModuleItem {
2995 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) } 3095 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) }
2996} 3096}
@@ -3081,16 +3181,6 @@ impl AstNode for ModuleItem {
3081 } 3181 }
3082 } 3182 }
3083} 3183}
3084impl ast::NameOwner for ModuleItem {}
3085impl ast::AttrsOwner for ModuleItem {}
3086impl ast::VisibilityOwner for ModuleItem {}
3087
3088#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3089pub enum ImplItem {
3090 FnDef(FnDef),
3091 TypeAliasDef(TypeAliasDef),
3092 ConstDef(ConstDef),
3093}
3094impl From<FnDef> for ImplItem { 3184impl From<FnDef> for ImplItem {
3095 fn from(node: FnDef) -> ImplItem { ImplItem::FnDef(node) } 3185 fn from(node: FnDef) -> ImplItem { ImplItem::FnDef(node) }
3096} 3186}
@@ -3124,14 +3214,6 @@ impl AstNode for ImplItem {
3124 } 3214 }
3125 } 3215 }
3126} 3216}
3127impl ast::NameOwner for ImplItem {}
3128impl ast::AttrsOwner for ImplItem {}
3129
3130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3131pub enum ExternItem {
3132 FnDef(FnDef),
3133 StaticDef(StaticDef),
3134}
3135impl From<FnDef> for ExternItem { 3217impl From<FnDef> for ExternItem {
3136 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } 3218 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
3137} 3219}
@@ -3160,44 +3242,6 @@ impl AstNode for ExternItem {
3160 } 3242 }
3161 } 3243 }
3162} 3244}
3163impl ast::NameOwner for ExternItem {}
3164impl ast::AttrsOwner for ExternItem {}
3165impl ast::VisibilityOwner for ExternItem {}
3166
3167#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3168pub enum Expr {
3169 TupleExpr(TupleExpr),
3170 ArrayExpr(ArrayExpr),
3171 ParenExpr(ParenExpr),
3172 PathExpr(PathExpr),
3173 LambdaExpr(LambdaExpr),
3174 IfExpr(IfExpr),
3175 LoopExpr(LoopExpr),
3176 ForExpr(ForExpr),
3177 WhileExpr(WhileExpr),
3178 ContinueExpr(ContinueExpr),
3179 BreakExpr(BreakExpr),
3180 Label(Label),
3181 BlockExpr(BlockExpr),
3182 ReturnExpr(ReturnExpr),
3183 MatchExpr(MatchExpr),
3184 RecordLit(RecordLit),
3185 CallExpr(CallExpr),
3186 IndexExpr(IndexExpr),
3187 MethodCallExpr(MethodCallExpr),
3188 FieldExpr(FieldExpr),
3189 AwaitExpr(AwaitExpr),
3190 TryExpr(TryExpr),
3191 TryBlockExpr(TryBlockExpr),
3192 CastExpr(CastExpr),
3193 RefExpr(RefExpr),
3194 PrefixExpr(PrefixExpr),
3195 RangeExpr(RangeExpr),
3196 BinExpr(BinExpr),
3197 Literal(Literal),
3198 MacroCall(MacroCall),
3199 BoxExpr(BoxExpr),
3200}
3201impl From<TupleExpr> for Expr { 3245impl From<TupleExpr> for Expr {
3202 fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) } 3246 fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) }
3203} 3247}
@@ -3376,26 +3420,6 @@ impl AstNode for Expr {
3376 } 3420 }
3377 } 3421 }
3378} 3422}
3379impl ast::AttrsOwner for Expr {}
3380
3381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3382pub enum Pat {
3383 OrPat(OrPat),
3384 ParenPat(ParenPat),
3385 RefPat(RefPat),
3386 BoxPat(BoxPat),
3387 BindPat(BindPat),
3388 PlaceholderPat(PlaceholderPat),
3389 DotDotPat(DotDotPat),
3390 PathPat(PathPat),
3391 RecordPat(RecordPat),
3392 TupleStructPat(TupleStructPat),
3393 TuplePat(TuplePat),
3394 SlicePat(SlicePat),
3395 RangePat(RangePat),
3396 LiteralPat(LiteralPat),
3397 MacroPat(MacroPat),
3398}
3399impl From<OrPat> for Pat { 3423impl From<OrPat> for Pat {
3400 fn from(node: OrPat) -> Pat { Pat::OrPat(node) } 3424 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
3401} 3425}
@@ -3491,12 +3515,6 @@ impl AstNode for Pat {
3491 } 3515 }
3492 } 3516 }
3493} 3517}
3494
3495#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3496pub enum RecordInnerPat {
3497 RecordFieldPat(RecordFieldPat),
3498 BindPat(BindPat),
3499}
3500impl From<RecordFieldPat> for RecordInnerPat { 3518impl From<RecordFieldPat> for RecordInnerPat {
3501 fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) } 3519 fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) }
3502} 3520}
@@ -3525,12 +3543,6 @@ impl AstNode for RecordInnerPat {
3525 } 3543 }
3526 } 3544 }
3527} 3545}
3528
3529#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3530pub enum AttrInput {
3531 Literal(Literal),
3532 TokenTree(TokenTree),
3533}
3534impl From<Literal> for AttrInput { 3546impl From<Literal> for AttrInput {
3535 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } 3547 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) }
3536} 3548}
@@ -3559,12 +3571,6 @@ impl AstNode for AttrInput {
3559 } 3571 }
3560 } 3572 }
3561} 3573}
3562
3563#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3564pub enum Stmt {
3565 LetStmt(LetStmt),
3566 ExprStmt(ExprStmt),
3567}
3568impl From<LetStmt> for Stmt { 3574impl From<LetStmt> for Stmt {
3569 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } 3575 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3570} 3576}
@@ -3593,12 +3599,6 @@ impl AstNode for Stmt {
3593 } 3599 }
3594 } 3600 }
3595} 3601}
3596
3597#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3598pub enum FieldDefList {
3599 RecordFieldDefList(RecordFieldDefList),
3600 TupleFieldDefList(TupleFieldDefList),
3601}
3602impl From<RecordFieldDefList> for FieldDefList { 3602impl From<RecordFieldDefList> for FieldDefList {
3603 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } 3603 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
3604} 3604}
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs
index 5e19253a6..b14409c39 100644
--- a/crates/rust-analyzer/src/bin/args.rs
+++ b/crates/rust-analyzer/src/bin/args.rs
@@ -84,7 +84,7 @@ impl Args {
84 if matches.contains(["-h", "--help"]) { 84 if matches.contains(["-h", "--help"]) {
85 eprintln!( 85 eprintln!(
86 "\ 86 "\
87ra-cli-parse 87rust-analyzer parse
88 88
89USAGE: 89USAGE:
90 rust-analyzer parse [FLAGS] 90 rust-analyzer parse [FLAGS]
@@ -104,7 +104,7 @@ FLAGS:
104 if matches.contains(["-h", "--help"]) { 104 if matches.contains(["-h", "--help"]) {
105 eprintln!( 105 eprintln!(
106 "\ 106 "\
107ra-cli-symbols 107rust-analyzer symbols
108 108
109USAGE: 109USAGE:
110 rust-analyzer highlight [FLAGS] 110 rust-analyzer highlight [FLAGS]
@@ -123,7 +123,7 @@ FLAGS:
123 if matches.contains(["-h", "--help"]) { 123 if matches.contains(["-h", "--help"]) {
124 eprintln!( 124 eprintln!(
125 "\ 125 "\
126ra-cli-highlight 126rust-analyzer highlight
127 127
128USAGE: 128USAGE:
129 rust-analyzer highlight [FLAGS] 129 rust-analyzer highlight [FLAGS]
@@ -143,7 +143,7 @@ FLAGS:
143 if matches.contains(["-h", "--help"]) { 143 if matches.contains(["-h", "--help"]) {
144 eprintln!( 144 eprintln!(
145 "\ 145 "\
146ra-cli-analysis-stats 146rust-analyzer analysis-stats
147 147
148USAGE: 148USAGE:
149 rust-analyzer analysis-stats [FLAGS] [OPTIONS] [PATH] 149 rust-analyzer analysis-stats [FLAGS] [OPTIONS] [PATH]
@@ -193,7 +193,7 @@ ARGS:
193 if matches.contains(["-h", "--help"]) { 193 if matches.contains(["-h", "--help"]) {
194 eprintln!( 194 eprintln!(
195 "\ 195 "\
196rust-analyzer-analysis-bench 196rust-analyzer analysis-bench
197 197
198USAGE: 198USAGE:
199 rust-analyzer analysis-bench [FLAGS] [OPTIONS] 199 rust-analyzer analysis-bench [FLAGS] [OPTIONS]
@@ -236,7 +236,7 @@ ARGS:
236 if matches.contains(["-h", "--help"]) { 236 if matches.contains(["-h", "--help"]) {
237 eprintln!( 237 eprintln!(
238 "\ 238 "\
239ra-cli-diagnostics 239rust-analyzer diagnostics
240 240
241USAGE: 241USAGE:
242 rust-analyzer diagnostics [FLAGS] [PATH] 242 rust-analyzer diagnostics [FLAGS] [PATH]
@@ -269,7 +269,7 @@ ARGS:
269 _ => { 269 _ => {
270 eprintln!( 270 eprintln!(
271 "\ 271 "\
272ra-cli 272rust-analyzer
273 273
274USAGE: 274USAGE:
275 rust-analyzer <SUBCOMMAND> 275 rust-analyzer <SUBCOMMAND>
@@ -281,6 +281,8 @@ SUBCOMMANDS:
281 analysis-bench 281 analysis-bench
282 analysis-stats 282 analysis-stats
283 highlight 283 highlight
284 diagnostics
285 proc-macro
284 parse 286 parse
285 symbols" 287 symbols"
286 ); 288 );
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc
index abd126340..13ab2acc2 100644
--- a/docs/user/readme.adoc
+++ b/docs/user/readme.adoc
@@ -14,9 +14,9 @@
14// Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository 14// Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository
15 15
16At its core, rust-analyzer is a *library* for semantic analysis of Rust code as it changes over time. 16At its core, rust-analyzer is a *library* for semantic analysis of Rust code as it changes over time.
17This manual focuses on a specific usage of the library -- the implementation of 17This manual focuses on a specific usage of the library -- running it as part of a server that implements the
18https://microsoft.github.io/language-server-protocol/[Language Server Protocol]. 18https://microsoft.github.io/language-server-protocol/[Language Server Protocol] (LSP).
19LSP allows various code editors, like VS Code, Emacs or Vim, to implement semantic features like completion or goto definition by talking to an external language server process. 19The LSP allows various code editors, like VS Code, Emacs or Vim, to implement semantic features like completion or goto definition by talking to an external language server process.
20 20
21To improve this document, send a pull request against 21To improve this document, send a pull request against
22https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file]. 22https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc[this file].
@@ -26,7 +26,7 @@ https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/readme.adoc
26In theory, one should be able to just install the server binary and have it automatically work with any editor. 26In theory, one should be able to just install the server binary and have it automatically work with any editor.
27We are not there yet, so some editor specific setup is required. 27We are not there yet, so some editor specific setup is required.
28 28
29Additionally, rust-analyzer needs sources of the standard library. 29Additionally, rust-analyzer needs the sources of the standard library.
30If the source code is not present, rust-analyzer will attempt to install it automatically. 30If the source code is not present, rust-analyzer will attempt to install it automatically.
31 31
32To add the sources manually, run the following command: 32To add the sources manually, run the following command:
@@ -38,7 +38,7 @@ $ rustup component add rust-src
38=== VS Code 38=== VS Code
39 39
40This is the best supported editor at the moment. 40This is the best supported editor at the moment.
41rust-analyzer plugin for VS Code is maintained 41The rust-analyzer plugin for VS Code is maintained
42https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree]. 42https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree].
43 43
44You can install the latest release of the plugin from 44You can install the latest release of the plugin from
@@ -74,7 +74,7 @@ We ship nightly releases for VS Code. To help us out with testing the newest cod
74{ "rust-analyzer.updates.channel": "nightly" } 74{ "rust-analyzer.updates.channel": "nightly" }
75---- 75----
76 76
77You will be prompted to install the `nightly` extension version. Just click `Download now` and from that moment you will get automatic updates each 24 hours. 77You will be prompted to install the `nightly` extension version. Just click `Download now` and from that moment you will get automatic updates every 24 hours.
78 78
79If you don't want to be asked for `Download now` every day when the new nightly version is released add the following to your `settings.json`: 79If you don't want to be asked for `Download now` every day when the new nightly version is released add the following to your `settings.json`:
80[source,json] 80[source,json]
@@ -110,19 +110,21 @@ Here are some useful self-diagnostic commands:
110 110
111=== Language Server Binary 111=== Language Server Binary
112 112
113Other editors generally require `rust-analyzer` binary to be in `$PATH`. 113Other editors generally require the `rust-analyzer` binary to be in `$PATH`.
114You can download the pre-built binary from 114You can download the pre-built binary from the https://github.com/rust-analyzer/rust-analyzer/releases[releases] page. Typically, you then need to rename the binary for your platform, e.g. `rust-analyzer-mac` if you're on Mac OS, to `rust-analzyer` and make it executable in addition to moving it into a directory in your `$PATH`.
115https://github.com/rust-analyzer/rust-analyzer/releases[releases] 115
116page, or you can install it from source using the following command: 116Alternatively, you can install it from source using the following command:
117 117
118[source,bash] 118[source,bash]
119---- 119----
120$ cargo xtask install --server 120$ cargo xtask install --server
121---- 121----
122 122
123If your editor can't find the binary even though the binary is on your `$PATH`, the likely explanation is that it doesn't see the same `$PATH` as the shell, see https://github.com/rust-analyzer/rust-analyzer/issues/1811[this issue]. On Unix, running the editor from a shell or changing the `.desktop` file to set the environment should help.
124
123==== Arch Linux 125==== Arch Linux
124 126
125`rust-analyzer` binary can be installed from AUR (Arch User Repository): 127The `rust-analyzer` binary can be installed from AUR (Arch User Repository):
126 128
127- https://aur.archlinux.org/packages/rust-analyzer-bin[`rust-analyzer-bin`] (binary from GitHub releases) 129- https://aur.archlinux.org/packages/rust-analyzer-bin[`rust-analyzer-bin`] (binary from GitHub releases)
128- https://aur.archlinux.org/packages/rust-analyzer[`rust-analyzer`] (built from latest tagged source) 130- https://aur.archlinux.org/packages/rust-analyzer[`rust-analyzer`] (built from latest tagged source)
@@ -156,8 +158,8 @@ The are several LSP client implementations for vim:
1562. Run `:CocInstall coc-rust-analyzer` to install 1582. Run `:CocInstall coc-rust-analyzer` to install
157 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer], 159 https://github.com/fannheyward/coc-rust-analyzer[coc-rust-analyzer],
158 this extension implements _most_ of the features supported in the VSCode extension: 160 this extension implements _most_ of the features supported in the VSCode extension:
159 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.enableCargoWatchOnStartup` etc. 161 * same configurations as VSCode extension, `rust-analyzer.serverPath`, `rust-analyzer.cargo.features` etc.
160 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.startCargoWatch` etc. 162 * same commands too, `rust-analyzer.analyzerStatus`, `rust-analyzer.ssr` etc.
161 * highlighting and inlay_hints are not implemented yet 163 * highlighting and inlay_hints are not implemented yet
162 164
163==== LanguageClient-neovim 165==== LanguageClient-neovim
@@ -183,11 +185,20 @@ Once `neovim/nvim-lsp` is installed, use `+lua require'nvim_lsp'.rust_analyzer.s
183 185
184=== Sublime Text 3 186=== Sublime Text 3
185 187
186Prerequisites: 188Prerequisites: You have installed the <<language-server-binary,`rust-analyzer` binary>>.
189
190You also need the `LSP` package. To install it:
191
1921. If you've never installed a Sublime Text package, install Package Control:
193 * Open the command palette (Win/Linux: `ctrl+shift+p`, Mac: `cmd+shift+p`)
194 * Type `Install Package Control`, press enter
1952. In the command palette, run `Package control: Install package`, and in the list that pops up, type `LSP` and press enter.
196
197Finally, with your Rust project open, in the command palette, run `LSP: Enable Language Server In Project` or `LSP: Enable Language Server Globally`, then select `rust-analyzer` in the list that pops up to enable the rust-analyzer LSP. The latter means that rust-analzyer is enabled by default in Rust projects.
187 198
188`LSP` package. 199If it worked, you should see "rust-analzyer, Line X, Column Y" on the left side of the bottom bar, and after waiting a bit, functionality like tooltips on hovering over variables should become available.
189 200
190Invoke the command palette (`ctrl+shift+p`) and type LSP enable to locally/globally enable the rust-analyzer LSP (type LSP enable, then choose either locally or globally, then select rust-analyzer) 201If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <<language-server-binary,section on installing the language server binary>>.
191 202
192== Usage 203== Usage
193 204
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index ec1f6ad8a..e9dc09552 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -63,126 +63,138 @@ fn generate_tokens(grammar: AstSrc<'_>) -> Result<String> {
63} 63}
64 64
65fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> { 65fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
66 let nodes = grammar.nodes.iter().map(|node| { 66 let (node_defs, node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
67 let name = format_ident!("{}", node.name); 67 .nodes
68 let kind = format_ident!("{}", to_upper_snake_case(&name.to_string())); 68 .iter()
69 let traits = node.traits.iter().map(|trait_name| { 69 .map(|node| {
70 let trait_name = format_ident!("{}", trait_name); 70 let name = format_ident!("{}", node.name);
71 quote!(impl ast::#trait_name for #name {}) 71 let kind = format_ident!("{}", to_upper_snake_case(&name.to_string()));
72 }); 72 let traits = node.traits.iter().map(|trait_name| {
73 73 let trait_name = format_ident!("{}", trait_name);
74 let methods = node.fields.iter().map(|field| { 74 quote!(impl ast::#trait_name for #name {})
75 let method_name = field.method_name(); 75 });
76 let ty = field.ty(); 76
77 77 let methods = node.fields.iter().map(|field| {
78 if field.is_many() { 78 let method_name = field.method_name();
79 quote! { 79 let ty = field.ty();
80 pub fn #method_name(&self) -> AstChildren<#ty> { 80
81 support::children(&self.syntax) 81 if field.is_many() {
82 }
83 }
84 } else {
85 if let Some(token_kind) = field.token_kind() {
86 quote! { 82 quote! {
87 pub fn #method_name(&self) -> Option<#ty> { 83 pub fn #method_name(&self) -> AstChildren<#ty> {
88 support::token(&self.syntax, #token_kind) 84 support::children(&self.syntax)
89 } 85 }
90 } 86 }
91 } else { 87 } else {
92 quote! { 88 if let Some(token_kind) = field.token_kind() {
93 pub fn #method_name(&self) -> Option<#ty> { 89 quote! {
94 support::child(&self.syntax) 90 pub fn #method_name(&self) -> Option<#ty> {
91 support::token(&self.syntax, #token_kind)
92 }
93 }
94 } else {
95 quote! {
96 pub fn #method_name(&self) -> Option<#ty> {
97 support::child(&self.syntax)
98 }
95 } 99 }
96 } 100 }
97 } 101 }
98 } 102 });
99 }); 103 (
100 104 quote! {
101 quote! { 105 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
102 #[derive(Debug, Clone, PartialEq, Eq, Hash)] 106 pub struct #name {
103 pub struct #name { 107 pub(crate) syntax: SyntaxNode,
104 pub(crate) syntax: SyntaxNode, 108 }
105 }
106
107 impl AstNode for #name {
108 fn can_cast(kind: SyntaxKind) -> bool {
109 kind == #kind
110 }
111 fn cast(syntax: SyntaxNode) -> Option<Self> {
112 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
113 }
114 fn syntax(&self) -> &SyntaxNode { &self.syntax }
115 }
116
117 #(#traits)*
118
119 impl #name {
120 #(#methods)*
121 }
122 }
123 });
124 109
125 let enums = grammar.enums.iter().map(|en| { 110 #(#traits)*
126 let variants = en.variants.iter().map(|var| format_ident!("{}", var)).collect::<Vec<_>>();
127 let name = format_ident!("{}", en.name);
128 let kinds = variants
129 .iter()
130 .map(|name| format_ident!("{}", to_upper_snake_case(&name.to_string())))
131 .collect::<Vec<_>>();
132 let traits = en.traits.iter().map(|trait_name| {
133 let trait_name = format_ident!("{}", trait_name);
134 quote!(impl ast::#trait_name for #name {})
135 });
136 111
137 quote! { 112 impl #name {
138 #[derive(Debug, Clone, PartialEq, Eq, Hash)] 113 #(#methods)*
139 pub enum #name { 114 }
140 #(#variants(#variants),)* 115 },
141 } 116 quote! {
117 impl AstNode for #name {
118 fn can_cast(kind: SyntaxKind) -> bool {
119 kind == #kind
120 }
121 fn cast(syntax: SyntaxNode) -> Option<Self> {
122 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
123 }
124 fn syntax(&self) -> &SyntaxNode { &self.syntax }
125 }
126 },
127 )
128 })
129 .unzip();
142 130
143 #( 131 let (enum_defs, enum_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
144 impl From<#variants> for #name { 132 .enums
145 fn from(node: #variants) -> #name { 133 .iter()
146 #name::#variants(node) 134 .map(|en| {
147 } 135 let variants: Vec<_> = en.variants.iter().map(|var| format_ident!("{}", var)).collect();
148 } 136 let name = format_ident!("{}", en.name);
149 )* 137 let kinds: Vec<_> = variants
138 .iter()
139 .map(|name| format_ident!("{}", to_upper_snake_case(&name.to_string())))
140 .collect();
141 let traits = en.traits.iter().map(|trait_name| {
142 let trait_name = format_ident!("{}", trait_name);
143 quote!(impl ast::#trait_name for #name {})
144 });
145
146 (
147 quote! {
148 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
149 pub enum #name {
150 #(#variants(#variants),)*
151 }
150 152
151 impl AstNode for #name { 153 #(#traits)*
152 fn can_cast(kind: SyntaxKind) -> bool { 154 },
153 match kind { 155 quote! {
154 #(#kinds)|* => true, 156 #(
155 _ => false, 157 impl From<#variants> for #name {
158 fn from(node: #variants) -> #name {
159 #name::#variants(node)
160 }
156 } 161 }
157 } 162 )*
158 fn cast(syntax: SyntaxNode) -> Option<Self> { 163
159 let res = match syntax.kind() { 164 impl AstNode for #name {
160 #( 165 fn can_cast(kind: SyntaxKind) -> bool {
161 #kinds => #name::#variants(#variants { syntax }), 166 match kind {
162 )* 167 #(#kinds)|* => true,
163 _ => return None, 168 _ => false,
164 }; 169 }
165 Some(res) 170 }
166 } 171 fn cast(syntax: SyntaxNode) -> Option<Self> {
167 fn syntax(&self) -> &SyntaxNode { 172 let res = match syntax.kind() {
168 match self { 173 #(
169 #( 174 #kinds => #name::#variants(#variants { syntax }),
170 #name::#variants(it) => &it.syntax, 175 )*
171 )* 176 _ => return None,
177 };
178 Some(res)
179 }
180 fn syntax(&self) -> &SyntaxNode {
181 match self {
182 #(
183 #name::#variants(it) => &it.syntax,
184 )*
185 }
186 }
172 } 187 }
173 } 188 },
174 } 189 )
190 })
191 .unzip();
175 192
176 #(#traits)* 193 let enum_names = grammar.enums.iter().map(|it| it.name);
177 } 194 let node_names = grammar.nodes.iter().map(|it| it.name);
178 });
179 195
180 let displays = grammar 196 let display_impls =
181 .enums 197 enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| {
182 .iter()
183 .map(|it| format_ident!("{}", it.name))
184 .chain(grammar.nodes.iter().map(|it| format_ident!("{}", it.name)))
185 .map(|name| {
186 quote! { 198 quote! {
187 impl std::fmt::Display for #name { 199 impl std::fmt::Display for #name {
188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 200 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
@@ -192,13 +204,13 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
192 } 204 }
193 }); 205 });
194 206
195 let defined_nodes: HashSet<_> = grammar.nodes.iter().map(|node| node.name).collect(); 207 let defined_nodes: HashSet<_> = node_names.collect();
196 208
197 for node in kinds 209 for node in kinds
198 .nodes 210 .nodes
199 .iter() 211 .iter()
200 .map(|kind| to_pascal_case(*kind)) 212 .map(|kind| to_pascal_case(kind))
201 .filter(|name| !defined_nodes.contains(&**name)) 213 .filter(|name| !defined_nodes.contains(name.as_str()))
202 { 214 {
203 eprintln!("Warning: node {} not defined in ast source", node); 215 eprintln!("Warning: node {} not defined in ast source", node);
204 } 216 }
@@ -210,9 +222,11 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
210 T, 222 T,
211 }; 223 };
212 224
213 #(#nodes)* 225 #(#node_defs)*
214 #(#enums)* 226 #(#enum_defs)*
215 #(#displays)* 227 #(#node_boilerplate_impls)*
228 #(#enum_boilerplate_impls)*
229 #(#display_impls)*
216 }; 230 };
217 231
218 let ast = ast.to_string().replace("T ! [ ", "T![").replace(" ] )", "])"); 232 let ast = ast.to_string().replace("T ! [ ", "T![").replace(" ] )", "])");
@@ -380,20 +394,16 @@ fn to_pascal_case(s: &str) -> String {
380 394
381impl Field<'_> { 395impl Field<'_> {
382 fn is_many(&self) -> bool { 396 fn is_many(&self) -> bool {
383 match self { 397 matches!(self, Field::Node { src: FieldSrc::Many(_), .. })
384 Field::Node { src: FieldSrc::Many(_), .. } => true,
385 _ => false,
386 }
387 } 398 }
388 fn token_kind(&self) -> Option<proc_macro2::TokenStream> { 399 fn token_kind(&self) -> Option<proc_macro2::TokenStream> {
389 let res = match self { 400 match self {
390 Field::Token(token) => { 401 Field::Token(token) => {
391 let token: proc_macro2::TokenStream = token.parse().unwrap(); 402 let token: proc_macro2::TokenStream = token.parse().unwrap();
392 quote! { T![#token] } 403 Some(quote! { T![#token] })
393 } 404 }
394 _ => return None, 405 _ => None,
395 }; 406 }
396 Some(res)
397 } 407 }
398 fn method_name(&self) -> proc_macro2::Ident { 408 fn method_name(&self) -> proc_macro2::Ident {
399 match self { 409 match self {