aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs8
-rw-r--r--crates/ra_syntax/src/ast/edit.rs18
-rw-r--r--crates/ra_syntax/src/ast/expr_ext.rs8
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs865
-rw-r--r--crates/ra_syntax/src/ast/make.rs10
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs44
-rw-r--r--crates/ra_syntax/src/ast/traits.rs4
-rw-r--r--crates/ra_syntax/src/lib.rs6
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs4
-rw-r--r--crates/ra_syntax/src/ptr.rs2
-rw-r--r--crates/ra_syntax/src/validation.rs6
-rw-r--r--crates/ra_syntax/src/validation/block.rs2
12 files changed, 488 insertions, 489 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index c65c485cb..fd426ece9 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -139,7 +139,7 @@ fn test_doc_comment_of_statics() {
139 ) 139 )
140 .ok() 140 .ok()
141 .unwrap(); 141 .unwrap();
142 let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); 142 let st = file.syntax().descendants().find_map(Static::cast).unwrap();
143 assert_eq!("Number of levels", st.doc_comment_text().unwrap()); 143 assert_eq!("Number of levels", st.doc_comment_text().unwrap());
144} 144}
145 145
@@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() {
235 ) 235 )
236 .ok() 236 .ok()
237 .unwrap(); 237 .unwrap();
238 let def = file.syntax().descendants().find_map(StructDef::cast).unwrap(); 238 let def = file.syntax().descendants().find_map(Struct::cast).unwrap();
239 assert_eq!( 239 assert_eq!(
240 "Representation of a Realm. \nIn the specification these are called Realm Records.", 240 "Representation of a Realm. \nIn the specification these are called Realm Records.",
241 def.doc_comment_text().unwrap() 241 def.doc_comment_text().unwrap()
@@ -286,7 +286,7 @@ where
286 let mut bounds = pred.type_bound_list().unwrap().bounds(); 286 let mut bounds = pred.type_bound_list().unwrap().bounds();
287 287
288 assert!(pred.for_token().is_none()); 288 assert!(pred.for_token().is_none());
289 assert!(pred.type_param_list().is_none()); 289 assert!(pred.generic_param_list().is_none());
290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); 290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string());
291 assert_bound("Clone", bounds.next()); 291 assert_bound("Clone", bounds.next());
292 assert_bound("Copy", bounds.next()); 292 assert_bound("Copy", bounds.next());
@@ -325,7 +325,7 @@ where
325 let mut bounds = pred.type_bound_list().unwrap().bounds(); 325 let mut bounds = pred.type_bound_list().unwrap().bounds();
326 326
327 assert!(pred.for_token().is_some()); 327 assert!(pred.for_token().is_some());
328 assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); 328 assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string());
329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); 329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string());
330 assert_bound("Fn(&'a str)", bounds.next()); 330 assert_bound("Fn(&'a str)", bounds.next());
331} 331}
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 6ebe10ff6..8d3e42f25 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -29,9 +29,9 @@ impl ast::BinExpr {
29 } 29 }
30} 30}
31 31
32impl ast::FnDef { 32impl ast::Fn {
33 #[must_use] 33 #[must_use]
34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { 34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); 35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { 36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
37 old_body.syntax().clone().into() 37 old_body.syntax().clone().into()
@@ -116,18 +116,18 @@ impl ast::AssocItemList {
116 } 116 }
117} 117}
118 118
119impl ast::RecordFieldList { 119impl ast::RecordExprFieldList {
120 #[must_use] 120 #[must_use]
121 pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { 121 pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList {
122 self.insert_field(InsertPosition::Last, field) 122 self.insert_field(InsertPosition::Last, field)
123 } 123 }
124 124
125 #[must_use] 125 #[must_use]
126 pub fn insert_field( 126 pub fn insert_field(
127 &self, 127 &self,
128 position: InsertPosition<&'_ ast::RecordField>, 128 position: InsertPosition<&'_ ast::RecordExprField>,
129 field: &ast::RecordField, 129 field: &ast::RecordExprField,
130 ) -> ast::RecordFieldList { 130 ) -> ast::RecordExprFieldList {
131 let is_multiline = self.syntax().text().contains_char('\n'); 131 let is_multiline = self.syntax().text().contains_char('\n');
132 let ws; 132 let ws;
133 let space = if is_multiline { 133 let space = if is_multiline {
@@ -192,9 +192,9 @@ impl ast::RecordFieldList {
192 } 192 }
193} 193}
194 194
195impl ast::TypeAliasDef { 195impl ast::TypeAlias {
196 #[must_use] 196 #[must_use]
197 pub fn remove_bounds(&self) -> ast::TypeAliasDef { 197 pub fn remove_bounds(&self) -> ast::TypeAlias {
198 let colon = match self.colon_token() { 198 let colon = match self.colon_token() {
199 Some(it) => it, 199 Some(it) => it,
200 None => return self.clone(), 200 None => return self.clone(),
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs
index 69c85c809..365f94287 100644
--- a/crates/ra_syntax/src/ast/expr_ext.rs
+++ b/crates/ra_syntax/src/ast/expr_ext.rs
@@ -401,7 +401,7 @@ impl ast::BlockExpr {
401 Some(it) => it, 401 Some(it) => it,
402 None => return true, 402 None => return true,
403 }; 403 };
404 !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) 404 !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
405 } 405 }
406} 406}
407 407
@@ -412,8 +412,8 @@ fn test_literal_with_attr() {
412 assert_eq!(lit.token().text(), r#""Hello""#); 412 assert_eq!(lit.token().text(), r#""Hello""#);
413} 413}
414 414
415impl ast::RecordField { 415impl ast::RecordExprField {
416 pub fn parent_record_lit(&self) -> ast::RecordLit { 416 pub fn parent_record_lit(&self) -> ast::RecordExpr {
417 self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() 417 self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
418 } 418 }
419} 419}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index be657699f..00a70fce0 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -28,32 +28,33 @@ impl Attr {
28 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 28 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
29} 29}
30#[derive(Debug, Clone, PartialEq, Eq, Hash)] 30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31pub struct ConstDef { 31pub struct Const {
32 pub(crate) syntax: SyntaxNode, 32 pub(crate) syntax: SyntaxNode,
33} 33}
34impl ast::AttrsOwner for ConstDef {} 34impl ast::AttrsOwner for Const {}
35impl ast::NameOwner for ConstDef {} 35impl ast::NameOwner for Const {}
36impl ast::VisibilityOwner for ConstDef {} 36impl ast::VisibilityOwner for Const {}
37impl ast::TypeAscriptionOwner for ConstDef {} 37impl ast::TypeAscriptionOwner for Const {}
38impl ConstDef { 38impl Const {
39 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 39 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
40 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 40 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
41 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
41 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 42 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
42 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 43 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
43 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 44 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
44 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 45 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
45} 46}
46#[derive(Debug, Clone, PartialEq, Eq, Hash)] 47#[derive(Debug, Clone, PartialEq, Eq, Hash)]
47pub struct EnumDef { 48pub struct Enum {
48 pub(crate) syntax: SyntaxNode, 49 pub(crate) syntax: SyntaxNode,
49} 50}
50impl ast::AttrsOwner for EnumDef {} 51impl ast::AttrsOwner for Enum {}
51impl ast::NameOwner for EnumDef {} 52impl ast::NameOwner for Enum {}
52impl ast::VisibilityOwner for EnumDef {} 53impl ast::VisibilityOwner for Enum {}
53impl ast::TypeParamsOwner for EnumDef {} 54impl ast::GenericParamsOwner for Enum {}
54impl EnumDef { 55impl Enum {
55 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } 56 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
56 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } 57 pub fn variant_list(&self) -> Option<VariantList> { support::child(&self.syntax) }
57} 58}
58#[derive(Debug, Clone, PartialEq, Eq, Hash)] 59#[derive(Debug, Clone, PartialEq, Eq, Hash)]
59pub struct ExternBlock { 60pub struct ExternBlock {
@@ -79,19 +80,19 @@ impl ExternCrate {
79 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 80 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
80} 81}
81#[derive(Debug, Clone, PartialEq, Eq, Hash)] 82#[derive(Debug, Clone, PartialEq, Eq, Hash)]
82pub struct FnDef { 83pub struct Fn {
83 pub(crate) syntax: SyntaxNode, 84 pub(crate) syntax: SyntaxNode,
84} 85}
85impl ast::AttrsOwner for FnDef {} 86impl ast::AttrsOwner for Fn {}
86impl ast::NameOwner for FnDef {} 87impl ast::NameOwner for Fn {}
87impl ast::VisibilityOwner for FnDef {} 88impl ast::VisibilityOwner for Fn {}
88impl ast::TypeParamsOwner for FnDef {} 89impl ast::GenericParamsOwner for Fn {}
89impl FnDef { 90impl Fn {
90 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
91 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
92 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 91 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
93 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 92 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
93 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
94 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 94 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
95 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
95 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } 96 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
96 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 97 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
97 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 98 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
@@ -104,7 +105,7 @@ pub struct ImplDef {
104} 105}
105impl ast::AttrsOwner for ImplDef {} 106impl ast::AttrsOwner for ImplDef {}
106impl ast::VisibilityOwner for ImplDef {} 107impl ast::VisibilityOwner for ImplDef {}
107impl ast::TypeParamsOwner for ImplDef {} 108impl ast::GenericParamsOwner for ImplDef {}
108impl ImplDef { 109impl ImplDef {
109 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 110 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
110 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 111 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
@@ -139,14 +140,14 @@ impl Module {
139 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 140 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
140} 141}
141#[derive(Debug, Clone, PartialEq, Eq, Hash)] 142#[derive(Debug, Clone, PartialEq, Eq, Hash)]
142pub struct StaticDef { 143pub struct Static {
143 pub(crate) syntax: SyntaxNode, 144 pub(crate) syntax: SyntaxNode,
144} 145}
145impl ast::AttrsOwner for StaticDef {} 146impl ast::AttrsOwner for Static {}
146impl ast::NameOwner for StaticDef {} 147impl ast::NameOwner for Static {}
147impl ast::VisibilityOwner for StaticDef {} 148impl ast::VisibilityOwner for Static {}
148impl ast::TypeAscriptionOwner for StaticDef {} 149impl ast::TypeAscriptionOwner for Static {}
149impl StaticDef { 150impl Static {
150 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 151 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
151 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 152 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
152 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 153 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
@@ -155,17 +156,17 @@ impl StaticDef {
155 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 156 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
156} 157}
157#[derive(Debug, Clone, PartialEq, Eq, Hash)] 158#[derive(Debug, Clone, PartialEq, Eq, Hash)]
158pub struct StructDef { 159pub struct Struct {
159 pub(crate) syntax: SyntaxNode, 160 pub(crate) syntax: SyntaxNode,
160} 161}
161impl ast::AttrsOwner for StructDef {} 162impl ast::AttrsOwner for Struct {}
162impl ast::NameOwner for StructDef {} 163impl ast::NameOwner for Struct {}
163impl ast::VisibilityOwner for StructDef {} 164impl ast::VisibilityOwner for Struct {}
164impl ast::TypeParamsOwner for StructDef {} 165impl ast::GenericParamsOwner for Struct {}
165impl StructDef { 166impl Struct {
166 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } 167 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
167 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 168 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
168 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 169 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
169} 170}
170#[derive(Debug, Clone, PartialEq, Eq, Hash)] 171#[derive(Debug, Clone, PartialEq, Eq, Hash)]
171pub struct TraitDef { 172pub struct TraitDef {
@@ -174,7 +175,7 @@ pub struct TraitDef {
174impl ast::AttrsOwner for TraitDef {} 175impl ast::AttrsOwner for TraitDef {}
175impl ast::NameOwner for TraitDef {} 176impl ast::NameOwner for TraitDef {}
176impl ast::VisibilityOwner for TraitDef {} 177impl ast::VisibilityOwner for TraitDef {}
177impl ast::TypeParamsOwner for TraitDef {} 178impl ast::GenericParamsOwner for TraitDef {}
178impl ast::TypeBoundsOwner for TraitDef {} 179impl ast::TypeBoundsOwner for TraitDef {}
179impl TraitDef { 180impl TraitDef {
180 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 181 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
@@ -183,15 +184,15 @@ impl TraitDef {
183 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } 184 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
184} 185}
185#[derive(Debug, Clone, PartialEq, Eq, Hash)] 186#[derive(Debug, Clone, PartialEq, Eq, Hash)]
186pub struct TypeAliasDef { 187pub struct TypeAlias {
187 pub(crate) syntax: SyntaxNode, 188 pub(crate) syntax: SyntaxNode,
188} 189}
189impl ast::AttrsOwner for TypeAliasDef {} 190impl ast::AttrsOwner for TypeAlias {}
190impl ast::NameOwner for TypeAliasDef {} 191impl ast::NameOwner for TypeAlias {}
191impl ast::VisibilityOwner for TypeAliasDef {} 192impl ast::VisibilityOwner for TypeAlias {}
192impl ast::TypeParamsOwner for TypeAliasDef {} 193impl ast::GenericParamsOwner for TypeAlias {}
193impl ast::TypeBoundsOwner for TypeAliasDef {} 194impl ast::TypeBoundsOwner for TypeAlias {}
194impl TypeAliasDef { 195impl TypeAlias {
195 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 196 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
196 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } 197 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
197 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 198 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
@@ -199,18 +200,16 @@ impl TypeAliasDef {
199 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 200 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
200} 201}
201#[derive(Debug, Clone, PartialEq, Eq, Hash)] 202#[derive(Debug, Clone, PartialEq, Eq, Hash)]
202pub struct UnionDef { 203pub struct Union {
203 pub(crate) syntax: SyntaxNode, 204 pub(crate) syntax: SyntaxNode,
204} 205}
205impl ast::AttrsOwner for UnionDef {} 206impl ast::AttrsOwner for Union {}
206impl ast::NameOwner for UnionDef {} 207impl ast::NameOwner for Union {}
207impl ast::VisibilityOwner for UnionDef {} 208impl ast::VisibilityOwner for Union {}
208impl ast::TypeParamsOwner for UnionDef {} 209impl ast::GenericParamsOwner for Union {}
209impl UnionDef { 210impl Union {
210 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } 211 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
211 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 212 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
212 support::child(&self.syntax)
213 }
214} 213}
215#[derive(Debug, Clone, PartialEq, Eq, Hash)] 214#[derive(Debug, Clone, PartialEq, Eq, Hash)]
216pub struct Use { 215pub struct Use {
@@ -303,12 +302,14 @@ impl UseTreeList {
303pub struct Abi { 302pub struct Abi {
304 pub(crate) syntax: SyntaxNode, 303 pub(crate) syntax: SyntaxNode,
305} 304}
306impl Abi {} 305impl Abi {
306 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
307}
307#[derive(Debug, Clone, PartialEq, Eq, Hash)] 308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
308pub struct TypeParamList { 309pub struct GenericParamList {
309 pub(crate) syntax: SyntaxNode, 310 pub(crate) syntax: SyntaxNode,
310} 311}
311impl TypeParamList { 312impl GenericParamList {
312 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } 313 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
313 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) } 314 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
314 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) } 315 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
@@ -321,8 +322,9 @@ pub struct ParamList {
321} 322}
322impl ParamList { 323impl ParamList {
323 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 324 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
324 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
325 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } 325 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
326 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
327 pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
326 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 328 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
327} 329}
328#[derive(Debug, Clone, PartialEq, Eq, Hash)] 330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -355,73 +357,98 @@ impl BlockExpr {
355 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 357 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
356} 358}
357#[derive(Debug, Clone, PartialEq, Eq, Hash)] 359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
358pub struct RecordFieldDefList { 360pub struct Param {
361 pub(crate) syntax: SyntaxNode,
362}
363impl ast::AttrsOwner for Param {}
364impl ast::TypeAscriptionOwner for Param {}
365impl Param {
366 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
367 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
368 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
369}
370#[derive(Debug, Clone, PartialEq, Eq, Hash)]
371pub struct SelfParam {
372 pub(crate) syntax: SyntaxNode,
373}
374impl ast::AttrsOwner for SelfParam {}
375impl ast::TypeAscriptionOwner for SelfParam {}
376impl SelfParam {
377 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
378 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
379 support::token(&self.syntax, T![lifetime])
380 }
381 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
382 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
383 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
384}
385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
386pub struct TypeBoundList {
387 pub(crate) syntax: SyntaxNode,
388}
389impl TypeBoundList {
390 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
391}
392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
393pub struct RecordFieldList {
359 pub(crate) syntax: SyntaxNode, 394 pub(crate) syntax: SyntaxNode,
360} 395}
361impl RecordFieldDefList { 396impl RecordFieldList {
362 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 397 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
363 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } 398 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
364 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 399 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
365} 400}
366#[derive(Debug, Clone, PartialEq, Eq, Hash)] 401#[derive(Debug, Clone, PartialEq, Eq, Hash)]
367pub struct TupleFieldDefList { 402pub struct TupleFieldList {
368 pub(crate) syntax: SyntaxNode, 403 pub(crate) syntax: SyntaxNode,
369} 404}
370impl TupleFieldDefList { 405impl TupleFieldList {
371 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 406 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
372 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } 407 pub fn fields(&self) -> AstChildren<TupleField> { support::children(&self.syntax) }
373 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 408 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
374} 409}
375#[derive(Debug, Clone, PartialEq, Eq, Hash)] 410#[derive(Debug, Clone, PartialEq, Eq, Hash)]
376pub struct RecordFieldDef { 411pub struct RecordField {
377 pub(crate) syntax: SyntaxNode, 412 pub(crate) syntax: SyntaxNode,
378} 413}
379impl ast::AttrsOwner for RecordFieldDef {} 414impl ast::AttrsOwner for RecordField {}
380impl ast::NameOwner for RecordFieldDef {} 415impl ast::NameOwner for RecordField {}
381impl ast::VisibilityOwner for RecordFieldDef {} 416impl ast::VisibilityOwner for RecordField {}
382impl ast::TypeAscriptionOwner for RecordFieldDef {} 417impl ast::TypeAscriptionOwner for RecordField {}
383impl RecordFieldDef { 418impl RecordField {
384 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 419 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
385} 420}
386#[derive(Debug, Clone, PartialEq, Eq, Hash)] 421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
387pub struct TupleFieldDef { 422pub struct TupleField {
388 pub(crate) syntax: SyntaxNode, 423 pub(crate) syntax: SyntaxNode,
389} 424}
390impl ast::AttrsOwner for TupleFieldDef {} 425impl ast::AttrsOwner for TupleField {}
391impl ast::NameOwner for TupleFieldDef {} 426impl ast::VisibilityOwner for TupleField {}
392impl ast::VisibilityOwner for TupleFieldDef {} 427impl TupleField {
393impl TupleFieldDef {
394 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 428 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
395} 429}
396#[derive(Debug, Clone, PartialEq, Eq, Hash)] 430#[derive(Debug, Clone, PartialEq, Eq, Hash)]
397pub struct EnumVariantList { 431pub struct VariantList {
398 pub(crate) syntax: SyntaxNode, 432 pub(crate) syntax: SyntaxNode,
399} 433}
400impl EnumVariantList { 434impl VariantList {
401 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 435 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
402 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 436 pub fn variants(&self) -> AstChildren<Variant> { support::children(&self.syntax) }
403 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 437 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
404} 438}
405#[derive(Debug, Clone, PartialEq, Eq, Hash)] 439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
406pub struct EnumVariant { 440pub struct Variant {
407 pub(crate) syntax: SyntaxNode, 441 pub(crate) syntax: SyntaxNode,
408} 442}
409impl ast::AttrsOwner for EnumVariant {} 443impl ast::AttrsOwner for Variant {}
410impl ast::NameOwner for EnumVariant {} 444impl ast::NameOwner for Variant {}
411impl ast::VisibilityOwner for EnumVariant {} 445impl ast::VisibilityOwner for Variant {}
412impl EnumVariant { 446impl Variant {
413 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 447 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
414 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 448 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
415 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 449 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
416} 450}
417#[derive(Debug, Clone, PartialEq, Eq, Hash)] 451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
418pub struct TypeBoundList {
419 pub(crate) syntax: SyntaxNode,
420}
421impl TypeBoundList {
422 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
423}
424#[derive(Debug, Clone, PartialEq, Eq, Hash)]
425pub struct AssocItemList { 452pub struct AssocItemList {
426 pub(crate) syntax: SyntaxNode, 453 pub(crate) syntax: SyntaxNode,
427} 454}
@@ -528,7 +555,7 @@ pub struct ForType {
528} 555}
529impl ForType { 556impl ForType {
530 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 557 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
531 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 558 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
532 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 559 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
533} 560}
534#[derive(Debug, Clone, PartialEq, Eq, Hash)] 561#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -880,30 +907,32 @@ impl MatchGuard {
880 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 907 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
881} 908}
882#[derive(Debug, Clone, PartialEq, Eq, Hash)] 909#[derive(Debug, Clone, PartialEq, Eq, Hash)]
883pub struct RecordLit { 910pub struct RecordExpr {
884 pub(crate) syntax: SyntaxNode, 911 pub(crate) syntax: SyntaxNode,
885} 912}
886impl RecordLit { 913impl RecordExpr {
887 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 914 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
888 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } 915 pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> {
916 support::child(&self.syntax)
917 }
889} 918}
890#[derive(Debug, Clone, PartialEq, Eq, Hash)] 919#[derive(Debug, Clone, PartialEq, Eq, Hash)]
891pub struct RecordFieldList { 920pub struct RecordExprFieldList {
892 pub(crate) syntax: SyntaxNode, 921 pub(crate) syntax: SyntaxNode,
893} 922}
894impl RecordFieldList { 923impl RecordExprFieldList {
895 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 924 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
896 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } 925 pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) }
897 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 926 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
898 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } 927 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
899 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 928 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
900} 929}
901#[derive(Debug, Clone, PartialEq, Eq, Hash)] 930#[derive(Debug, Clone, PartialEq, Eq, Hash)]
902pub struct RecordField { 931pub struct RecordExprField {
903 pub(crate) syntax: SyntaxNode, 932 pub(crate) syntax: SyntaxNode,
904} 933}
905impl ast::AttrsOwner for RecordField {} 934impl ast::AttrsOwner for RecordExprField {}
906impl RecordField { 935impl RecordExprField {
907 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 936 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
908 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 937 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
909 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 938 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -1143,7 +1172,7 @@ pub struct WherePred {
1143impl ast::TypeBoundsOwner for WherePred {} 1172impl ast::TypeBoundsOwner for WherePred {}
1144impl WherePred { 1173impl WherePred {
1145 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 1174 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
1146 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 1175 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
1147 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1176 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1148 support::token(&self.syntax, T![lifetime]) 1177 support::token(&self.syntax, T![lifetime])
1149 } 1178 }
@@ -1173,32 +1202,6 @@ impl LetStmt {
1173 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1202 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1174} 1203}
1175#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1204#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1176pub struct SelfParam {
1177 pub(crate) syntax: SyntaxNode,
1178}
1179impl ast::AttrsOwner for SelfParam {}
1180impl ast::TypeAscriptionOwner for SelfParam {}
1181impl SelfParam {
1182 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1183 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1184 support::token(&self.syntax, T![lifetime])
1185 }
1186 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1187 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1188 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1189}
1190#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1191pub struct Param {
1192 pub(crate) syntax: SyntaxNode,
1193}
1194impl ast::AttrsOwner for Param {}
1195impl ast::TypeAscriptionOwner for Param {}
1196impl Param {
1197 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1198 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1199 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
1200}
1201#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1202pub struct PathSegment { 1205pub struct PathSegment {
1203 pub(crate) syntax: SyntaxNode, 1206 pub(crate) syntax: SyntaxNode,
1204} 1207}
@@ -1270,19 +1273,19 @@ impl MetaItem {
1270} 1273}
1271#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1274#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1272pub enum Item { 1275pub enum Item {
1273 ConstDef(ConstDef), 1276 Const(Const),
1274 EnumDef(EnumDef), 1277 Enum(Enum),
1275 ExternBlock(ExternBlock), 1278 ExternBlock(ExternBlock),
1276 ExternCrate(ExternCrate), 1279 ExternCrate(ExternCrate),
1277 FnDef(FnDef), 1280 Fn(Fn),
1278 ImplDef(ImplDef), 1281 ImplDef(ImplDef),
1279 MacroCall(MacroCall), 1282 MacroCall(MacroCall),
1280 Module(Module), 1283 Module(Module),
1281 StaticDef(StaticDef), 1284 Static(Static),
1282 StructDef(StructDef), 1285 Struct(Struct),
1283 TraitDef(TraitDef), 1286 TraitDef(TraitDef),
1284 TypeAliasDef(TypeAliasDef), 1287 TypeAlias(TypeAlias),
1285 UnionDef(UnionDef), 1288 Union(Union),
1286 Use(Use), 1289 Use(Use),
1287} 1290}
1288impl ast::AttrsOwner for Item {} 1291impl ast::AttrsOwner for Item {}
@@ -1303,9 +1306,27 @@ pub enum TypeRef {
1303 DynTraitType(DynTraitType), 1306 DynTraitType(DynTraitType),
1304} 1307}
1305#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1306pub enum FieldDefList { 1309pub enum Pat {
1307 RecordFieldDefList(RecordFieldDefList), 1310 OrPat(OrPat),
1308 TupleFieldDefList(TupleFieldDefList), 1311 ParenPat(ParenPat),
1312 RefPat(RefPat),
1313 BoxPat(BoxPat),
1314 BindPat(BindPat),
1315 PlaceholderPat(PlaceholderPat),
1316 DotDotPat(DotDotPat),
1317 PathPat(PathPat),
1318 RecordPat(RecordPat),
1319 TupleStructPat(TupleStructPat),
1320 TuplePat(TuplePat),
1321 SlicePat(SlicePat),
1322 RangePat(RangePat),
1323 LiteralPat(LiteralPat),
1324 MacroPat(MacroPat),
1325}
1326#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1327pub enum FieldList {
1328 RecordFieldList(RecordFieldList),
1329 TupleFieldList(TupleFieldList),
1309} 1330}
1310#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1331#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1311pub enum Expr { 1332pub enum Expr {
@@ -1324,7 +1345,7 @@ pub enum Expr {
1324 BlockExpr(BlockExpr), 1345 BlockExpr(BlockExpr),
1325 ReturnExpr(ReturnExpr), 1346 ReturnExpr(ReturnExpr),
1326 MatchExpr(MatchExpr), 1347 MatchExpr(MatchExpr),
1327 RecordLit(RecordLit), 1348 RecordExpr(RecordExpr),
1328 CallExpr(CallExpr), 1349 CallExpr(CallExpr),
1329 IndexExpr(IndexExpr), 1350 IndexExpr(IndexExpr),
1330 MethodCallExpr(MethodCallExpr), 1351 MethodCallExpr(MethodCallExpr),
@@ -1343,32 +1364,14 @@ pub enum Expr {
1343} 1364}
1344#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1365#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1345pub enum AssocItem { 1366pub enum AssocItem {
1346 FnDef(FnDef), 1367 Fn(Fn),
1347 TypeAliasDef(TypeAliasDef), 1368 TypeAlias(TypeAlias),
1348 ConstDef(ConstDef), 1369 Const(Const),
1349 MacroCall(MacroCall), 1370 MacroCall(MacroCall),
1350} 1371}
1351impl ast::AttrsOwner for AssocItem {} 1372impl ast::AttrsOwner for AssocItem {}
1352impl ast::NameOwner for AssocItem {} 1373impl ast::NameOwner for AssocItem {}
1353#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1374#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1354pub enum Pat {
1355 OrPat(OrPat),
1356 ParenPat(ParenPat),
1357 RefPat(RefPat),
1358 BoxPat(BoxPat),
1359 BindPat(BindPat),
1360 PlaceholderPat(PlaceholderPat),
1361 DotDotPat(DotDotPat),
1362 PathPat(PathPat),
1363 RecordPat(RecordPat),
1364 TupleStructPat(TupleStructPat),
1365 TuplePat(TuplePat),
1366 SlicePat(SlicePat),
1367 RangePat(RangePat),
1368 LiteralPat(LiteralPat),
1369 MacroPat(MacroPat),
1370}
1371#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1372pub enum Stmt { 1375pub enum Stmt {
1373 LetStmt(LetStmt), 1376 LetStmt(LetStmt),
1374 ExprStmt(ExprStmt), 1377 ExprStmt(ExprStmt),
@@ -1381,21 +1384,21 @@ pub enum AttrInput {
1381} 1384}
1382#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1383pub enum ExternItem { 1386pub enum ExternItem {
1384 FnDef(FnDef), 1387 Fn(Fn),
1385 StaticDef(StaticDef), 1388 Static(Static),
1386} 1389}
1387impl ast::AttrsOwner for ExternItem {} 1390impl ast::AttrsOwner for ExternItem {}
1388impl ast::NameOwner for ExternItem {} 1391impl ast::NameOwner for ExternItem {}
1389impl ast::VisibilityOwner for ExternItem {} 1392impl ast::VisibilityOwner for ExternItem {}
1390#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1393#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1391pub enum AdtDef { 1394pub enum AdtDef {
1392 StructDef(StructDef), 1395 Struct(Struct),
1393 EnumDef(EnumDef), 1396 Enum(Enum),
1394 UnionDef(UnionDef), 1397 Union(Union),
1395} 1398}
1396impl ast::AttrsOwner for AdtDef {} 1399impl ast::AttrsOwner for AdtDef {}
1400impl ast::GenericParamsOwner for AdtDef {}
1397impl ast::NameOwner for AdtDef {} 1401impl ast::NameOwner for AdtDef {}
1398impl ast::TypeParamsOwner for AdtDef {}
1399impl ast::VisibilityOwner for AdtDef {} 1402impl ast::VisibilityOwner for AdtDef {}
1400impl AstNode for SourceFile { 1403impl AstNode for SourceFile {
1401 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1404 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
@@ -1419,8 +1422,8 @@ impl AstNode for Attr {
1419 } 1422 }
1420 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1423 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1421} 1424}
1422impl AstNode for ConstDef { 1425impl AstNode for Const {
1423 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } 1426 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST }
1424 fn cast(syntax: SyntaxNode) -> Option<Self> { 1427 fn cast(syntax: SyntaxNode) -> Option<Self> {
1425 if Self::can_cast(syntax.kind()) { 1428 if Self::can_cast(syntax.kind()) {
1426 Some(Self { syntax }) 1429 Some(Self { syntax })
@@ -1430,8 +1433,8 @@ impl AstNode for ConstDef {
1430 } 1433 }
1431 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1434 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1432} 1435}
1433impl AstNode for EnumDef { 1436impl AstNode for Enum {
1434 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } 1437 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM }
1435 fn cast(syntax: SyntaxNode) -> Option<Self> { 1438 fn cast(syntax: SyntaxNode) -> Option<Self> {
1436 if Self::can_cast(syntax.kind()) { 1439 if Self::can_cast(syntax.kind()) {
1437 Some(Self { syntax }) 1440 Some(Self { syntax })
@@ -1463,8 +1466,8 @@ impl AstNode for ExternCrate {
1463 } 1466 }
1464 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1467 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1465} 1468}
1466impl AstNode for FnDef { 1469impl AstNode for Fn {
1467 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } 1470 fn can_cast(kind: SyntaxKind) -> bool { kind == FN }
1468 fn cast(syntax: SyntaxNode) -> Option<Self> { 1471 fn cast(syntax: SyntaxNode) -> Option<Self> {
1469 if Self::can_cast(syntax.kind()) { 1472 if Self::can_cast(syntax.kind()) {
1470 Some(Self { syntax }) 1473 Some(Self { syntax })
@@ -1507,8 +1510,8 @@ impl AstNode for Module {
1507 } 1510 }
1508 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1511 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1509} 1512}
1510impl AstNode for StaticDef { 1513impl AstNode for Static {
1511 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } 1514 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC }
1512 fn cast(syntax: SyntaxNode) -> Option<Self> { 1515 fn cast(syntax: SyntaxNode) -> Option<Self> {
1513 if Self::can_cast(syntax.kind()) { 1516 if Self::can_cast(syntax.kind()) {
1514 Some(Self { syntax }) 1517 Some(Self { syntax })
@@ -1518,8 +1521,8 @@ impl AstNode for StaticDef {
1518 } 1521 }
1519 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1522 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1520} 1523}
1521impl AstNode for StructDef { 1524impl AstNode for Struct {
1522 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } 1525 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT }
1523 fn cast(syntax: SyntaxNode) -> Option<Self> { 1526 fn cast(syntax: SyntaxNode) -> Option<Self> {
1524 if Self::can_cast(syntax.kind()) { 1527 if Self::can_cast(syntax.kind()) {
1525 Some(Self { syntax }) 1528 Some(Self { syntax })
@@ -1540,8 +1543,8 @@ impl AstNode for TraitDef {
1540 } 1543 }
1541 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1544 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1542} 1545}
1543impl AstNode for TypeAliasDef { 1546impl AstNode for TypeAlias {
1544 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } 1547 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS }
1545 fn cast(syntax: SyntaxNode) -> Option<Self> { 1548 fn cast(syntax: SyntaxNode) -> Option<Self> {
1546 if Self::can_cast(syntax.kind()) { 1549 if Self::can_cast(syntax.kind()) {
1547 Some(Self { syntax }) 1550 Some(Self { syntax })
@@ -1551,8 +1554,8 @@ impl AstNode for TypeAliasDef {
1551 } 1554 }
1552 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1555 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1553} 1556}
1554impl AstNode for UnionDef { 1557impl AstNode for Union {
1555 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } 1558 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION }
1556 fn cast(syntax: SyntaxNode) -> Option<Self> { 1559 fn cast(syntax: SyntaxNode) -> Option<Self> {
1557 if Self::can_cast(syntax.kind()) { 1560 if Self::can_cast(syntax.kind()) {
1558 Some(Self { syntax }) 1561 Some(Self { syntax })
@@ -1672,8 +1675,8 @@ impl AstNode for Abi {
1672 } 1675 }
1673 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1676 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1674} 1677}
1675impl AstNode for TypeParamList { 1678impl AstNode for GenericParamList {
1676 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } 1679 fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST }
1677 fn cast(syntax: SyntaxNode) -> Option<Self> { 1680 fn cast(syntax: SyntaxNode) -> Option<Self> {
1678 if Self::can_cast(syntax.kind()) { 1681 if Self::can_cast(syntax.kind()) {
1679 Some(Self { syntax }) 1682 Some(Self { syntax })
@@ -1727,8 +1730,8 @@ impl AstNode for BlockExpr {
1727 } 1730 }
1728 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1731 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1729} 1732}
1730impl AstNode for RecordFieldDefList { 1733impl AstNode for Param {
1731 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } 1734 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
1732 fn cast(syntax: SyntaxNode) -> Option<Self> { 1735 fn cast(syntax: SyntaxNode) -> Option<Self> {
1733 if Self::can_cast(syntax.kind()) { 1736 if Self::can_cast(syntax.kind()) {
1734 Some(Self { syntax }) 1737 Some(Self { syntax })
@@ -1738,8 +1741,8 @@ impl AstNode for RecordFieldDefList {
1738 } 1741 }
1739 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1742 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1740} 1743}
1741impl AstNode for TupleFieldDefList { 1744impl AstNode for SelfParam {
1742 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } 1745 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
1743 fn cast(syntax: SyntaxNode) -> Option<Self> { 1746 fn cast(syntax: SyntaxNode) -> Option<Self> {
1744 if Self::can_cast(syntax.kind()) { 1747 if Self::can_cast(syntax.kind()) {
1745 Some(Self { syntax }) 1748 Some(Self { syntax })
@@ -1749,8 +1752,8 @@ impl AstNode for TupleFieldDefList {
1749 } 1752 }
1750 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1751} 1754}
1752impl AstNode for RecordFieldDef { 1755impl AstNode for TypeBoundList {
1753 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } 1756 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
1754 fn cast(syntax: SyntaxNode) -> Option<Self> { 1757 fn cast(syntax: SyntaxNode) -> Option<Self> {
1755 if Self::can_cast(syntax.kind()) { 1758 if Self::can_cast(syntax.kind()) {
1756 Some(Self { syntax }) 1759 Some(Self { syntax })
@@ -1760,8 +1763,8 @@ impl AstNode for RecordFieldDef {
1760 } 1763 }
1761 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1764 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1762} 1765}
1763impl AstNode for TupleFieldDef { 1766impl AstNode for RecordFieldList {
1764 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } 1767 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
1765 fn cast(syntax: SyntaxNode) -> Option<Self> { 1768 fn cast(syntax: SyntaxNode) -> Option<Self> {
1766 if Self::can_cast(syntax.kind()) { 1769 if Self::can_cast(syntax.kind()) {
1767 Some(Self { syntax }) 1770 Some(Self { syntax })
@@ -1771,8 +1774,8 @@ impl AstNode for TupleFieldDef {
1771 } 1774 }
1772 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1775 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1773} 1776}
1774impl AstNode for EnumVariantList { 1777impl AstNode for TupleFieldList {
1775 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } 1778 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_LIST }
1776 fn cast(syntax: SyntaxNode) -> Option<Self> { 1779 fn cast(syntax: SyntaxNode) -> Option<Self> {
1777 if Self::can_cast(syntax.kind()) { 1780 if Self::can_cast(syntax.kind()) {
1778 Some(Self { syntax }) 1781 Some(Self { syntax })
@@ -1782,8 +1785,8 @@ impl AstNode for EnumVariantList {
1782 } 1785 }
1783 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1786 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1784} 1787}
1785impl AstNode for EnumVariant { 1788impl AstNode for RecordField {
1786 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } 1789 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
1787 fn cast(syntax: SyntaxNode) -> Option<Self> { 1790 fn cast(syntax: SyntaxNode) -> Option<Self> {
1788 if Self::can_cast(syntax.kind()) { 1791 if Self::can_cast(syntax.kind()) {
1789 Some(Self { syntax }) 1792 Some(Self { syntax })
@@ -1793,8 +1796,30 @@ impl AstNode for EnumVariant {
1793 } 1796 }
1794 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1797 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1795} 1798}
1796impl AstNode for TypeBoundList { 1799impl AstNode for TupleField {
1797 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } 1800 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD }
1801 fn cast(syntax: SyntaxNode) -> Option<Self> {
1802 if Self::can_cast(syntax.kind()) {
1803 Some(Self { syntax })
1804 } else {
1805 None
1806 }
1807 }
1808 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1809}
1810impl AstNode for VariantList {
1811 fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT_LIST }
1812 fn cast(syntax: SyntaxNode) -> Option<Self> {
1813 if Self::can_cast(syntax.kind()) {
1814 Some(Self { syntax })
1815 } else {
1816 None
1817 }
1818 }
1819 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1820}
1821impl AstNode for Variant {
1822 fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT }
1798 fn cast(syntax: SyntaxNode) -> Option<Self> { 1823 fn cast(syntax: SyntaxNode) -> Option<Self> {
1799 if Self::can_cast(syntax.kind()) { 1824 if Self::can_cast(syntax.kind()) {
1800 Some(Self { syntax }) 1825 Some(Self { syntax })
@@ -2332,8 +2357,8 @@ impl AstNode for MatchGuard {
2332 } 2357 }
2333 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2358 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2334} 2359}
2335impl AstNode for RecordLit { 2360impl AstNode for RecordExpr {
2336 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } 2361 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR }
2337 fn cast(syntax: SyntaxNode) -> Option<Self> { 2362 fn cast(syntax: SyntaxNode) -> Option<Self> {
2338 if Self::can_cast(syntax.kind()) { 2363 if Self::can_cast(syntax.kind()) {
2339 Some(Self { syntax }) 2364 Some(Self { syntax })
@@ -2343,8 +2368,8 @@ impl AstNode for RecordLit {
2343 } 2368 }
2344 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2369 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2345} 2370}
2346impl AstNode for RecordFieldList { 2371impl AstNode for RecordExprFieldList {
2347 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } 2372 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST }
2348 fn cast(syntax: SyntaxNode) -> Option<Self> { 2373 fn cast(syntax: SyntaxNode) -> Option<Self> {
2349 if Self::can_cast(syntax.kind()) { 2374 if Self::can_cast(syntax.kind()) {
2350 Some(Self { syntax }) 2375 Some(Self { syntax })
@@ -2354,8 +2379,8 @@ impl AstNode for RecordFieldList {
2354 } 2379 }
2355 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2380 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2356} 2381}
2357impl AstNode for RecordField { 2382impl AstNode for RecordExprField {
2358 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } 2383 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD }
2359 fn cast(syntax: SyntaxNode) -> Option<Self> { 2384 fn cast(syntax: SyntaxNode) -> Option<Self> {
2360 if Self::can_cast(syntax.kind()) { 2385 if Self::can_cast(syntax.kind()) {
2361 Some(Self { syntax }) 2386 Some(Self { syntax })
@@ -2673,28 +2698,6 @@ impl AstNode for LetStmt {
2673 } 2698 }
2674 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2699 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2675} 2700}
2676impl AstNode for SelfParam {
2677 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
2678 fn cast(syntax: SyntaxNode) -> Option<Self> {
2679 if Self::can_cast(syntax.kind()) {
2680 Some(Self { syntax })
2681 } else {
2682 None
2683 }
2684 }
2685 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2686}
2687impl AstNode for Param {
2688 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
2689 fn cast(syntax: SyntaxNode) -> Option<Self> {
2690 if Self::can_cast(syntax.kind()) {
2691 Some(Self { syntax })
2692 } else {
2693 None
2694 }
2695 }
2696 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2697}
2698impl AstNode for PathSegment { 2701impl AstNode for PathSegment {
2699 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } 2702 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
2700 fn cast(syntax: SyntaxNode) -> Option<Self> { 2703 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2772,11 +2775,11 @@ impl AstNode for MetaItem {
2772 } 2775 }
2773 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2776 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2774} 2777}
2775impl From<ConstDef> for Item { 2778impl From<Const> for Item {
2776 fn from(node: ConstDef) -> Item { Item::ConstDef(node) } 2779 fn from(node: Const) -> Item { Item::Const(node) }
2777} 2780}
2778impl From<EnumDef> for Item { 2781impl From<Enum> for Item {
2779 fn from(node: EnumDef) -> Item { Item::EnumDef(node) } 2782 fn from(node: Enum) -> Item { Item::Enum(node) }
2780} 2783}
2781impl From<ExternBlock> for Item { 2784impl From<ExternBlock> for Item {
2782 fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } 2785 fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) }
@@ -2784,8 +2787,8 @@ impl From<ExternBlock> for Item {
2784impl From<ExternCrate> for Item { 2787impl From<ExternCrate> for Item {
2785 fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } 2788 fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) }
2786} 2789}
2787impl From<FnDef> for Item { 2790impl From<Fn> for Item {
2788 fn from(node: FnDef) -> Item { Item::FnDef(node) } 2791 fn from(node: Fn) -> Item { Item::Fn(node) }
2789} 2792}
2790impl From<ImplDef> for Item { 2793impl From<ImplDef> for Item {
2791 fn from(node: ImplDef) -> Item { Item::ImplDef(node) } 2794 fn from(node: ImplDef) -> Item { Item::ImplDef(node) }
@@ -2796,20 +2799,20 @@ impl From<MacroCall> for Item {
2796impl From<Module> for Item { 2799impl From<Module> for Item {
2797 fn from(node: Module) -> Item { Item::Module(node) } 2800 fn from(node: Module) -> Item { Item::Module(node) }
2798} 2801}
2799impl From<StaticDef> for Item { 2802impl From<Static> for Item {
2800 fn from(node: StaticDef) -> Item { Item::StaticDef(node) } 2803 fn from(node: Static) -> Item { Item::Static(node) }
2801} 2804}
2802impl From<StructDef> for Item { 2805impl From<Struct> for Item {
2803 fn from(node: StructDef) -> Item { Item::StructDef(node) } 2806 fn from(node: Struct) -> Item { Item::Struct(node) }
2804} 2807}
2805impl From<TraitDef> for Item { 2808impl From<TraitDef> for Item {
2806 fn from(node: TraitDef) -> Item { Item::TraitDef(node) } 2809 fn from(node: TraitDef) -> Item { Item::TraitDef(node) }
2807} 2810}
2808impl From<TypeAliasDef> for Item { 2811impl From<TypeAlias> for Item {
2809 fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) } 2812 fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) }
2810} 2813}
2811impl From<UnionDef> for Item { 2814impl From<Union> for Item {
2812 fn from(node: UnionDef) -> Item { Item::UnionDef(node) } 2815 fn from(node: Union) -> Item { Item::Union(node) }
2813} 2816}
2814impl From<Use> for Item { 2817impl From<Use> for Item {
2815 fn from(node: Use) -> Item { Item::Use(node) } 2818 fn from(node: Use) -> Item { Item::Use(node) }
@@ -2817,28 +2820,26 @@ impl From<Use> for Item {
2817impl AstNode for Item { 2820impl AstNode for Item {
2818 fn can_cast(kind: SyntaxKind) -> bool { 2821 fn can_cast(kind: SyntaxKind) -> bool {
2819 match kind { 2822 match kind {
2820 CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL 2823 CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE
2821 | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { 2824 | STATIC | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true,
2822 true
2823 }
2824 _ => false, 2825 _ => false,
2825 } 2826 }
2826 } 2827 }
2827 fn cast(syntax: SyntaxNode) -> Option<Self> { 2828 fn cast(syntax: SyntaxNode) -> Option<Self> {
2828 let res = match syntax.kind() { 2829 let res = match syntax.kind() {
2829 CONST_DEF => Item::ConstDef(ConstDef { syntax }), 2830 CONST => Item::Const(Const { syntax }),
2830 ENUM_DEF => Item::EnumDef(EnumDef { syntax }), 2831 ENUM => Item::Enum(Enum { syntax }),
2831 EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), 2832 EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
2832 EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), 2833 EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
2833 FN_DEF => Item::FnDef(FnDef { syntax }), 2834 FN => Item::Fn(Fn { syntax }),
2834 IMPL_DEF => Item::ImplDef(ImplDef { syntax }), 2835 IMPL_DEF => Item::ImplDef(ImplDef { syntax }),
2835 MACRO_CALL => Item::MacroCall(MacroCall { syntax }), 2836 MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
2836 MODULE => Item::Module(Module { syntax }), 2837 MODULE => Item::Module(Module { syntax }),
2837 STATIC_DEF => Item::StaticDef(StaticDef { syntax }), 2838 STATIC => Item::Static(Static { syntax }),
2838 STRUCT_DEF => Item::StructDef(StructDef { syntax }), 2839 STRUCT => Item::Struct(Struct { syntax }),
2839 TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), 2840 TRAIT_DEF => Item::TraitDef(TraitDef { syntax }),
2840 TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), 2841 TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }),
2841 UNION_DEF => Item::UnionDef(UnionDef { syntax }), 2842 UNION => Item::Union(Union { syntax }),
2842 USE => Item::Use(Use { syntax }), 2843 USE => Item::Use(Use { syntax }),
2843 _ => return None, 2844 _ => return None,
2844 }; 2845 };
@@ -2846,19 +2847,19 @@ impl AstNode for Item {
2846 } 2847 }
2847 fn syntax(&self) -> &SyntaxNode { 2848 fn syntax(&self) -> &SyntaxNode {
2848 match self { 2849 match self {
2849 Item::ConstDef(it) => &it.syntax, 2850 Item::Const(it) => &it.syntax,
2850 Item::EnumDef(it) => &it.syntax, 2851 Item::Enum(it) => &it.syntax,
2851 Item::ExternBlock(it) => &it.syntax, 2852 Item::ExternBlock(it) => &it.syntax,
2852 Item::ExternCrate(it) => &it.syntax, 2853 Item::ExternCrate(it) => &it.syntax,
2853 Item::FnDef(it) => &it.syntax, 2854 Item::Fn(it) => &it.syntax,
2854 Item::ImplDef(it) => &it.syntax, 2855 Item::ImplDef(it) => &it.syntax,
2855 Item::MacroCall(it) => &it.syntax, 2856 Item::MacroCall(it) => &it.syntax,
2856 Item::Module(it) => &it.syntax, 2857 Item::Module(it) => &it.syntax,
2857 Item::StaticDef(it) => &it.syntax, 2858 Item::Static(it) => &it.syntax,
2858 Item::StructDef(it) => &it.syntax, 2859 Item::Struct(it) => &it.syntax,
2859 Item::TraitDef(it) => &it.syntax, 2860 Item::TraitDef(it) => &it.syntax,
2860 Item::TypeAliasDef(it) => &it.syntax, 2861 Item::TypeAlias(it) => &it.syntax,
2861 Item::UnionDef(it) => &it.syntax, 2862 Item::Union(it) => &it.syntax,
2862 Item::Use(it) => &it.syntax, 2863 Item::Use(it) => &it.syntax,
2863 } 2864 }
2864 } 2865 }
@@ -2948,33 +2949,126 @@ impl AstNode for TypeRef {
2948 } 2949 }
2949 } 2950 }
2950} 2951}
2951impl From<RecordFieldDefList> for FieldDefList { 2952impl From<OrPat> for Pat {
2952 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } 2953 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
2954}
2955impl From<ParenPat> for Pat {
2956 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
2957}
2958impl From<RefPat> for Pat {
2959 fn from(node: RefPat) -> Pat { Pat::RefPat(node) }
2960}
2961impl From<BoxPat> for Pat {
2962 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
2963}
2964impl From<BindPat> for Pat {
2965 fn from(node: BindPat) -> Pat { Pat::BindPat(node) }
2966}
2967impl From<PlaceholderPat> for Pat {
2968 fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) }
2969}
2970impl From<DotDotPat> for Pat {
2971 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) }
2972}
2973impl From<PathPat> for Pat {
2974 fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
2975}
2976impl From<RecordPat> for Pat {
2977 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
2978}
2979impl From<TupleStructPat> for Pat {
2980 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
2981}
2982impl From<TuplePat> for Pat {
2983 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
2984}
2985impl From<SlicePat> for Pat {
2986 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
2987}
2988impl From<RangePat> for Pat {
2989 fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
2990}
2991impl From<LiteralPat> for Pat {
2992 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
2993}
2994impl From<MacroPat> for Pat {
2995 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
2996}
2997impl AstNode for Pat {
2998 fn can_cast(kind: SyntaxKind) -> bool {
2999 match kind {
3000 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
3001 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
3002 | LITERAL_PAT | MACRO_PAT => true,
3003 _ => false,
3004 }
3005 }
3006 fn cast(syntax: SyntaxNode) -> Option<Self> {
3007 let res = match syntax.kind() {
3008 OR_PAT => Pat::OrPat(OrPat { syntax }),
3009 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
3010 REF_PAT => Pat::RefPat(RefPat { syntax }),
3011 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3012 BIND_PAT => Pat::BindPat(BindPat { syntax }),
3013 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
3014 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
3015 PATH_PAT => Pat::PathPat(PathPat { syntax }),
3016 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
3017 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
3018 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
3019 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
3020 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
3021 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
3022 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
3023 _ => return None,
3024 };
3025 Some(res)
3026 }
3027 fn syntax(&self) -> &SyntaxNode {
3028 match self {
3029 Pat::OrPat(it) => &it.syntax,
3030 Pat::ParenPat(it) => &it.syntax,
3031 Pat::RefPat(it) => &it.syntax,
3032 Pat::BoxPat(it) => &it.syntax,
3033 Pat::BindPat(it) => &it.syntax,
3034 Pat::PlaceholderPat(it) => &it.syntax,
3035 Pat::DotDotPat(it) => &it.syntax,
3036 Pat::PathPat(it) => &it.syntax,
3037 Pat::RecordPat(it) => &it.syntax,
3038 Pat::TupleStructPat(it) => &it.syntax,
3039 Pat::TuplePat(it) => &it.syntax,
3040 Pat::SlicePat(it) => &it.syntax,
3041 Pat::RangePat(it) => &it.syntax,
3042 Pat::LiteralPat(it) => &it.syntax,
3043 Pat::MacroPat(it) => &it.syntax,
3044 }
3045 }
3046}
3047impl From<RecordFieldList> for FieldList {
3048 fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) }
2953} 3049}
2954impl From<TupleFieldDefList> for FieldDefList { 3050impl From<TupleFieldList> for FieldList {
2955 fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) } 3051 fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) }
2956} 3052}
2957impl AstNode for FieldDefList { 3053impl AstNode for FieldList {
2958 fn can_cast(kind: SyntaxKind) -> bool { 3054 fn can_cast(kind: SyntaxKind) -> bool {
2959 match kind { 3055 match kind {
2960 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true, 3056 RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true,
2961 _ => false, 3057 _ => false,
2962 } 3058 }
2963 } 3059 }
2964 fn cast(syntax: SyntaxNode) -> Option<Self> { 3060 fn cast(syntax: SyntaxNode) -> Option<Self> {
2965 let res = match syntax.kind() { 3061 let res = match syntax.kind() {
2966 RECORD_FIELD_DEF_LIST => { 3062 RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }),
2967 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax }) 3063 TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }),
2968 }
2969 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
2970 _ => return None, 3064 _ => return None,
2971 }; 3065 };
2972 Some(res) 3066 Some(res)
2973 } 3067 }
2974 fn syntax(&self) -> &SyntaxNode { 3068 fn syntax(&self) -> &SyntaxNode {
2975 match self { 3069 match self {
2976 FieldDefList::RecordFieldDefList(it) => &it.syntax, 3070 FieldList::RecordFieldList(it) => &it.syntax,
2977 FieldDefList::TupleFieldDefList(it) => &it.syntax, 3071 FieldList::TupleFieldList(it) => &it.syntax,
2978 } 3072 }
2979 } 3073 }
2980} 3074}
@@ -3023,8 +3117,8 @@ impl From<ReturnExpr> for Expr {
3023impl From<MatchExpr> for Expr { 3117impl From<MatchExpr> for Expr {
3024 fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } 3118 fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) }
3025} 3119}
3026impl From<RecordLit> for Expr { 3120impl From<RecordExpr> for Expr {
3027 fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) } 3121 fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) }
3028} 3122}
3029impl From<CallExpr> for Expr { 3123impl From<CallExpr> for Expr {
3030 fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } 3124 fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
@@ -3076,7 +3170,7 @@ impl AstNode for Expr {
3076 match kind { 3170 match kind {
3077 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR 3171 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
3078 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL 3172 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
3079 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR 3173 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_EXPR | CALL_EXPR | INDEX_EXPR
3080 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR 3174 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR
3081 | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { 3175 | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => {
3082 true 3176 true
@@ -3101,7 +3195,7 @@ impl AstNode for Expr {
3101 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), 3195 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
3102 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), 3196 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
3103 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), 3197 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
3104 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), 3198 RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }),
3105 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), 3199 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
3106 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), 3200 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
3107 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), 3201 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
@@ -3138,7 +3232,7 @@ impl AstNode for Expr {
3138 Expr::BlockExpr(it) => &it.syntax, 3232 Expr::BlockExpr(it) => &it.syntax,
3139 Expr::ReturnExpr(it) => &it.syntax, 3233 Expr::ReturnExpr(it) => &it.syntax,
3140 Expr::MatchExpr(it) => &it.syntax, 3234 Expr::MatchExpr(it) => &it.syntax,
3141 Expr::RecordLit(it) => &it.syntax, 3235 Expr::RecordExpr(it) => &it.syntax,
3142 Expr::CallExpr(it) => &it.syntax, 3236 Expr::CallExpr(it) => &it.syntax,
3143 Expr::IndexExpr(it) => &it.syntax, 3237 Expr::IndexExpr(it) => &it.syntax,
3144 Expr::MethodCallExpr(it) => &it.syntax, 3238 Expr::MethodCallExpr(it) => &it.syntax,
@@ -3157,14 +3251,14 @@ impl AstNode for Expr {
3157 } 3251 }
3158 } 3252 }
3159} 3253}
3160impl From<FnDef> for AssocItem { 3254impl From<Fn> for AssocItem {
3161 fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) } 3255 fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) }
3162} 3256}
3163impl From<TypeAliasDef> for AssocItem { 3257impl From<TypeAlias> for AssocItem {
3164 fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } 3258 fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) }
3165} 3259}
3166impl From<ConstDef> for AssocItem { 3260impl From<Const> for AssocItem {
3167 fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } 3261 fn from(node: Const) -> AssocItem { AssocItem::Const(node) }
3168} 3262}
3169impl From<MacroCall> for AssocItem { 3263impl From<MacroCall> for AssocItem {
3170 fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) } 3264 fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) }
@@ -3172,15 +3266,15 @@ impl From<MacroCall> for AssocItem {
3172impl AstNode for AssocItem { 3266impl AstNode for AssocItem {
3173 fn can_cast(kind: SyntaxKind) -> bool { 3267 fn can_cast(kind: SyntaxKind) -> bool {
3174 match kind { 3268 match kind {
3175 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, 3269 FN | TYPE_ALIAS | CONST | MACRO_CALL => true,
3176 _ => false, 3270 _ => false,
3177 } 3271 }
3178 } 3272 }
3179 fn cast(syntax: SyntaxNode) -> Option<Self> { 3273 fn cast(syntax: SyntaxNode) -> Option<Self> {
3180 let res = match syntax.kind() { 3274 let res = match syntax.kind() {
3181 FN_DEF => AssocItem::FnDef(FnDef { syntax }), 3275 FN => AssocItem::Fn(Fn { syntax }),
3182 TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), 3276 TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }),
3183 CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), 3277 CONST => AssocItem::Const(Const { syntax }),
3184 MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), 3278 MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }),
3185 _ => return None, 3279 _ => return None,
3186 }; 3280 };
@@ -3188,108 +3282,13 @@ impl AstNode for AssocItem {
3188 } 3282 }
3189 fn syntax(&self) -> &SyntaxNode { 3283 fn syntax(&self) -> &SyntaxNode {
3190 match self { 3284 match self {
3191 AssocItem::FnDef(it) => &it.syntax, 3285 AssocItem::Fn(it) => &it.syntax,
3192 AssocItem::TypeAliasDef(it) => &it.syntax, 3286 AssocItem::TypeAlias(it) => &it.syntax,
3193 AssocItem::ConstDef(it) => &it.syntax, 3287 AssocItem::Const(it) => &it.syntax,
3194 AssocItem::MacroCall(it) => &it.syntax, 3288 AssocItem::MacroCall(it) => &it.syntax,
3195 } 3289 }
3196 } 3290 }
3197} 3291}
3198impl From<OrPat> for Pat {
3199 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
3200}
3201impl From<ParenPat> for Pat {
3202 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
3203}
3204impl From<RefPat> for Pat {
3205 fn from(node: RefPat) -> Pat { Pat::RefPat(node) }
3206}
3207impl From<BoxPat> for Pat {
3208 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
3209}
3210impl From<BindPat> for Pat {
3211 fn from(node: BindPat) -> Pat { Pat::BindPat(node) }
3212}
3213impl From<PlaceholderPat> for Pat {
3214 fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) }
3215}
3216impl From<DotDotPat> for Pat {
3217 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) }
3218}
3219impl From<PathPat> for Pat {
3220 fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
3221}
3222impl From<RecordPat> for Pat {
3223 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
3224}
3225impl From<TupleStructPat> for Pat {
3226 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
3227}
3228impl From<TuplePat> for Pat {
3229 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
3230}
3231impl From<SlicePat> for Pat {
3232 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
3233}
3234impl From<RangePat> for Pat {
3235 fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
3236}
3237impl From<LiteralPat> for Pat {
3238 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
3239}
3240impl From<MacroPat> for Pat {
3241 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
3242}
3243impl AstNode for Pat {
3244 fn can_cast(kind: SyntaxKind) -> bool {
3245 match kind {
3246 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
3247 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
3248 | LITERAL_PAT | MACRO_PAT => true,
3249 _ => false,
3250 }
3251 }
3252 fn cast(syntax: SyntaxNode) -> Option<Self> {
3253 let res = match syntax.kind() {
3254 OR_PAT => Pat::OrPat(OrPat { syntax }),
3255 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
3256 REF_PAT => Pat::RefPat(RefPat { syntax }),
3257 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3258 BIND_PAT => Pat::BindPat(BindPat { syntax }),
3259 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
3260 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
3261 PATH_PAT => Pat::PathPat(PathPat { syntax }),
3262 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
3263 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
3264 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
3265 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
3266 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
3267 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
3268 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
3269 _ => return None,
3270 };
3271 Some(res)
3272 }
3273 fn syntax(&self) -> &SyntaxNode {
3274 match self {
3275 Pat::OrPat(it) => &it.syntax,
3276 Pat::ParenPat(it) => &it.syntax,
3277 Pat::RefPat(it) => &it.syntax,
3278 Pat::BoxPat(it) => &it.syntax,
3279 Pat::BindPat(it) => &it.syntax,
3280 Pat::PlaceholderPat(it) => &it.syntax,
3281 Pat::DotDotPat(it) => &it.syntax,
3282 Pat::PathPat(it) => &it.syntax,
3283 Pat::RecordPat(it) => &it.syntax,
3284 Pat::TupleStructPat(it) => &it.syntax,
3285 Pat::TuplePat(it) => &it.syntax,
3286 Pat::SlicePat(it) => &it.syntax,
3287 Pat::RangePat(it) => &it.syntax,
3288 Pat::LiteralPat(it) => &it.syntax,
3289 Pat::MacroPat(it) => &it.syntax,
3290 }
3291 }
3292}
3293impl From<LetStmt> for Stmt { 3292impl From<LetStmt> for Stmt {
3294 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } 3293 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3295} 3294}
@@ -3346,64 +3345,64 @@ impl AstNode for AttrInput {
3346 } 3345 }
3347 } 3346 }
3348} 3347}
3349impl From<FnDef> for ExternItem { 3348impl From<Fn> for ExternItem {
3350 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } 3349 fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) }
3351} 3350}
3352impl From<StaticDef> for ExternItem { 3351impl From<Static> for ExternItem {
3353 fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } 3352 fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
3354} 3353}
3355impl AstNode for ExternItem { 3354impl AstNode for ExternItem {
3356 fn can_cast(kind: SyntaxKind) -> bool { 3355 fn can_cast(kind: SyntaxKind) -> bool {
3357 match kind { 3356 match kind {
3358 FN_DEF | STATIC_DEF => true, 3357 FN | STATIC => true,
3359 _ => false, 3358 _ => false,
3360 } 3359 }
3361 } 3360 }
3362 fn cast(syntax: SyntaxNode) -> Option<Self> { 3361 fn cast(syntax: SyntaxNode) -> Option<Self> {
3363 let res = match syntax.kind() { 3362 let res = match syntax.kind() {
3364 FN_DEF => ExternItem::FnDef(FnDef { syntax }), 3363 FN => ExternItem::Fn(Fn { syntax }),
3365 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), 3364 STATIC => ExternItem::Static(Static { syntax }),
3366 _ => return None, 3365 _ => return None,
3367 }; 3366 };
3368 Some(res) 3367 Some(res)
3369 } 3368 }
3370 fn syntax(&self) -> &SyntaxNode { 3369 fn syntax(&self) -> &SyntaxNode {
3371 match self { 3370 match self {
3372 ExternItem::FnDef(it) => &it.syntax, 3371 ExternItem::Fn(it) => &it.syntax,
3373 ExternItem::StaticDef(it) => &it.syntax, 3372 ExternItem::Static(it) => &it.syntax,
3374 } 3373 }
3375 } 3374 }
3376} 3375}
3377impl From<StructDef> for AdtDef { 3376impl From<Struct> for AdtDef {
3378 fn from(node: StructDef) -> AdtDef { AdtDef::StructDef(node) } 3377 fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) }
3379} 3378}
3380impl From<EnumDef> for AdtDef { 3379impl From<Enum> for AdtDef {
3381 fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } 3380 fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) }
3382} 3381}
3383impl From<UnionDef> for AdtDef { 3382impl From<Union> for AdtDef {
3384 fn from(node: UnionDef) -> AdtDef { AdtDef::UnionDef(node) } 3383 fn from(node: Union) -> AdtDef { AdtDef::Union(node) }
3385} 3384}
3386impl AstNode for AdtDef { 3385impl AstNode for AdtDef {
3387 fn can_cast(kind: SyntaxKind) -> bool { 3386 fn can_cast(kind: SyntaxKind) -> bool {
3388 match kind { 3387 match kind {
3389 STRUCT_DEF | ENUM_DEF | UNION_DEF => true, 3388 STRUCT | ENUM | UNION => true,
3390 _ => false, 3389 _ => false,
3391 } 3390 }
3392 } 3391 }
3393 fn cast(syntax: SyntaxNode) -> Option<Self> { 3392 fn cast(syntax: SyntaxNode) -> Option<Self> {
3394 let res = match syntax.kind() { 3393 let res = match syntax.kind() {
3395 STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }), 3394 STRUCT => AdtDef::Struct(Struct { syntax }),
3396 ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), 3395 ENUM => AdtDef::Enum(Enum { syntax }),
3397 UNION_DEF => AdtDef::UnionDef(UnionDef { syntax }), 3396 UNION => AdtDef::Union(Union { syntax }),
3398 _ => return None, 3397 _ => return None,
3399 }; 3398 };
3400 Some(res) 3399 Some(res)
3401 } 3400 }
3402 fn syntax(&self) -> &SyntaxNode { 3401 fn syntax(&self) -> &SyntaxNode {
3403 match self { 3402 match self {
3404 AdtDef::StructDef(it) => &it.syntax, 3403 AdtDef::Struct(it) => &it.syntax,
3405 AdtDef::EnumDef(it) => &it.syntax, 3404 AdtDef::Enum(it) => &it.syntax,
3406 AdtDef::UnionDef(it) => &it.syntax, 3405 AdtDef::Union(it) => &it.syntax,
3407 } 3406 }
3408 } 3407 }
3409} 3408}
@@ -3417,22 +3416,22 @@ impl std::fmt::Display for TypeRef {
3417 std::fmt::Display::fmt(self.syntax(), f) 3416 std::fmt::Display::fmt(self.syntax(), f)
3418 } 3417 }
3419} 3418}
3420impl std::fmt::Display for FieldDefList { 3419impl std::fmt::Display for Pat {
3421 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3420 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3422 std::fmt::Display::fmt(self.syntax(), f) 3421 std::fmt::Display::fmt(self.syntax(), f)
3423 } 3422 }
3424} 3423}
3425impl std::fmt::Display for Expr { 3424impl std::fmt::Display for FieldList {
3426 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3425 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3427 std::fmt::Display::fmt(self.syntax(), f) 3426 std::fmt::Display::fmt(self.syntax(), f)
3428 } 3427 }
3429} 3428}
3430impl std::fmt::Display for AssocItem { 3429impl std::fmt::Display for Expr {
3431 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3430 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3432 std::fmt::Display::fmt(self.syntax(), f) 3431 std::fmt::Display::fmt(self.syntax(), f)
3433 } 3432 }
3434} 3433}
3435impl std::fmt::Display for Pat { 3434impl std::fmt::Display for AssocItem {
3436 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3435 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3437 std::fmt::Display::fmt(self.syntax(), f) 3436 std::fmt::Display::fmt(self.syntax(), f)
3438 } 3437 }
@@ -3467,12 +3466,12 @@ impl std::fmt::Display for Attr {
3467 std::fmt::Display::fmt(self.syntax(), f) 3466 std::fmt::Display::fmt(self.syntax(), f)
3468 } 3467 }
3469} 3468}
3470impl std::fmt::Display for ConstDef { 3469impl std::fmt::Display for Const {
3471 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3470 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3472 std::fmt::Display::fmt(self.syntax(), f) 3471 std::fmt::Display::fmt(self.syntax(), f)
3473 } 3472 }
3474} 3473}
3475impl std::fmt::Display for EnumDef { 3474impl std::fmt::Display for Enum {
3476 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3475 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3477 std::fmt::Display::fmt(self.syntax(), f) 3476 std::fmt::Display::fmt(self.syntax(), f)
3478 } 3477 }
@@ -3487,7 +3486,7 @@ impl std::fmt::Display for ExternCrate {
3487 std::fmt::Display::fmt(self.syntax(), f) 3486 std::fmt::Display::fmt(self.syntax(), f)
3488 } 3487 }
3489} 3488}
3490impl std::fmt::Display for FnDef { 3489impl std::fmt::Display for Fn {
3491 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3490 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3492 std::fmt::Display::fmt(self.syntax(), f) 3491 std::fmt::Display::fmt(self.syntax(), f)
3493 } 3492 }
@@ -3507,12 +3506,12 @@ impl std::fmt::Display for Module {
3507 std::fmt::Display::fmt(self.syntax(), f) 3506 std::fmt::Display::fmt(self.syntax(), f)
3508 } 3507 }
3509} 3508}
3510impl std::fmt::Display for StaticDef { 3509impl std::fmt::Display for Static {
3511 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3510 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3512 std::fmt::Display::fmt(self.syntax(), f) 3511 std::fmt::Display::fmt(self.syntax(), f)
3513 } 3512 }
3514} 3513}
3515impl std::fmt::Display for StructDef { 3514impl std::fmt::Display for Struct {
3516 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3515 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3517 std::fmt::Display::fmt(self.syntax(), f) 3516 std::fmt::Display::fmt(self.syntax(), f)
3518 } 3517 }
@@ -3522,12 +3521,12 @@ impl std::fmt::Display for TraitDef {
3522 std::fmt::Display::fmt(self.syntax(), f) 3521 std::fmt::Display::fmt(self.syntax(), f)
3523 } 3522 }
3524} 3523}
3525impl std::fmt::Display for TypeAliasDef { 3524impl std::fmt::Display for TypeAlias {
3526 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3525 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3527 std::fmt::Display::fmt(self.syntax(), f) 3526 std::fmt::Display::fmt(self.syntax(), f)
3528 } 3527 }
3529} 3528}
3530impl std::fmt::Display for UnionDef { 3529impl std::fmt::Display for Union {
3531 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3530 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3532 std::fmt::Display::fmt(self.syntax(), f) 3531 std::fmt::Display::fmt(self.syntax(), f)
3533 } 3532 }
@@ -3582,7 +3581,7 @@ impl std::fmt::Display for Abi {
3582 std::fmt::Display::fmt(self.syntax(), f) 3581 std::fmt::Display::fmt(self.syntax(), f)
3583 } 3582 }
3584} 3583}
3585impl std::fmt::Display for TypeParamList { 3584impl std::fmt::Display for GenericParamList {
3586 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3585 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3587 std::fmt::Display::fmt(self.syntax(), f) 3586 std::fmt::Display::fmt(self.syntax(), f)
3588 } 3587 }
@@ -3607,37 +3606,47 @@ impl std::fmt::Display for BlockExpr {
3607 std::fmt::Display::fmt(self.syntax(), f) 3606 std::fmt::Display::fmt(self.syntax(), f)
3608 } 3607 }
3609} 3608}
3610impl std::fmt::Display for RecordFieldDefList { 3609impl std::fmt::Display for Param {
3611 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3610 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3612 std::fmt::Display::fmt(self.syntax(), f) 3611 std::fmt::Display::fmt(self.syntax(), f)
3613 } 3612 }
3614} 3613}
3615impl std::fmt::Display for TupleFieldDefList { 3614impl std::fmt::Display for SelfParam {
3616 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3615 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3617 std::fmt::Display::fmt(self.syntax(), f) 3616 std::fmt::Display::fmt(self.syntax(), f)
3618 } 3617 }
3619} 3618}
3620impl std::fmt::Display for RecordFieldDef { 3619impl std::fmt::Display for TypeBoundList {
3621 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3620 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3622 std::fmt::Display::fmt(self.syntax(), f) 3621 std::fmt::Display::fmt(self.syntax(), f)
3623 } 3622 }
3624} 3623}
3625impl std::fmt::Display for TupleFieldDef { 3624impl std::fmt::Display for RecordFieldList {
3626 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3625 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3627 std::fmt::Display::fmt(self.syntax(), f) 3626 std::fmt::Display::fmt(self.syntax(), f)
3628 } 3627 }
3629} 3628}
3630impl std::fmt::Display for EnumVariantList { 3629impl std::fmt::Display for TupleFieldList {
3631 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3630 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3632 std::fmt::Display::fmt(self.syntax(), f) 3631 std::fmt::Display::fmt(self.syntax(), f)
3633 } 3632 }
3634} 3633}
3635impl std::fmt::Display for EnumVariant { 3634impl std::fmt::Display for RecordField {
3636 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3635 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3637 std::fmt::Display::fmt(self.syntax(), f) 3636 std::fmt::Display::fmt(self.syntax(), f)
3638 } 3637 }
3639} 3638}
3640impl std::fmt::Display for TypeBoundList { 3639impl std::fmt::Display for TupleField {
3640 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3641 std::fmt::Display::fmt(self.syntax(), f)
3642 }
3643}
3644impl std::fmt::Display for VariantList {
3645 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3646 std::fmt::Display::fmt(self.syntax(), f)
3647 }
3648}
3649impl std::fmt::Display for Variant {
3641 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3650 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3642 std::fmt::Display::fmt(self.syntax(), f) 3651 std::fmt::Display::fmt(self.syntax(), f)
3643 } 3652 }
@@ -3882,17 +3891,17 @@ impl std::fmt::Display for MatchGuard {
3882 std::fmt::Display::fmt(self.syntax(), f) 3891 std::fmt::Display::fmt(self.syntax(), f)
3883 } 3892 }
3884} 3893}
3885impl std::fmt::Display for RecordLit { 3894impl std::fmt::Display for RecordExpr {
3886 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3895 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3887 std::fmt::Display::fmt(self.syntax(), f) 3896 std::fmt::Display::fmt(self.syntax(), f)
3888 } 3897 }
3889} 3898}
3890impl std::fmt::Display for RecordFieldList { 3899impl std::fmt::Display for RecordExprFieldList {
3891 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3900 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3892 std::fmt::Display::fmt(self.syntax(), f) 3901 std::fmt::Display::fmt(self.syntax(), f)
3893 } 3902 }
3894} 3903}
3895impl std::fmt::Display for RecordField { 3904impl std::fmt::Display for RecordExprField {
3896 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3905 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3897 std::fmt::Display::fmt(self.syntax(), f) 3906 std::fmt::Display::fmt(self.syntax(), f)
3898 } 3907 }
@@ -4037,16 +4046,6 @@ impl std::fmt::Display for LetStmt {
4037 std::fmt::Display::fmt(self.syntax(), f) 4046 std::fmt::Display::fmt(self.syntax(), f)
4038 } 4047 }
4039} 4048}
4040impl std::fmt::Display for SelfParam {
4041 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4042 std::fmt::Display::fmt(self.syntax(), f)
4043 }
4044}
4045impl std::fmt::Display for Param {
4046 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4047 std::fmt::Display::fmt(self.syntax(), f)
4048 }
4049}
4050impl std::fmt::Display for PathSegment { 4049impl std::fmt::Display for PathSegment {
4051 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4050 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4052 std::fmt::Display::fmt(self.syntax(), f) 4051 std::fmt::Display::fmt(self.syntax(), f)
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 0ff69bc2d..509e8ae7a 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -64,18 +64,18 @@ pub fn use_item(use_tree: ast::UseTree) -> ast::Use {
64 ast_from_text(&format!("use {};", use_tree)) 64 ast_from_text(&format!("use {};", use_tree))
65} 65}
66 66
67pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { 67pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField {
68 return match expr { 68 return match expr {
69 Some(expr) => from_text(&format!("{}: {}", name, expr)), 69 Some(expr) => from_text(&format!("{}: {}", name, expr)),
70 None => from_text(&name.to_string()), 70 None => from_text(&name.to_string()),
71 }; 71 };
72 72
73 fn from_text(text: &str) -> ast::RecordField { 73 fn from_text(text: &str) -> ast::RecordExprField {
74 ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) 74 ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text))
75 } 75 }
76} 76}
77 77
78pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordFieldDef { 78pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField {
79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) 79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty))
80} 80}
81 81
@@ -291,10 +291,10 @@ pub fn visibility_pub_crate() -> ast::Visibility {
291pub fn fn_def( 291pub fn fn_def(
292 visibility: Option<ast::Visibility>, 292 visibility: Option<ast::Visibility>,
293 fn_name: ast::Name, 293 fn_name: ast::Name,
294 type_params: Option<ast::TypeParamList>, 294 type_params: Option<ast::GenericParamList>,
295 params: ast::ParamList, 295 params: ast::ParamList,
296 body: ast::BlockExpr, 296 body: ast::BlockExpr,
297) -> ast::FnDef { 297) -> ast::Fn {
298 let type_params = 298 let type_params =
299 if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; 299 if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() };
300 let visibility = match visibility { 300 let visibility = match visibility {
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs
index 242900643..4da1d5c11 100644
--- a/crates/ra_syntax/src/ast/node_ext.rs
+++ b/crates/ra_syntax/src/ast/node_ext.rs
@@ -166,16 +166,16 @@ impl ast::ImplDef {
166 166
167#[derive(Debug, Clone, PartialEq, Eq)] 167#[derive(Debug, Clone, PartialEq, Eq)]
168pub enum StructKind { 168pub enum StructKind {
169 Record(ast::RecordFieldDefList), 169 Record(ast::RecordFieldList),
170 Tuple(ast::TupleFieldDefList), 170 Tuple(ast::TupleFieldList),
171 Unit, 171 Unit,
172} 172}
173 173
174impl StructKind { 174impl StructKind {
175 fn from_node<N: AstNode>(node: &N) -> StructKind { 175 fn from_node<N: AstNode>(node: &N) -> StructKind {
176 if let Some(nfdl) = support::child::<ast::RecordFieldDefList>(node.syntax()) { 176 if let Some(nfdl) = support::child::<ast::RecordFieldList>(node.syntax()) {
177 StructKind::Record(nfdl) 177 StructKind::Record(nfdl)
178 } else if let Some(pfl) = support::child::<ast::TupleFieldDefList>(node.syntax()) { 178 } else if let Some(pfl) = support::child::<ast::TupleFieldList>(node.syntax()) {
179 StructKind::Tuple(pfl) 179 StructKind::Tuple(pfl)
180 } else { 180 } else {
181 StructKind::Unit 181 StructKind::Unit
@@ -183,17 +183,17 @@ impl StructKind {
183 } 183 }
184} 184}
185 185
186impl ast::StructDef { 186impl ast::Struct {
187 pub fn kind(&self) -> StructKind { 187 pub fn kind(&self) -> StructKind {
188 StructKind::from_node(self) 188 StructKind::from_node(self)
189 } 189 }
190} 190}
191 191
192impl ast::RecordField { 192impl ast::RecordExprField {
193 pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> { 193 pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> {
194 let candidate = 194 let candidate =
195 field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| { 195 field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| {
196 field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast) 196 field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast)
197 })?; 197 })?;
198 if candidate.field_name().as_ref() == Some(field_name) { 198 if candidate.field_name().as_ref() == Some(field_name) {
199 Some(candidate) 199 Some(candidate)
@@ -247,12 +247,12 @@ impl ast::RecordFieldPat {
247 } 247 }
248} 248}
249 249
250impl ast::EnumVariant { 250impl ast::Variant {
251 pub fn parent_enum(&self) -> ast::EnumDef { 251 pub fn parent_enum(&self) -> ast::Enum {
252 self.syntax() 252 self.syntax()
253 .parent() 253 .parent()
254 .and_then(|it| it.parent()) 254 .and_then(|it| it.parent())
255 .and_then(ast::EnumDef::cast) 255 .and_then(ast::Enum::cast)
256 .expect("EnumVariants are always nested in Enums") 256 .expect("EnumVariants are always nested in Enums")
257 } 257 }
258 pub fn kind(&self) -> StructKind { 258 pub fn kind(&self) -> StructKind {
@@ -474,17 +474,17 @@ impl ast::TokenTree {
474} 474}
475 475
476impl ast::DocCommentsOwner for ast::SourceFile {} 476impl ast::DocCommentsOwner for ast::SourceFile {}
477impl ast::DocCommentsOwner for ast::FnDef {} 477impl ast::DocCommentsOwner for ast::Fn {}
478impl ast::DocCommentsOwner for ast::StructDef {} 478impl ast::DocCommentsOwner for ast::Struct {}
479impl ast::DocCommentsOwner for ast::UnionDef {} 479impl ast::DocCommentsOwner for ast::Union {}
480impl ast::DocCommentsOwner for ast::RecordFieldDef {} 480impl ast::DocCommentsOwner for ast::RecordField {}
481impl ast::DocCommentsOwner for ast::TupleFieldDef {} 481impl ast::DocCommentsOwner for ast::TupleField {}
482impl ast::DocCommentsOwner for ast::EnumDef {} 482impl ast::DocCommentsOwner for ast::Enum {}
483impl ast::DocCommentsOwner for ast::EnumVariant {} 483impl ast::DocCommentsOwner for ast::Variant {}
484impl ast::DocCommentsOwner for ast::TraitDef {} 484impl ast::DocCommentsOwner for ast::TraitDef {}
485impl ast::DocCommentsOwner for ast::Module {} 485impl ast::DocCommentsOwner for ast::Module {}
486impl ast::DocCommentsOwner for ast::StaticDef {} 486impl ast::DocCommentsOwner for ast::Static {}
487impl ast::DocCommentsOwner for ast::ConstDef {} 487impl ast::DocCommentsOwner for ast::Const {}
488impl ast::DocCommentsOwner for ast::TypeAliasDef {} 488impl ast::DocCommentsOwner for ast::TypeAlias {}
489impl ast::DocCommentsOwner for ast::ImplDef {} 489impl ast::DocCommentsOwner for ast::ImplDef {}
490impl ast::DocCommentsOwner for ast::MacroCall {} 490impl ast::DocCommentsOwner for ast::MacroCall {}
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 9fe0b93c1..113bd5d82 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -49,8 +49,8 @@ pub trait ModuleItemOwner: AstNode {
49 } 49 }
50} 50}
51 51
52pub trait TypeParamsOwner: AstNode { 52pub trait GenericParamsOwner: AstNode {
53 fn type_param_list(&self) -> Option<ast::TypeParamList> { 53 fn generic_param_list(&self) -> Option<ast::GenericParamList> {
54 support::child(self.syntax()) 54 support::child(self.syntax())
55 } 55 }
56 56
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 219dd0b07..6203b6206 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -255,11 +255,11 @@ fn api_walkthrough() {
255 let mut func = None; 255 let mut func = None;
256 for item in file.items() { 256 for item in file.items() {
257 match item { 257 match item {
258 ast::Item::FnDef(f) => func = Some(f), 258 ast::Item::Fn(f) => func = Some(f),
259 _ => unreachable!(), 259 _ => unreachable!(),
260 } 260 }
261 } 261 }
262 let func: ast::FnDef = func.unwrap(); 262 let func: ast::Fn = func.unwrap();
263 263
264 // Each AST node has a bunch of getters for children. All getters return 264 // Each AST node has a bunch of getters for children. All getters return
265 // `Option`s though, to account for incomplete code. Some getters are common 265 // `Option`s though, to account for incomplete code. Some getters are common
@@ -316,7 +316,7 @@ fn api_walkthrough() {
316 ); 316 );
317 317
318 // As well as some iterator helpers: 318 // As well as some iterator helpers:
319 let f = expr_syntax.ancestors().find_map(ast::FnDef::cast); 319 let f = expr_syntax.ancestors().find_map(ast::Fn::cast);
320 assert_eq!(f, Some(func)); 320 assert_eq!(f, Some(func));
321 assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); 321 assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}']));
322 assert_eq!( 322 assert_eq!(
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index c6b30a02a..95581a84b 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -146,8 +146,8 @@ fn n_attached_trivias<'a>(
146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
147) -> usize { 147) -> usize {
148 match kind { 148 match kind {
149 MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF 149 MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF | MODULE
150 | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { 150 | RECORD_FIELD | STATIC => {
151 let mut res = 0; 151 let mut res = 0;
152 let mut trivias = trivias.enumerate().peekable(); 152 let mut trivias = trivias.enumerate().peekable();
153 153
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs
index 62f03e93d..ca7957747 100644
--- a/crates/ra_syntax/src/ptr.rs
+++ b/crates/ra_syntax/src/ptr.rs
@@ -98,7 +98,7 @@ fn test_local_syntax_ptr() {
98 use crate::{ast, AstNode, SourceFile}; 98 use crate::{ast, AstNode, SourceFile};
99 99
100 let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap(); 100 let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap();
101 let field = file.syntax().descendants().find_map(ast::RecordFieldDef::cast).unwrap(); 101 let field = file.syntax().descendants().find_map(ast::RecordField::cast).unwrap();
102 let ptr = SyntaxNodePtr::new(field.syntax()); 102 let ptr = SyntaxNodePtr::new(field.syntax());
103 let field_syntax = ptr.to_node(file.syntax()); 103 let field_syntax = ptr.to_node(file.syntax());
104 assert_eq!(field.syntax(), &field_syntax); 104 assert_eq!(field.syntax(), &field_syntax);
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs
index fdec48fb0..a666b18db 100644
--- a/crates/ra_syntax/src/validation.rs
+++ b/crates/ra_syntax/src/validation.rs
@@ -4,7 +4,7 @@ mod block;
4 4
5use crate::{ 5use crate::{
6 ast, match_ast, AstNode, SyntaxError, 6 ast, match_ast, AstNode, SyntaxError,
7 SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, 7 SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST, FN, INT_NUMBER, STRING, TYPE_ALIAS},
8 SyntaxNode, SyntaxToken, TextSize, T, 8 SyntaxNode, SyntaxToken, TextSize, T,
9}; 9};
10use rustc_lexer::unescape::{ 10use rustc_lexer::unescape::{
@@ -91,7 +91,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
91 ast::Literal(it) => validate_literal(it, &mut errors), 91 ast::Literal(it) => validate_literal(it, &mut errors),
92 ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), 92 ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors),
93 ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), 93 ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors),
94 ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), 94 ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), &mut errors),
95 ast::Visibility(it) => validate_visibility(it, &mut errors), 95 ast::Visibility(it) => validate_visibility(it, &mut errors),
96 ast::RangeExpr(it) => validate_range_expr(it, &mut errors), 96 ast::RangeExpr(it) => validate_range_expr(it, &mut errors),
97 ast::PathSegment(it) => validate_path_keywords(it, &mut errors), 97 ast::PathSegment(it) => validate_path_keywords(it, &mut errors),
@@ -200,7 +200,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) {
200 None => return, 200 None => return,
201 }; 201 };
202 match parent.kind() { 202 match parent.kind() {
203 FN_DEF | CONST_DEF | TYPE_ALIAS_DEF => (), 203 FN | CONST | TYPE_ALIAS => (),
204 _ => return, 204 _ => return,
205 } 205 }
206 206
diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs
index 2c08f7e6e..ad9901468 100644
--- a/crates/ra_syntax/src/validation/block.rs
+++ b/crates/ra_syntax/src/validation/block.rs
@@ -9,7 +9,7 @@ use crate::{
9pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { 9pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
10 if let Some(parent) = block.syntax().parent() { 10 if let Some(parent) = block.syntax().parent() {
11 match parent.kind() { 11 match parent.kind() {
12 FN_DEF | EXPR_STMT | BLOCK_EXPR => return, 12 FN | EXPR_STMT | BLOCK_EXPR => return,
13 _ => {} 13 _ => {}
14 } 14 }
15 } 15 }