aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-09 12:00:55 +0100
committerGitHub <[email protected]>2020-04-09 12:00:55 +0100
commitcfc127f52988cf4f95797cb355398e3af32632aa (patch)
treea974bfe4160a0cb0d49146b239d68cdb99a6566d
parent85956932872481cf4813c5e7794d981a9edb4623 (diff)
parent689661c95968cb438f8bd1f10ce0ee096287741b (diff)
Merge #3911
3911: Genrate token accessors r=matklad a=matklad bors r+ 🤖 Co-authored-by: Luca Barbieri <[email protected]> Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_assists/src/handlers/add_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/add_new.rs5
-rw-r--r--crates/ra_assists/src/handlers/introduce_variable.rs2
-rw-r--r--crates/ra_assists/src/handlers/merge_imports.rs4
-rw-r--r--crates/ra_fmt/src/lib.rs6
-rw-r--r--crates/ra_hir_def/src/body/lower.rs9
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs4
-rw-r--r--crates/ra_hir_def/src/path/lower.rs2
-rw-r--r--crates/ra_hir_def/src/path/lower/lower_use.rs2
-rw-r--r--crates/ra_hir_def/src/visibility.rs4
-rw-r--r--crates/ra_hir_ty/src/tests.rs4
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs6
-rw-r--r--crates/ra_syntax/src/ast.rs18
-rw-r--r--crates/ra_syntax/src/ast/edit.rs26
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs4
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs147
-rw-r--r--crates/ra_syntax/src/ast/generated.rs2091
-rw-r--r--crates/ra_syntax/src/ast/traits.rs10
-rw-r--r--xtask/src/ast_src.rs375
-rw-r--r--xtask/src/codegen/gen_syntax.rs87
20 files changed, 2412 insertions, 398 deletions
diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs
index 6622eadb2..72a201b6d 100644
--- a/crates/ra_assists/src/handlers/add_impl.rs
+++ b/crates/ra_assists/src/handlers/add_impl.rs
@@ -1,5 +1,5 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, AstNode, NameOwner, TypeParamsOwner}, 2 ast::{self, AstNode, AstToken, NameOwner, TypeParamsOwner},
3 TextUnit, 3 TextUnit,
4}; 4};
5use stdx::{format_to, SepBy}; 5use stdx::{format_to, SepBy};
@@ -42,7 +42,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option<Assist> {
42 if let Some(type_params) = type_params { 42 if let Some(type_params) = type_params {
43 let lifetime_params = type_params 43 let lifetime_params = type_params
44 .lifetime_params() 44 .lifetime_params()
45 .filter_map(|it| it.lifetime_token()) 45 .filter_map(|it| it.lifetime())
46 .map(|it| it.text().clone()); 46 .map(|it| it.text().clone());
47 let type_params = 47 let type_params =
48 type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); 48 type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone());
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs
index 240b19fa3..c10397249 100644
--- a/crates/ra_assists/src/handlers/add_new.rs
+++ b/crates/ra_assists/src/handlers/add_new.rs
@@ -1,7 +1,8 @@
1use hir::Adt; 1use hir::Adt;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{ 3 ast::{
4 self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, 4 self, AstNode, AstToken, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner,
5 VisibilityOwner,
5 }, 6 },
6 TextUnit, T, 7 TextUnit, T,
7}; 8};
@@ -105,7 +106,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
105 if let Some(type_params) = type_params { 106 if let Some(type_params) = type_params {
106 let lifetime_params = type_params 107 let lifetime_params = type_params
107 .lifetime_params() 108 .lifetime_params()
108 .filter_map(|it| it.lifetime_token()) 109 .filter_map(|it| it.lifetime())
109 .map(|it| it.text().clone()); 110 .map(|it| it.text().clone());
110 let type_params = 111 let type_params =
111 type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); 112 type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone());
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs
index 1edbdc14c..8a02f1a32 100644
--- a/crates/ra_assists/src/handlers/introduce_variable.rs
+++ b/crates/ra_assists/src/handlers/introduce_variable.rs
@@ -124,7 +124,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> {
124 } 124 }
125 } 125 }
126 126
127 if ast::Stmt::cast(node.clone()).is_some() { 127 if ast::Stmt::cast(node.clone().into()).is_some() {
128 return Some((node, false)); 128 return Some((node, false));
129 } 129 }
130 130
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs
index 5d4b74e56..f8b3ddb4e 100644
--- a/crates/ra_assists/src/handlers/merge_imports.rs
+++ b/crates/ra_assists/src/handlers/merge_imports.rs
@@ -3,7 +3,7 @@ use std::iter::successors;
3use ra_syntax::{ 3use ra_syntax::{
4 algo::{neighbor, SyntaxRewriter}, 4 algo::{neighbor, SyntaxRewriter},
5 ast::{self, edit::AstNodeEdit, make}, 5 ast::{self, edit::AstNodeEdit, make},
6 AstNode, Direction, InsertPosition, SyntaxElement, T, 6 AstNode, AstToken, Direction, InsertPosition, SyntaxElement, T,
7}; 7};
8 8
9use crate::{Assist, AssistCtx, AssistId}; 9use crate::{Assist, AssistCtx, AssistId};
@@ -82,7 +82,7 @@ fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option<ast::UseTre
82 .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']), 82 .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']),
83 ); 83 );
84 let use_tree_list = lhs.use_tree_list()?; 84 let use_tree_list = lhs.use_tree_list()?;
85 let pos = InsertPosition::Before(use_tree_list.r_curly()?.into()); 85 let pos = InsertPosition::Before(use_tree_list.r_curly()?.syntax().clone().into());
86 let use_tree_list = use_tree_list.insert_children(pos, to_insert); 86 let use_tree_list = use_tree_list.insert_children(pos, to_insert);
87 Some(lhs.with_use_tree_list(use_tree_list)) 87 Some(lhs.with_use_tree_list(use_tree_list))
88} 88}
diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs
index db27f9b83..0b4ba1bbe 100644
--- a/crates/ra_fmt/src/lib.rs
+++ b/crates/ra_fmt/src/lib.rs
@@ -60,10 +60,10 @@ pub fn extract_trivial_expression(block: &ast::BlockExpr) -> Option<ast::Expr> {
60 } else { 60 } else {
61 // Unwrap `{ continue; }` 61 // Unwrap `{ continue; }`
62 let (stmt,) = block.statements().next_tuple()?; 62 let (stmt,) = block.statements().next_tuple()?;
63 if has_anything_else(stmt.syntax()) {
64 return None;
65 }
66 if let ast::Stmt::ExprStmt(expr_stmt) = stmt { 63 if let ast::Stmt::ExprStmt(expr_stmt) = stmt {
64 if has_anything_else(expr_stmt.syntax()) {
65 return None;
66 }
67 let expr = expr_stmt.expr()?; 67 let expr = expr_stmt.expr()?;
68 match expr.syntax().kind() { 68 match expr.syntax().kind() {
69 CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr), 69 CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr),
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 8d4b8b0f0..b02de5d67 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -482,14 +482,16 @@ impl ExprCollector<'_> {
482 self.collect_block_items(&block); 482 self.collect_block_items(&block);
483 let statements = block 483 let statements = block
484 .statements() 484 .statements()
485 .map(|s| match s { 485 .filter_map(|s| match s {
486 ast::Stmt::LetStmt(stmt) => { 486 ast::Stmt::LetStmt(stmt) => {
487 let pat = self.collect_pat_opt(stmt.pat()); 487 let pat = self.collect_pat_opt(stmt.pat());
488 let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); 488 let type_ref = stmt.ascribed_type().map(TypeRef::from_ast);
489 let initializer = stmt.initializer().map(|e| self.collect_expr(e)); 489 let initializer = stmt.initializer().map(|e| self.collect_expr(e));
490 Statement::Let { pat, type_ref, initializer } 490 Some(Statement::Let { pat, type_ref, initializer })
491 }
492 ast::Stmt::ExprStmt(stmt) => {
493 Some(Statement::Expr(self.collect_expr_opt(stmt.expr())))
491 } 494 }
492 ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())),
493 }) 495 })
494 .collect(); 496 .collect();
495 let tail = block.expr().map(|e| self.collect_expr(e)); 497 let tail = block.expr().map(|e| self.collect_expr(e));
@@ -541,6 +543,7 @@ impl ExprCollector<'_> {
541 let ast_id = self.expander.ast_id(&def); 543 let ast_id = self.expander.ast_id(&def);
542 (TraitLoc { container, ast_id }.intern(self.db).into(), def.name()) 544 (TraitLoc { container, ast_id }.intern(self.db).into(), def.name())
543 } 545 }
546 ast::ModuleItem::ExternBlock(_) => continue, // FIXME: collect from extern blocks
544 ast::ModuleItem::ImplDef(_) 547 ast::ModuleItem::ImplDef(_)
545 | ast::ModuleItem::UseItem(_) 548 | ast::ModuleItem::UseItem(_)
546 | ast::ModuleItem::ExternCrateItem(_) 549 | ast::ModuleItem::ExternCrateItem(_)
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 8f190e7f9..a9dff3a5d 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -266,6 +266,10 @@ impl RawItemsCollector {
266 self.add_macro(current_module, it); 266 self.add_macro(current_module, it);
267 return; 267 return;
268 } 268 }
269 ast::ModuleItem::ExternBlock(_) => {
270 // FIXME: add extern block
271 return;
272 }
269 }; 273 };
270 if let Some(name) = name { 274 if let Some(name) = name {
271 let name = name.as_name(); 275 let name = name.as_name();
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index 4900000fe..3c13cb2c7 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -28,7 +28,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
28 loop { 28 loop {
29 let segment = path.segment()?; 29 let segment = path.segment()?;
30 30
31 if segment.has_colon_colon() { 31 if segment.coloncolon().is_some() {
32 kind = PathKind::Abs; 32 kind = PathKind::Abs;
33 } 33 }
34 34
diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs
index 278d5196e..6ec944228 100644
--- a/crates/ra_hir_def/src/path/lower/lower_use.rs
+++ b/crates/ra_hir_def/src/path/lower/lower_use.rs
@@ -34,7 +34,7 @@ pub(crate) fn lower_use_tree(
34 let alias = tree.alias().map(|a| { 34 let alias = tree.alias().map(|a| {
35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) 35 a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
36 }); 36 });
37 let is_glob = tree.has_star(); 37 let is_glob = tree.star().is_some();
38 if let Some(ast_path) = tree.path() { 38 if let Some(ast_path) = tree.path() {
39 // Handle self in a path. 39 // Handle self in a path.
40 // E.g. `use something::{self, <...>}` 40 // E.g. `use something::{self, <...>}`
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs
index 62513873e..1482d3be0 100644
--- a/crates/ra_hir_def/src/visibility.rs
+++ b/crates/ra_hir_def/src/visibility.rs
@@ -84,6 +84,10 @@ impl RawVisibility {
84 let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() }; 84 let path = ModPath { kind: PathKind::Super(1), segments: Vec::new() };
85 RawVisibility::Module(path) 85 RawVisibility::Module(path)
86 } 86 }
87 ast::VisibilityKind::PubSelf => {
88 let path = ModPath { kind: PathKind::Plain, segments: Vec::new() };
89 RawVisibility::Module(path)
90 }
87 ast::VisibilityKind::Pub => RawVisibility::Public, 91 ast::VisibilityKind::Pub => RawVisibility::Public,
88 } 92 }
89 } 93 }
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 608408d88..ac0966236 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -23,7 +23,7 @@ use insta::assert_snapshot;
23use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase}; 23use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase};
24use ra_syntax::{ 24use ra_syntax::{
25 algo, 25 algo,
26 ast::{self, AstNode}, 26 ast::{self, AstNode, AstToken},
27}; 27};
28use stdx::format_to; 28use stdx::format_to;
29 29
@@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
101 let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db)); 101 let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db));
102 102
103 let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) { 103 let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) {
104 (self_param.self_kw_token().text_range(), "self".to_string()) 104 (self_param.self_kw().unwrap().syntax().text_range(), "self".to_string())
105 } else { 105 } else {
106 (src_ptr.value.range(), node.text().to_string().replace("\n", " ")) 106 (src_ptr.value.range(), node.text().to_string().replace("\n", " "))
107 }; 107 };
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 4c16cf1cd..004f4e564 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -105,6 +105,7 @@ pub enum SyntaxKind {
105 DEFAULT_KW, 105 DEFAULT_KW,
106 EXISTENTIAL_KW, 106 EXISTENTIAL_KW,
107 UNION_KW, 107 UNION_KW,
108 RAW_KW,
108 INT_NUMBER, 109 INT_NUMBER,
109 FLOAT_NUMBER, 110 FLOAT_NUMBER,
110 CHAR, 111 CHAR,
@@ -258,7 +259,7 @@ impl SyntaxKind {
258 | IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW 259 | IMPL_KW | IN_KW | LET_KW | LOOP_KW | MACRO_KW | MATCH_KW | MOD_KW | MOVE_KW
259 | MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW 260 | MUT_KW | PUB_KW | REF_KW | RETURN_KW | SELF_KW | STATIC_KW | STRUCT_KW | SUPER_KW
260 | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW 261 | TRAIT_KW | TRUE_KW | TRY_KW | TYPE_KW | UNSAFE_KW | USE_KW | WHERE_KW | WHILE_KW
261 | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW => true, 262 | AUTO_KW | DEFAULT_KW | EXISTENTIAL_KW | UNION_KW | RAW_KW => true,
262 _ => false, 263 _ => false,
263 } 264 }
264 } 265 }
@@ -651,4 +652,7 @@ macro_rules! T {
651 ( union ) => { 652 ( union ) => {
652 $crate::SyntaxKind::UNION_KW 653 $crate::SyntaxKind::UNION_KW
653 }; 654 };
655 ( raw ) => {
656 $crate::SyntaxKind::RAW_KW
657 };
654} 658}
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index ab0f44dd2..e1ebd5b92 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -64,6 +64,22 @@ pub trait AstToken {
64 } 64 }
65} 65}
66 66
67mod support {
68 use super::{AstChildren, AstNode, AstToken, SyntaxNode};
69
70 pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
71 parent.children().find_map(N::cast)
72 }
73
74 pub(super) fn children<N: AstNode>(parent: &SyntaxNode) -> AstChildren<N> {
75 AstChildren::new(parent)
76 }
77
78 pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
79 parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
80 }
81}
82
67/// An iterator over `SyntaxNode` children of a particular AST type. 83/// An iterator over `SyntaxNode` children of a particular AST type.
68#[derive(Debug, Clone)] 84#[derive(Debug, Clone)]
69pub struct AstChildren<N> { 85pub struct AstChildren<N> {
@@ -271,7 +287,7 @@ where
271 let pred = predicates.next().unwrap(); 287 let pred = predicates.next().unwrap();
272 let mut bounds = pred.type_bound_list().unwrap().bounds(); 288 let mut bounds = pred.type_bound_list().unwrap().bounds();
273 289
274 assert_eq!("'a", pred.lifetime_token().unwrap().text()); 290 assert_eq!("'a", pred.lifetime().unwrap().text());
275 291
276 assert_bound("'b", bounds.next()); 292 assert_bound("'b", bounds.next());
277 assert_bound("'c", bounds.next()); 293 assert_bound("'c", bounds.next());
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index b69cae234..d79310995 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -99,7 +99,7 @@ impl ast::ItemList {
99 None => match self.l_curly() { 99 None => match self.l_curly() {
100 Some(it) => ( 100 Some(it) => (
101 " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), 101 " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(),
102 InsertPosition::After(it), 102 InsertPosition::After(it.syntax().clone().into()),
103 ), 103 ),
104 None => return self.clone(), 104 None => return self.clone(),
105 }, 105 },
@@ -109,10 +109,6 @@ impl ast::ItemList {
109 [ws.ws().into(), item.syntax().clone().into()].into(); 109 [ws.ws().into(), item.syntax().clone().into()].into();
110 self.insert_children(position, to_insert) 110 self.insert_children(position, to_insert)
111 } 111 }
112
113 fn l_curly(&self) -> Option<SyntaxElement> {
114 self.syntax().children_with_tokens().find(|it| it.kind() == T!['{'])
115 }
116} 112}
117 113
118impl ast::RecordFieldList { 114impl ast::RecordFieldList {
@@ -147,7 +143,7 @@ impl ast::RecordFieldList {
147 macro_rules! after_l_curly { 143 macro_rules! after_l_curly {
148 () => {{ 144 () => {{
149 let anchor = match self.l_curly() { 145 let anchor = match self.l_curly() {
150 Some(it) => it, 146 Some(it) => it.syntax().clone().into(),
151 None => return self.clone(), 147 None => return self.clone(),
152 }; 148 };
153 InsertPosition::After(anchor) 149 InsertPosition::After(anchor)
@@ -189,24 +185,20 @@ impl ast::RecordFieldList {
189 185
190 self.insert_children(position, to_insert) 186 self.insert_children(position, to_insert)
191 } 187 }
192
193 fn l_curly(&self) -> Option<SyntaxElement> {
194 self.syntax().children_with_tokens().find(|it| it.kind() == T!['{'])
195 }
196} 188}
197 189
198impl ast::TypeParam { 190impl ast::TypeParam {
199 #[must_use] 191 #[must_use]
200 pub fn remove_bounds(&self) -> ast::TypeParam { 192 pub fn remove_bounds(&self) -> ast::TypeParam {
201 let colon = match self.colon_token() { 193 let colon = match self.colon() {
202 Some(it) => it, 194 Some(it) => it,
203 None => return self.clone(), 195 None => return self.clone(),
204 }; 196 };
205 let end = match self.type_bound_list() { 197 let end = match self.type_bound_list() {
206 Some(it) => it.syntax().clone().into(), 198 Some(it) => it.syntax().clone().into(),
207 None => colon.clone().into(), 199 None => colon.syntax().clone().into(),
208 }; 200 };
209 self.replace_children(colon.into()..=end, iter::empty()) 201 self.replace_children(colon.syntax().clone().into()..=end, iter::empty())
210 } 202 }
211} 203}
212 204
@@ -305,8 +297,12 @@ impl ast::UseTree {
305 Some(it) => it, 297 Some(it) => it,
306 None => return self.clone(), 298 None => return self.clone(),
307 }; 299 };
308 let use_tree = 300 let use_tree = make::use_tree(
309 make::use_tree(suffix.clone(), self.use_tree_list(), self.alias(), self.has_star()); 301 suffix.clone(),
302 self.use_tree_list(),
303 self.alias(),
304 self.star().is_some(),
305 );
310 let nested = make::use_tree_list(iter::once(use_tree)); 306 let nested = make::use_tree_list(iter::once(use_tree));
311 return make::use_tree(prefix.clone(), Some(nested), None, false); 307 return make::use_tree(prefix.clone(), Some(nested), None, false);
312 308
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 8bbd946c0..40c8fca3b 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -52,6 +52,10 @@ impl ast::RefExpr {
52 pub fn is_mut(&self) -> bool { 52 pub fn is_mut(&self) -> bool {
53 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut]) 53 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
54 } 54 }
55
56 pub fn raw_token(&self) -> Option<SyntaxToken> {
57 None // FIXME: implement &raw
58 }
55} 59}
56 60
57#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 61#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index bf7d137be..33fe60762 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -4,7 +4,9 @@
4use itertools::Itertools; 4use itertools::Itertools;
5 5
6use crate::{ 6use crate::{
7 ast::{self, child_opt, children, AstNode, AttrInput, NameOwner, SyntaxNode}, 7 ast::{
8 self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode,
9 },
8 SmolStr, SyntaxElement, 10 SmolStr, SyntaxElement,
9 SyntaxKind::*, 11 SyntaxKind::*,
10 SyntaxToken, T, 12 SyntaxToken, T,
@@ -130,13 +132,6 @@ impl ast::PathSegment {
130 }; 132 };
131 Some(res) 133 Some(res)
132 } 134 }
133
134 pub fn has_colon_colon(&self) -> bool {
135 match self.syntax.first_child_or_token().map(|s| s.kind()) {
136 Some(T![::]) => true,
137 _ => false,
138 }
139 }
140} 135}
141 136
142impl ast::Path { 137impl ast::Path {
@@ -154,12 +149,6 @@ impl ast::Module {
154 } 149 }
155} 150}
156 151
157impl ast::UseTree {
158 pub fn has_star(&self) -> bool {
159 self.syntax().children_with_tokens().any(|it| it.kind() == T![*])
160 }
161}
162
163impl ast::UseTreeList { 152impl ast::UseTreeList {
164 pub fn parent_use_tree(&self) -> ast::UseTree { 153 pub fn parent_use_tree(&self) -> ast::UseTree {
165 self.syntax() 154 self.syntax()
@@ -167,20 +156,6 @@ impl ast::UseTreeList {
167 .and_then(ast::UseTree::cast) 156 .and_then(ast::UseTree::cast)
168 .expect("UseTreeLists are always nested in UseTrees") 157 .expect("UseTreeLists are always nested in UseTrees")
169 } 158 }
170 pub fn l_curly(&self) -> Option<SyntaxToken> {
171 self.token(T!['{'])
172 }
173
174 pub fn r_curly(&self) -> Option<SyntaxToken> {
175 self.token(T!['}'])
176 }
177
178 fn token(&self, kind: SyntaxKind) -> Option<SyntaxToken> {
179 self.syntax()
180 .children_with_tokens()
181 .filter_map(|it| it.into_token())
182 .find(|it| it.kind() == kind)
183 }
184} 159}
185 160
186impl ast::ImplDef { 161impl ast::ImplDef {
@@ -387,24 +362,9 @@ pub enum SelfParamKind {
387} 362}
388 363
389impl ast::SelfParam { 364impl ast::SelfParam {
390 pub fn self_kw_token(&self) -> SyntaxToken {
391 self.syntax()
392 .children_with_tokens()
393 .filter_map(|it| it.into_token())
394 .find(|it| it.kind() == T![self])
395 .expect("invalid tree: self param must have self")
396 }
397
398 pub fn kind(&self) -> SelfParamKind { 365 pub fn kind(&self) -> SelfParamKind {
399 let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == T![&]); 366 if self.amp().is_some() {
400 if borrowed { 367 if self.amp_mut_kw().is_some() {
401 // check for a `mut` coming after the & -- `mut &self` != `&mut self`
402 if self
403 .syntax()
404 .children_with_tokens()
405 .skip_while(|n| n.kind() != T![&])
406 .any(|n| n.kind() == T![mut])
407 {
408 SelfParamKind::MutRef 368 SelfParamKind::MutRef
409 } else { 369 } else {
410 SelfParamKind::Ref 370 SelfParamKind::Ref
@@ -413,32 +373,23 @@ impl ast::SelfParam {
413 SelfParamKind::Owned 373 SelfParamKind::Owned
414 } 374 }
415 } 375 }
416}
417 376
418impl ast::LifetimeParam { 377 /// the "mut" in "mut self", not the one in "&mut self"
419 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 378 pub fn mut_kw(&self) -> Option<ast::MutKw> {
420 self.syntax() 379 self.syntax()
421 .children_with_tokens() 380 .children_with_tokens()
422 .filter_map(|it| it.into_token()) 381 .filter_map(|it| it.into_token())
423 .find(|it| it.kind() == LIFETIME) 382 .take_while(|it| it.kind() != T![&])
383 .find_map(ast::MutKw::cast)
424 } 384 }
425}
426 385
427impl ast::TypeParam { 386 /// the "mut" in "&mut self", not the one in "mut self"
428 pub fn colon_token(&self) -> Option<SyntaxToken> { 387 pub fn amp_mut_kw(&self) -> Option<ast::MutKw> {
429 self.syntax() 388 self.syntax()
430 .children_with_tokens() 389 .children_with_tokens()
431 .filter_map(|it| it.into_token()) 390 .filter_map(|it| it.into_token())
432 .find(|it| it.kind() == T![:]) 391 .skip_while(|it| it.kind() != T![&])
433 } 392 .find_map(ast::MutKw::cast)
434}
435
436impl ast::WherePred {
437 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
438 self.syntax()
439 .children_with_tokens()
440 .filter_map(|it| it.into_token())
441 .find(|it| it.kind() == LIFETIME)
442 } 393 }
443} 394}
444 395
@@ -449,7 +400,7 @@ pub enum TypeBoundKind {
449 /// for<'a> ... 400 /// for<'a> ...
450 ForType(ast::ForType), 401 ForType(ast::ForType),
451 /// 'a 402 /// 'a
452 Lifetime(ast::SyntaxToken), 403 Lifetime(ast::Lifetime),
453} 404}
454 405
455impl ast::TypeBound { 406impl ast::TypeBound {
@@ -465,21 +416,28 @@ impl ast::TypeBound {
465 } 416 }
466 } 417 }
467 418
468 fn lifetime(&self) -> Option<SyntaxToken> { 419 pub fn has_question_mark(&self) -> bool {
469 self.syntax() 420 self.question().is_some()
470 .children_with_tokens()
471 .filter_map(|it| it.into_token())
472 .find(|it| it.kind() == LIFETIME)
473 } 421 }
474 422
475 pub fn question_mark_token(&self) -> Option<SyntaxToken> { 423 pub fn const_question(&self) -> Option<ast::Question> {
476 self.syntax() 424 self.syntax()
477 .children_with_tokens() 425 .children_with_tokens()
478 .filter_map(|it| it.into_token()) 426 .filter_map(|it| it.into_token())
479 .find(|it| it.kind() == T![?]) 427 .take_while(|it| it.kind() != T![const])
428 .find_map(ast::Question::cast)
480 } 429 }
481 pub fn has_question_mark(&self) -> bool { 430
482 self.question_mark_token().is_some() 431 pub fn question(&self) -> Option<ast::Question> {
432 if self.const_kw().is_some() {
433 self.syntax()
434 .children_with_tokens()
435 .filter_map(|it| it.into_token())
436 .skip_while(|it| it.kind() != T![const])
437 .find_map(ast::Question::cast)
438 } else {
439 support::token(&self.syntax)
440 }
483 } 441 }
484} 442}
485 443
@@ -493,6 +451,7 @@ pub enum VisibilityKind {
493 In(ast::Path), 451 In(ast::Path),
494 PubCrate, 452 PubCrate,
495 PubSuper, 453 PubSuper,
454 PubSelf,
496 Pub, 455 Pub,
497} 456}
498 457
@@ -504,6 +463,8 @@ impl ast::Visibility {
504 VisibilityKind::PubCrate 463 VisibilityKind::PubCrate
505 } else if self.is_pub_super() { 464 } else if self.is_pub_super() {
506 VisibilityKind::PubSuper 465 VisibilityKind::PubSuper
466 } else if self.is_pub_self() {
467 VisibilityKind::PubSuper
507 } else { 468 } else {
508 VisibilityKind::Pub 469 VisibilityKind::Pub
509 } 470 }
@@ -516,6 +477,10 @@ impl ast::Visibility {
516 fn is_pub_super(&self) -> bool { 477 fn is_pub_super(&self) -> bool {
517 self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) 478 self.syntax().children_with_tokens().any(|it| it.kind() == T![super])
518 } 479 }
480
481 fn is_pub_self(&self) -> bool {
482 self.syntax().children_with_tokens().any(|it| it.kind() == T![self])
483 }
519} 484}
520 485
521impl ast::MacroCall { 486impl ast::MacroCall {
@@ -528,3 +493,41 @@ impl ast::MacroCall {
528 } 493 }
529 } 494 }
530} 495}
496
497impl ast::LifetimeParam {
498 pub fn lifetime_bounds(&self) -> impl Iterator<Item = ast::Lifetime> {
499 self.syntax()
500 .children_with_tokens()
501 .filter_map(|it| it.into_token())
502 .skip_while(|x| x.kind() != T![:])
503 .filter_map(ast::Lifetime::cast)
504 }
505}
506
507impl ast::RangePat {
508 pub fn start(&self) -> Option<ast::Pat> {
509 self.syntax()
510 .children_with_tokens()
511 .take_while(|it| !ast::RangeSeparator::can_cast(it.kind()))
512 .filter_map(|it| it.into_node())
513 .find_map(ast::Pat::cast)
514 }
515
516 pub fn end(&self) -> Option<ast::Pat> {
517 self.syntax()
518 .children_with_tokens()
519 .skip_while(|it| !ast::RangeSeparator::can_cast(it.kind()))
520 .filter_map(|it| it.into_node())
521 .find_map(ast::Pat::cast)
522 }
523}
524
525impl ast::TokenTree {
526 pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> {
527 self.syntax().first_child_or_token()?.into_token().and_then(ast::LeftDelimiter::cast)
528 }
529
530 pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> {
531 self.syntax().last_child_or_token()?.into_token().and_then(ast::RightDelimiter::cast)
532 }
533}
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 385fddc89..bd92e9c87 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -2,7 +2,7 @@
2 2
3#[allow(unused_imports)] 3#[allow(unused_imports)]
4use crate::{ 4use crate::{
5 ast::{self, AstChildren, AstNode, AstToken}, 5 ast::{self, support, AstChildren, AstNode, AstToken},
6 NodeOrToken, SyntaxElement, 6 NodeOrToken, SyntaxElement,
7 SyntaxKind::{self, *}, 7 SyntaxKind::{self, *},
8 SyntaxNode, SyntaxToken, 8 SyntaxNode, SyntaxToken,
@@ -2600,6 +2600,33 @@ impl AstToken for UnionKw {
2600 } 2600 }
2601} 2601}
2602#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2602#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2603pub struct RawKw {
2604 pub(crate) syntax: SyntaxToken,
2605}
2606impl std::fmt::Display for RawKw {
2607 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2608 std::fmt::Display::fmt(&self.syntax, f)
2609 }
2610}
2611impl AstToken for RawKw {
2612 fn can_cast(kind: SyntaxKind) -> bool {
2613 match kind {
2614 RAW_KW => true,
2615 _ => false,
2616 }
2617 }
2618 fn cast(syntax: SyntaxToken) -> Option<Self> {
2619 if Self::can_cast(syntax.kind()) {
2620 Some(Self { syntax })
2621 } else {
2622 None
2623 }
2624 }
2625 fn syntax(&self) -> &SyntaxToken {
2626 &self.syntax
2627 }
2628}
2629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2603pub struct IntNumber { 2630pub struct IntNumber {
2604 pub(crate) syntax: SyntaxToken, 2631 pub(crate) syntax: SyntaxToken,
2605} 2632}
@@ -3060,9 +3087,10 @@ impl AstNode for SourceFile {
3060} 3087}
3061impl ast::ModuleItemOwner for SourceFile {} 3088impl ast::ModuleItemOwner for SourceFile {}
3062impl ast::FnDefOwner for SourceFile {} 3089impl ast::FnDefOwner for SourceFile {}
3090impl ast::AttrsOwner for SourceFile {}
3063impl SourceFile { 3091impl SourceFile {
3064 pub fn modules(&self) -> AstChildren<Module> { 3092 pub fn modules(&self) -> AstChildren<Module> {
3065 AstChildren::new(&self.syntax) 3093 support::children(&self.syntax)
3066 } 3094 }
3067} 3095}
3068#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3096#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3098,14 +3126,35 @@ impl ast::TypeParamsOwner for FnDef {}
3098impl ast::DocCommentsOwner for FnDef {} 3126impl ast::DocCommentsOwner for FnDef {}
3099impl ast::AttrsOwner for FnDef {} 3127impl ast::AttrsOwner for FnDef {}
3100impl FnDef { 3128impl FnDef {
3129 pub fn abi(&self) -> Option<Abi> {
3130 support::child(&self.syntax)
3131 }
3132 pub fn const_kw(&self) -> Option<ConstKw> {
3133 support::token(&self.syntax)
3134 }
3135 pub fn default_kw(&self) -> Option<DefaultKw> {
3136 support::token(&self.syntax)
3137 }
3138 pub fn async_kw(&self) -> Option<AsyncKw> {
3139 support::token(&self.syntax)
3140 }
3141 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3142 support::token(&self.syntax)
3143 }
3144 pub fn fn_kw(&self) -> Option<FnKw> {
3145 support::token(&self.syntax)
3146 }
3101 pub fn param_list(&self) -> Option<ParamList> { 3147 pub fn param_list(&self) -> Option<ParamList> {
3102 AstChildren::new(&self.syntax).next() 3148 support::child(&self.syntax)
3103 } 3149 }
3104 pub fn ret_type(&self) -> Option<RetType> { 3150 pub fn ret_type(&self) -> Option<RetType> {
3105 AstChildren::new(&self.syntax).next() 3151 support::child(&self.syntax)
3106 } 3152 }
3107 pub fn body(&self) -> Option<BlockExpr> { 3153 pub fn body(&self) -> Option<BlockExpr> {
3108 AstChildren::new(&self.syntax).next() 3154 support::child(&self.syntax)
3155 }
3156 pub fn semi(&self) -> Option<Semi> {
3157 support::token(&self.syntax)
3109 } 3158 }
3110} 3159}
3111#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3136,8 +3185,11 @@ impl AstNode for RetType {
3136 } 3185 }
3137} 3186}
3138impl RetType { 3187impl RetType {
3188 pub fn thin_arrow(&self) -> Option<ThinArrow> {
3189 support::token(&self.syntax)
3190 }
3139 pub fn type_ref(&self) -> Option<TypeRef> { 3191 pub fn type_ref(&self) -> Option<TypeRef> {
3140 AstChildren::new(&self.syntax).next() 3192 support::child(&self.syntax)
3141 } 3193 }
3142} 3194}
3143#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3195#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3172,7 +3224,17 @@ impl ast::NameOwner for StructDef {}
3172impl ast::TypeParamsOwner for StructDef {} 3224impl ast::TypeParamsOwner for StructDef {}
3173impl ast::AttrsOwner for StructDef {} 3225impl ast::AttrsOwner for StructDef {}
3174impl ast::DocCommentsOwner for StructDef {} 3226impl ast::DocCommentsOwner for StructDef {}
3175impl StructDef {} 3227impl StructDef {
3228 pub fn struct_kw(&self) -> Option<StructKw> {
3229 support::token(&self.syntax)
3230 }
3231 pub fn field_def_list(&self) -> Option<FieldDefList> {
3232 support::child(&self.syntax)
3233 }
3234 pub fn semi(&self) -> Option<Semi> {
3235 support::token(&self.syntax)
3236 }
3237}
3176#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3177pub struct UnionDef { 3239pub struct UnionDef {
3178 pub(crate) syntax: SyntaxNode, 3240 pub(crate) syntax: SyntaxNode,
@@ -3206,8 +3268,11 @@ impl ast::TypeParamsOwner for UnionDef {}
3206impl ast::AttrsOwner for UnionDef {} 3268impl ast::AttrsOwner for UnionDef {}
3207impl ast::DocCommentsOwner for UnionDef {} 3269impl ast::DocCommentsOwner for UnionDef {}
3208impl UnionDef { 3270impl UnionDef {
3271 pub fn union_kw(&self) -> Option<UnionKw> {
3272 support::token(&self.syntax)
3273 }
3209 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 3274 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
3210 AstChildren::new(&self.syntax).next() 3275 support::child(&self.syntax)
3211 } 3276 }
3212} 3277}
3213#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3278#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3238,8 +3303,14 @@ impl AstNode for RecordFieldDefList {
3238 } 3303 }
3239} 3304}
3240impl RecordFieldDefList { 3305impl RecordFieldDefList {
3306 pub fn l_curly(&self) -> Option<LCurly> {
3307 support::token(&self.syntax)
3308 }
3241 pub fn fields(&self) -> AstChildren<RecordFieldDef> { 3309 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
3242 AstChildren::new(&self.syntax) 3310 support::children(&self.syntax)
3311 }
3312 pub fn r_curly(&self) -> Option<RCurly> {
3313 support::token(&self.syntax)
3243 } 3314 }
3244} 3315}
3245#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3316#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3303,8 +3374,14 @@ impl AstNode for TupleFieldDefList {
3303 } 3374 }
3304} 3375}
3305impl TupleFieldDefList { 3376impl TupleFieldDefList {
3377 pub fn l_paren(&self) -> Option<LParen> {
3378 support::token(&self.syntax)
3379 }
3306 pub fn fields(&self) -> AstChildren<TupleFieldDef> { 3380 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3307 AstChildren::new(&self.syntax) 3381 support::children(&self.syntax)
3382 }
3383 pub fn r_paren(&self) -> Option<RParen> {
3384 support::token(&self.syntax)
3308 } 3385 }
3309} 3386}
3310#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3338,7 +3415,7 @@ impl ast::VisibilityOwner for TupleFieldDef {}
3338impl ast::AttrsOwner for TupleFieldDef {} 3415impl ast::AttrsOwner for TupleFieldDef {}
3339impl TupleFieldDef { 3416impl TupleFieldDef {
3340 pub fn type_ref(&self) -> Option<TypeRef> { 3417 pub fn type_ref(&self) -> Option<TypeRef> {
3341 AstChildren::new(&self.syntax).next() 3418 support::child(&self.syntax)
3342 } 3419 }
3343} 3420}
3344#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3374,8 +3451,11 @@ impl ast::TypeParamsOwner for EnumDef {}
3374impl ast::AttrsOwner for EnumDef {} 3451impl ast::AttrsOwner for EnumDef {}
3375impl ast::DocCommentsOwner for EnumDef {} 3452impl ast::DocCommentsOwner for EnumDef {}
3376impl EnumDef { 3453impl EnumDef {
3454 pub fn enum_kw(&self) -> Option<EnumKw> {
3455 support::token(&self.syntax)
3456 }
3377 pub fn variant_list(&self) -> Option<EnumVariantList> { 3457 pub fn variant_list(&self) -> Option<EnumVariantList> {
3378 AstChildren::new(&self.syntax).next() 3458 support::child(&self.syntax)
3379 } 3459 }
3380} 3460}
3381#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3461#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3406,8 +3486,14 @@ impl AstNode for EnumVariantList {
3406 } 3486 }
3407} 3487}
3408impl EnumVariantList { 3488impl EnumVariantList {
3489 pub fn l_curly(&self) -> Option<LCurly> {
3490 support::token(&self.syntax)
3491 }
3409 pub fn variants(&self) -> AstChildren<EnumVariant> { 3492 pub fn variants(&self) -> AstChildren<EnumVariant> {
3410 AstChildren::new(&self.syntax) 3493 support::children(&self.syntax)
3494 }
3495 pub fn r_curly(&self) -> Option<RCurly> {
3496 support::token(&self.syntax)
3411 } 3497 }
3412} 3498}
3413#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3499#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3437,12 +3523,19 @@ impl AstNode for EnumVariant {
3437 &self.syntax 3523 &self.syntax
3438 } 3524 }
3439} 3525}
3526impl ast::VisibilityOwner for EnumVariant {}
3440impl ast::NameOwner for EnumVariant {} 3527impl ast::NameOwner for EnumVariant {}
3441impl ast::DocCommentsOwner for EnumVariant {} 3528impl ast::DocCommentsOwner for EnumVariant {}
3442impl ast::AttrsOwner for EnumVariant {} 3529impl ast::AttrsOwner for EnumVariant {}
3443impl EnumVariant { 3530impl EnumVariant {
3531 pub fn field_def_list(&self) -> Option<FieldDefList> {
3532 support::child(&self.syntax)
3533 }
3534 pub fn eq(&self) -> Option<Eq> {
3535 support::token(&self.syntax)
3536 }
3444 pub fn expr(&self) -> Option<Expr> { 3537 pub fn expr(&self) -> Option<Expr> {
3445 AstChildren::new(&self.syntax).next() 3538 support::child(&self.syntax)
3446 } 3539 }
3447} 3540}
3448#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3541#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3479,8 +3572,17 @@ impl ast::DocCommentsOwner for TraitDef {}
3479impl ast::TypeParamsOwner for TraitDef {} 3572impl ast::TypeParamsOwner for TraitDef {}
3480impl ast::TypeBoundsOwner for TraitDef {} 3573impl ast::TypeBoundsOwner for TraitDef {}
3481impl TraitDef { 3574impl TraitDef {
3575 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3576 support::token(&self.syntax)
3577 }
3578 pub fn auto_kw(&self) -> Option<AutoKw> {
3579 support::token(&self.syntax)
3580 }
3581 pub fn trait_kw(&self) -> Option<TraitKw> {
3582 support::token(&self.syntax)
3583 }
3482 pub fn item_list(&self) -> Option<ItemList> { 3584 pub fn item_list(&self) -> Option<ItemList> {
3483 AstChildren::new(&self.syntax).next() 3585 support::child(&self.syntax)
3484 } 3586 }
3485} 3587}
3486#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3515,8 +3617,14 @@ impl ast::NameOwner for Module {}
3515impl ast::AttrsOwner for Module {} 3617impl ast::AttrsOwner for Module {}
3516impl ast::DocCommentsOwner for Module {} 3618impl ast::DocCommentsOwner for Module {}
3517impl Module { 3619impl Module {
3620 pub fn mod_kw(&self) -> Option<ModKw> {
3621 support::token(&self.syntax)
3622 }
3518 pub fn item_list(&self) -> Option<ItemList> { 3623 pub fn item_list(&self) -> Option<ItemList> {
3519 AstChildren::new(&self.syntax).next() 3624 support::child(&self.syntax)
3625 }
3626 pub fn semi(&self) -> Option<Semi> {
3627 support::token(&self.syntax)
3520 } 3628 }
3521} 3629}
3522#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3630#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3549,8 +3657,14 @@ impl AstNode for ItemList {
3549impl ast::FnDefOwner for ItemList {} 3657impl ast::FnDefOwner for ItemList {}
3550impl ast::ModuleItemOwner for ItemList {} 3658impl ast::ModuleItemOwner for ItemList {}
3551impl ItemList { 3659impl ItemList {
3660 pub fn l_curly(&self) -> Option<LCurly> {
3661 support::token(&self.syntax)
3662 }
3552 pub fn impl_items(&self) -> AstChildren<ImplItem> { 3663 pub fn impl_items(&self) -> AstChildren<ImplItem> {
3553 AstChildren::new(&self.syntax) 3664 support::children(&self.syntax)
3665 }
3666 pub fn r_curly(&self) -> Option<RCurly> {
3667 support::token(&self.syntax)
3554 } 3668 }
3555} 3669}
3556#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3670#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3587,8 +3701,20 @@ impl ast::AttrsOwner for ConstDef {}
3587impl ast::DocCommentsOwner for ConstDef {} 3701impl ast::DocCommentsOwner for ConstDef {}
3588impl ast::TypeAscriptionOwner for ConstDef {} 3702impl ast::TypeAscriptionOwner for ConstDef {}
3589impl ConstDef { 3703impl ConstDef {
3704 pub fn default_kw(&self) -> Option<DefaultKw> {
3705 support::token(&self.syntax)
3706 }
3707 pub fn const_kw(&self) -> Option<ConstKw> {
3708 support::token(&self.syntax)
3709 }
3710 pub fn eq(&self) -> Option<Eq> {
3711 support::token(&self.syntax)
3712 }
3590 pub fn body(&self) -> Option<Expr> { 3713 pub fn body(&self) -> Option<Expr> {
3591 AstChildren::new(&self.syntax).next() 3714 support::child(&self.syntax)
3715 }
3716 pub fn semi(&self) -> Option<Semi> {
3717 support::token(&self.syntax)
3592 } 3718 }
3593} 3719}
3594#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3720#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3625,8 +3751,20 @@ impl ast::AttrsOwner for StaticDef {}
3625impl ast::DocCommentsOwner for StaticDef {} 3751impl ast::DocCommentsOwner for StaticDef {}
3626impl ast::TypeAscriptionOwner for StaticDef {} 3752impl ast::TypeAscriptionOwner for StaticDef {}
3627impl StaticDef { 3753impl StaticDef {
3754 pub fn static_kw(&self) -> Option<StaticKw> {
3755 support::token(&self.syntax)
3756 }
3757 pub fn mut_kw(&self) -> Option<MutKw> {
3758 support::token(&self.syntax)
3759 }
3760 pub fn eq(&self) -> Option<Eq> {
3761 support::token(&self.syntax)
3762 }
3628 pub fn body(&self) -> Option<Expr> { 3763 pub fn body(&self) -> Option<Expr> {
3629 AstChildren::new(&self.syntax).next() 3764 support::child(&self.syntax)
3765 }
3766 pub fn semi(&self) -> Option<Semi> {
3767 support::token(&self.syntax)
3630 } 3768 }
3631} 3769}
3632#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3770#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3663,8 +3801,20 @@ impl ast::AttrsOwner for TypeAliasDef {}
3663impl ast::DocCommentsOwner for TypeAliasDef {} 3801impl ast::DocCommentsOwner for TypeAliasDef {}
3664impl ast::TypeBoundsOwner for TypeAliasDef {} 3802impl ast::TypeBoundsOwner for TypeAliasDef {}
3665impl TypeAliasDef { 3803impl TypeAliasDef {
3804 pub fn default_kw(&self) -> Option<DefaultKw> {
3805 support::token(&self.syntax)
3806 }
3807 pub fn type_kw(&self) -> Option<TypeKw> {
3808 support::token(&self.syntax)
3809 }
3810 pub fn eq(&self) -> Option<Eq> {
3811 support::token(&self.syntax)
3812 }
3666 pub fn type_ref(&self) -> Option<TypeRef> { 3813 pub fn type_ref(&self) -> Option<TypeRef> {
3667 AstChildren::new(&self.syntax).next() 3814 support::child(&self.syntax)
3815 }
3816 pub fn semi(&self) -> Option<Semi> {
3817 support::token(&self.syntax)
3668 } 3818 }
3669} 3819}
3670#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3697,8 +3847,26 @@ impl AstNode for ImplDef {
3697impl ast::TypeParamsOwner for ImplDef {} 3847impl ast::TypeParamsOwner for ImplDef {}
3698impl ast::AttrsOwner for ImplDef {} 3848impl ast::AttrsOwner for ImplDef {}
3699impl ImplDef { 3849impl ImplDef {
3850 pub fn default_kw(&self) -> Option<DefaultKw> {
3851 support::token(&self.syntax)
3852 }
3853 pub fn const_kw(&self) -> Option<ConstKw> {
3854 support::token(&self.syntax)
3855 }
3856 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
3857 support::token(&self.syntax)
3858 }
3859 pub fn impl_kw(&self) -> Option<ImplKw> {
3860 support::token(&self.syntax)
3861 }
3862 pub fn excl(&self) -> Option<Excl> {
3863 support::token(&self.syntax)
3864 }
3865 pub fn for_kw(&self) -> Option<ForKw> {
3866 support::token(&self.syntax)
3867 }
3700 pub fn item_list(&self) -> Option<ItemList> { 3868 pub fn item_list(&self) -> Option<ItemList> {
3701 AstChildren::new(&self.syntax).next() 3869 support::child(&self.syntax)
3702 } 3870 }
3703} 3871}
3704#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3872#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3729,8 +3897,14 @@ impl AstNode for ParenType {
3729 } 3897 }
3730} 3898}
3731impl ParenType { 3899impl ParenType {
3900 pub fn l_paren(&self) -> Option<LParen> {
3901 support::token(&self.syntax)
3902 }
3732 pub fn type_ref(&self) -> Option<TypeRef> { 3903 pub fn type_ref(&self) -> Option<TypeRef> {
3733 AstChildren::new(&self.syntax).next() 3904 support::child(&self.syntax)
3905 }
3906 pub fn r_paren(&self) -> Option<RParen> {
3907 support::token(&self.syntax)
3734 } 3908 }
3735} 3909}
3736#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3910#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3761,8 +3935,14 @@ impl AstNode for TupleType {
3761 } 3935 }
3762} 3936}
3763impl TupleType { 3937impl TupleType {
3938 pub fn l_paren(&self) -> Option<LParen> {
3939 support::token(&self.syntax)
3940 }
3764 pub fn fields(&self) -> AstChildren<TypeRef> { 3941 pub fn fields(&self) -> AstChildren<TypeRef> {
3765 AstChildren::new(&self.syntax) 3942 support::children(&self.syntax)
3943 }
3944 pub fn r_paren(&self) -> Option<RParen> {
3945 support::token(&self.syntax)
3766 } 3946 }
3767} 3947}
3768#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3792,7 +3972,11 @@ impl AstNode for NeverType {
3792 &self.syntax 3972 &self.syntax
3793 } 3973 }
3794} 3974}
3795impl NeverType {} 3975impl NeverType {
3976 pub fn excl(&self) -> Option<Excl> {
3977 support::token(&self.syntax)
3978 }
3979}
3796#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3980#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3797pub struct PathType { 3981pub struct PathType {
3798 pub(crate) syntax: SyntaxNode, 3982 pub(crate) syntax: SyntaxNode,
@@ -3822,7 +4006,7 @@ impl AstNode for PathType {
3822} 4006}
3823impl PathType { 4007impl PathType {
3824 pub fn path(&self) -> Option<Path> { 4008 pub fn path(&self) -> Option<Path> {
3825 AstChildren::new(&self.syntax).next() 4009 support::child(&self.syntax)
3826 } 4010 }
3827} 4011}
3828#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4012#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3853,8 +4037,14 @@ impl AstNode for PointerType {
3853 } 4037 }
3854} 4038}
3855impl PointerType { 4039impl PointerType {
4040 pub fn star(&self) -> Option<Star> {
4041 support::token(&self.syntax)
4042 }
4043 pub fn const_kw(&self) -> Option<ConstKw> {
4044 support::token(&self.syntax)
4045 }
3856 pub fn type_ref(&self) -> Option<TypeRef> { 4046 pub fn type_ref(&self) -> Option<TypeRef> {
3857 AstChildren::new(&self.syntax).next() 4047 support::child(&self.syntax)
3858 } 4048 }
3859} 4049}
3860#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4050#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3885,11 +4075,20 @@ impl AstNode for ArrayType {
3885 } 4075 }
3886} 4076}
3887impl ArrayType { 4077impl ArrayType {
4078 pub fn l_brack(&self) -> Option<LBrack> {
4079 support::token(&self.syntax)
4080 }
3888 pub fn type_ref(&self) -> Option<TypeRef> { 4081 pub fn type_ref(&self) -> Option<TypeRef> {
3889 AstChildren::new(&self.syntax).next() 4082 support::child(&self.syntax)
4083 }
4084 pub fn semi(&self) -> Option<Semi> {
4085 support::token(&self.syntax)
3890 } 4086 }
3891 pub fn expr(&self) -> Option<Expr> { 4087 pub fn expr(&self) -> Option<Expr> {
3892 AstChildren::new(&self.syntax).next() 4088 support::child(&self.syntax)
4089 }
4090 pub fn r_brack(&self) -> Option<RBrack> {
4091 support::token(&self.syntax)
3893 } 4092 }
3894} 4093}
3895#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4094#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3920,8 +4119,14 @@ impl AstNode for SliceType {
3920 } 4119 }
3921} 4120}
3922impl SliceType { 4121impl SliceType {
4122 pub fn l_brack(&self) -> Option<LBrack> {
4123 support::token(&self.syntax)
4124 }
3923 pub fn type_ref(&self) -> Option<TypeRef> { 4125 pub fn type_ref(&self) -> Option<TypeRef> {
3924 AstChildren::new(&self.syntax).next() 4126 support::child(&self.syntax)
4127 }
4128 pub fn r_brack(&self) -> Option<RBrack> {
4129 support::token(&self.syntax)
3925 } 4130 }
3926} 4131}
3927#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3952,8 +4157,17 @@ impl AstNode for ReferenceType {
3952 } 4157 }
3953} 4158}
3954impl ReferenceType { 4159impl ReferenceType {
4160 pub fn amp(&self) -> Option<Amp> {
4161 support::token(&self.syntax)
4162 }
4163 pub fn lifetime(&self) -> Option<Lifetime> {
4164 support::token(&self.syntax)
4165 }
4166 pub fn mut_kw(&self) -> Option<MutKw> {
4167 support::token(&self.syntax)
4168 }
3955 pub fn type_ref(&self) -> Option<TypeRef> { 4169 pub fn type_ref(&self) -> Option<TypeRef> {
3956 AstChildren::new(&self.syntax).next() 4170 support::child(&self.syntax)
3957 } 4171 }
3958} 4172}
3959#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3983,7 +4197,11 @@ impl AstNode for PlaceholderType {
3983 &self.syntax 4197 &self.syntax
3984 } 4198 }
3985} 4199}
3986impl PlaceholderType {} 4200impl PlaceholderType {
4201 pub fn underscore(&self) -> Option<Underscore> {
4202 support::token(&self.syntax)
4203 }
4204}
3987#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4205#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3988pub struct FnPointerType { 4206pub struct FnPointerType {
3989 pub(crate) syntax: SyntaxNode, 4207 pub(crate) syntax: SyntaxNode,
@@ -4012,11 +4230,20 @@ impl AstNode for FnPointerType {
4012 } 4230 }
4013} 4231}
4014impl FnPointerType { 4232impl FnPointerType {
4233 pub fn abi(&self) -> Option<Abi> {
4234 support::child(&self.syntax)
4235 }
4236 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
4237 support::token(&self.syntax)
4238 }
4239 pub fn fn_kw(&self) -> Option<FnKw> {
4240 support::token(&self.syntax)
4241 }
4015 pub fn param_list(&self) -> Option<ParamList> { 4242 pub fn param_list(&self) -> Option<ParamList> {
4016 AstChildren::new(&self.syntax).next() 4243 support::child(&self.syntax)
4017 } 4244 }
4018 pub fn ret_type(&self) -> Option<RetType> { 4245 pub fn ret_type(&self) -> Option<RetType> {
4019 AstChildren::new(&self.syntax).next() 4246 support::child(&self.syntax)
4020 } 4247 }
4021} 4248}
4022#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4249#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4047,8 +4274,14 @@ impl AstNode for ForType {
4047 } 4274 }
4048} 4275}
4049impl ForType { 4276impl ForType {
4277 pub fn for_kw(&self) -> Option<ForKw> {
4278 support::token(&self.syntax)
4279 }
4280 pub fn type_param_list(&self) -> Option<TypeParamList> {
4281 support::child(&self.syntax)
4282 }
4050 pub fn type_ref(&self) -> Option<TypeRef> { 4283 pub fn type_ref(&self) -> Option<TypeRef> {
4051 AstChildren::new(&self.syntax).next() 4284 support::child(&self.syntax)
4052 } 4285 }
4053} 4286}
4054#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4287#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4079,7 +4312,11 @@ impl AstNode for ImplTraitType {
4079 } 4312 }
4080} 4313}
4081impl ast::TypeBoundsOwner for ImplTraitType {} 4314impl ast::TypeBoundsOwner for ImplTraitType {}
4082impl ImplTraitType {} 4315impl ImplTraitType {
4316 pub fn impl_kw(&self) -> Option<ImplKw> {
4317 support::token(&self.syntax)
4318 }
4319}
4083#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4084pub struct DynTraitType { 4321pub struct DynTraitType {
4085 pub(crate) syntax: SyntaxNode, 4322 pub(crate) syntax: SyntaxNode,
@@ -4108,7 +4345,11 @@ impl AstNode for DynTraitType {
4108 } 4345 }
4109} 4346}
4110impl ast::TypeBoundsOwner for DynTraitType {} 4347impl ast::TypeBoundsOwner for DynTraitType {}
4111impl DynTraitType {} 4348impl DynTraitType {
4349 pub fn dyn_kw(&self) -> Option<DynKw> {
4350 support::token(&self.syntax)
4351 }
4352}
4112#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4353#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4113pub struct TupleExpr { 4354pub struct TupleExpr {
4114 pub(crate) syntax: SyntaxNode, 4355 pub(crate) syntax: SyntaxNode,
@@ -4136,9 +4377,16 @@ impl AstNode for TupleExpr {
4136 &self.syntax 4377 &self.syntax
4137 } 4378 }
4138} 4379}
4380impl ast::AttrsOwner for TupleExpr {}
4139impl TupleExpr { 4381impl TupleExpr {
4382 pub fn l_paren(&self) -> Option<LParen> {
4383 support::token(&self.syntax)
4384 }
4140 pub fn exprs(&self) -> AstChildren<Expr> { 4385 pub fn exprs(&self) -> AstChildren<Expr> {
4141 AstChildren::new(&self.syntax) 4386 support::children(&self.syntax)
4387 }
4388 pub fn r_paren(&self) -> Option<RParen> {
4389 support::token(&self.syntax)
4142 } 4390 }
4143} 4391}
4144#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4168,9 +4416,19 @@ impl AstNode for ArrayExpr {
4168 &self.syntax 4416 &self.syntax
4169 } 4417 }
4170} 4418}
4419impl ast::AttrsOwner for ArrayExpr {}
4171impl ArrayExpr { 4420impl ArrayExpr {
4421 pub fn l_brack(&self) -> Option<LBrack> {
4422 support::token(&self.syntax)
4423 }
4172 pub fn exprs(&self) -> AstChildren<Expr> { 4424 pub fn exprs(&self) -> AstChildren<Expr> {
4173 AstChildren::new(&self.syntax) 4425 support::children(&self.syntax)
4426 }
4427 pub fn semi(&self) -> Option<Semi> {
4428 support::token(&self.syntax)
4429 }
4430 pub fn r_brack(&self) -> Option<RBrack> {
4431 support::token(&self.syntax)
4174 } 4432 }
4175} 4433}
4176#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4200,9 +4458,16 @@ impl AstNode for ParenExpr {
4200 &self.syntax 4458 &self.syntax
4201 } 4459 }
4202} 4460}
4461impl ast::AttrsOwner for ParenExpr {}
4203impl ParenExpr { 4462impl ParenExpr {
4463 pub fn l_paren(&self) -> Option<LParen> {
4464 support::token(&self.syntax)
4465 }
4204 pub fn expr(&self) -> Option<Expr> { 4466 pub fn expr(&self) -> Option<Expr> {
4205 AstChildren::new(&self.syntax).next() 4467 support::child(&self.syntax)
4468 }
4469 pub fn r_paren(&self) -> Option<RParen> {
4470 support::token(&self.syntax)
4206 } 4471 }
4207} 4472}
4208#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4234,7 +4499,7 @@ impl AstNode for PathExpr {
4234} 4499}
4235impl PathExpr { 4500impl PathExpr {
4236 pub fn path(&self) -> Option<Path> { 4501 pub fn path(&self) -> Option<Path> {
4237 AstChildren::new(&self.syntax).next() 4502 support::child(&self.syntax)
4238 } 4503 }
4239} 4504}
4240#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4264,15 +4529,25 @@ impl AstNode for LambdaExpr {
4264 &self.syntax 4529 &self.syntax
4265 } 4530 }
4266} 4531}
4532impl ast::AttrsOwner for LambdaExpr {}
4267impl LambdaExpr { 4533impl LambdaExpr {
4534 pub fn static_kw(&self) -> Option<StaticKw> {
4535 support::token(&self.syntax)
4536 }
4537 pub fn async_kw(&self) -> Option<AsyncKw> {
4538 support::token(&self.syntax)
4539 }
4540 pub fn move_kw(&self) -> Option<MoveKw> {
4541 support::token(&self.syntax)
4542 }
4268 pub fn param_list(&self) -> Option<ParamList> { 4543 pub fn param_list(&self) -> Option<ParamList> {
4269 AstChildren::new(&self.syntax).next() 4544 support::child(&self.syntax)
4270 } 4545 }
4271 pub fn ret_type(&self) -> Option<RetType> { 4546 pub fn ret_type(&self) -> Option<RetType> {
4272 AstChildren::new(&self.syntax).next() 4547 support::child(&self.syntax)
4273 } 4548 }
4274 pub fn body(&self) -> Option<Expr> { 4549 pub fn body(&self) -> Option<Expr> {
4275 AstChildren::new(&self.syntax).next() 4550 support::child(&self.syntax)
4276 } 4551 }
4277} 4552}
4278#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4302,9 +4577,13 @@ impl AstNode for IfExpr {
4302 &self.syntax 4577 &self.syntax
4303 } 4578 }
4304} 4579}
4580impl ast::AttrsOwner for IfExpr {}
4305impl IfExpr { 4581impl IfExpr {
4582 pub fn if_kw(&self) -> Option<IfKw> {
4583 support::token(&self.syntax)
4584 }
4306 pub fn condition(&self) -> Option<Condition> { 4585 pub fn condition(&self) -> Option<Condition> {
4307 AstChildren::new(&self.syntax).next() 4586 support::child(&self.syntax)
4308 } 4587 }
4309} 4588}
4310#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4589#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4334,8 +4613,13 @@ impl AstNode for LoopExpr {
4334 &self.syntax 4613 &self.syntax
4335 } 4614 }
4336} 4615}
4616impl ast::AttrsOwner for LoopExpr {}
4337impl ast::LoopBodyOwner for LoopExpr {} 4617impl ast::LoopBodyOwner for LoopExpr {}
4338impl LoopExpr {} 4618impl LoopExpr {
4619 pub fn loop_kw(&self) -> Option<LoopKw> {
4620 support::token(&self.syntax)
4621 }
4622}
4339#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4340pub struct TryBlockExpr { 4624pub struct TryBlockExpr {
4341 pub(crate) syntax: SyntaxNode, 4625 pub(crate) syntax: SyntaxNode,
@@ -4363,9 +4647,13 @@ impl AstNode for TryBlockExpr {
4363 &self.syntax 4647 &self.syntax
4364 } 4648 }
4365} 4649}
4650impl ast::AttrsOwner for TryBlockExpr {}
4366impl TryBlockExpr { 4651impl TryBlockExpr {
4652 pub fn try_kw(&self) -> Option<TryKw> {
4653 support::token(&self.syntax)
4654 }
4367 pub fn body(&self) -> Option<BlockExpr> { 4655 pub fn body(&self) -> Option<BlockExpr> {
4368 AstChildren::new(&self.syntax).next() 4656 support::child(&self.syntax)
4369 } 4657 }
4370} 4658}
4371#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4659#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4395,13 +4683,20 @@ impl AstNode for ForExpr {
4395 &self.syntax 4683 &self.syntax
4396 } 4684 }
4397} 4685}
4686impl ast::AttrsOwner for ForExpr {}
4398impl ast::LoopBodyOwner for ForExpr {} 4687impl ast::LoopBodyOwner for ForExpr {}
4399impl ForExpr { 4688impl ForExpr {
4689 pub fn for_kw(&self) -> Option<ForKw> {
4690 support::token(&self.syntax)
4691 }
4400 pub fn pat(&self) -> Option<Pat> { 4692 pub fn pat(&self) -> Option<Pat> {
4401 AstChildren::new(&self.syntax).next() 4693 support::child(&self.syntax)
4694 }
4695 pub fn in_kw(&self) -> Option<InKw> {
4696 support::token(&self.syntax)
4402 } 4697 }
4403 pub fn iterable(&self) -> Option<Expr> { 4698 pub fn iterable(&self) -> Option<Expr> {
4404 AstChildren::new(&self.syntax).next() 4699 support::child(&self.syntax)
4405 } 4700 }
4406} 4701}
4407#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4702#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4431,10 +4726,14 @@ impl AstNode for WhileExpr {
4431 &self.syntax 4726 &self.syntax
4432 } 4727 }
4433} 4728}
4729impl ast::AttrsOwner for WhileExpr {}
4434impl ast::LoopBodyOwner for WhileExpr {} 4730impl ast::LoopBodyOwner for WhileExpr {}
4435impl WhileExpr { 4731impl WhileExpr {
4732 pub fn while_kw(&self) -> Option<WhileKw> {
4733 support::token(&self.syntax)
4734 }
4436 pub fn condition(&self) -> Option<Condition> { 4735 pub fn condition(&self) -> Option<Condition> {
4437 AstChildren::new(&self.syntax).next() 4736 support::child(&self.syntax)
4438 } 4737 }
4439} 4738}
4440#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4739#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4464,7 +4763,15 @@ impl AstNode for ContinueExpr {
4464 &self.syntax 4763 &self.syntax
4465 } 4764 }
4466} 4765}
4467impl ContinueExpr {} 4766impl ast::AttrsOwner for ContinueExpr {}
4767impl ContinueExpr {
4768 pub fn continue_kw(&self) -> Option<ContinueKw> {
4769 support::token(&self.syntax)
4770 }
4771 pub fn lifetime(&self) -> Option<Lifetime> {
4772 support::token(&self.syntax)
4773 }
4774}
4468#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4775#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4469pub struct BreakExpr { 4776pub struct BreakExpr {
4470 pub(crate) syntax: SyntaxNode, 4777 pub(crate) syntax: SyntaxNode,
@@ -4492,9 +4799,16 @@ impl AstNode for BreakExpr {
4492 &self.syntax 4799 &self.syntax
4493 } 4800 }
4494} 4801}
4802impl ast::AttrsOwner for BreakExpr {}
4495impl BreakExpr { 4803impl BreakExpr {
4804 pub fn break_kw(&self) -> Option<BreakKw> {
4805 support::token(&self.syntax)
4806 }
4807 pub fn lifetime(&self) -> Option<Lifetime> {
4808 support::token(&self.syntax)
4809 }
4496 pub fn expr(&self) -> Option<Expr> { 4810 pub fn expr(&self) -> Option<Expr> {
4497 AstChildren::new(&self.syntax).next() 4811 support::child(&self.syntax)
4498 } 4812 }
4499} 4813}
4500#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4814#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4524,7 +4838,11 @@ impl AstNode for Label {
4524 &self.syntax 4838 &self.syntax
4525 } 4839 }
4526} 4840}
4527impl Label {} 4841impl Label {
4842 pub fn lifetime(&self) -> Option<Lifetime> {
4843 support::token(&self.syntax)
4844 }
4845}
4528#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4846#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4529pub struct BlockExpr { 4847pub struct BlockExpr {
4530 pub(crate) syntax: SyntaxNode, 4848 pub(crate) syntax: SyntaxNode,
@@ -4552,9 +4870,16 @@ impl AstNode for BlockExpr {
4552 &self.syntax 4870 &self.syntax
4553 } 4871 }
4554} 4872}
4873impl ast::AttrsOwner for BlockExpr {}
4555impl BlockExpr { 4874impl BlockExpr {
4875 pub fn label(&self) -> Option<Label> {
4876 support::child(&self.syntax)
4877 }
4878 pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
4879 support::token(&self.syntax)
4880 }
4556 pub fn block(&self) -> Option<Block> { 4881 pub fn block(&self) -> Option<Block> {
4557 AstChildren::new(&self.syntax).next() 4882 support::child(&self.syntax)
4558 } 4883 }
4559} 4884}
4560#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4885#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4584,9 +4909,10 @@ impl AstNode for ReturnExpr {
4584 &self.syntax 4909 &self.syntax
4585 } 4910 }
4586} 4911}
4912impl ast::AttrsOwner for ReturnExpr {}
4587impl ReturnExpr { 4913impl ReturnExpr {
4588 pub fn expr(&self) -> Option<Expr> { 4914 pub fn expr(&self) -> Option<Expr> {
4589 AstChildren::new(&self.syntax).next() 4915 support::child(&self.syntax)
4590 } 4916 }
4591} 4917}
4592#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4918#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4619,7 +4945,7 @@ impl AstNode for CallExpr {
4619impl ast::ArgListOwner for CallExpr {} 4945impl ast::ArgListOwner for CallExpr {}
4620impl CallExpr { 4946impl CallExpr {
4621 pub fn expr(&self) -> Option<Expr> { 4947 pub fn expr(&self) -> Option<Expr> {
4622 AstChildren::new(&self.syntax).next() 4948 support::child(&self.syntax)
4623 } 4949 }
4624} 4950}
4625#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4951#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4649,16 +4975,20 @@ impl AstNode for MethodCallExpr {
4649 &self.syntax 4975 &self.syntax
4650 } 4976 }
4651} 4977}
4978impl ast::AttrsOwner for MethodCallExpr {}
4652impl ast::ArgListOwner for MethodCallExpr {} 4979impl ast::ArgListOwner for MethodCallExpr {}
4653impl MethodCallExpr { 4980impl MethodCallExpr {
4654 pub fn expr(&self) -> Option<Expr> { 4981 pub fn expr(&self) -> Option<Expr> {
4655 AstChildren::new(&self.syntax).next() 4982 support::child(&self.syntax)
4983 }
4984 pub fn dot(&self) -> Option<Dot> {
4985 support::token(&self.syntax)
4656 } 4986 }
4657 pub fn name_ref(&self) -> Option<NameRef> { 4987 pub fn name_ref(&self) -> Option<NameRef> {
4658 AstChildren::new(&self.syntax).next() 4988 support::child(&self.syntax)
4659 } 4989 }
4660 pub fn type_arg_list(&self) -> Option<TypeArgList> { 4990 pub fn type_arg_list(&self) -> Option<TypeArgList> {
4661 AstChildren::new(&self.syntax).next() 4991 support::child(&self.syntax)
4662 } 4992 }
4663} 4993}
4664#[derive(Debug, Clone, PartialEq, Eq, Hash)] 4994#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4688,7 +5018,15 @@ impl AstNode for IndexExpr {
4688 &self.syntax 5018 &self.syntax
4689 } 5019 }
4690} 5020}
4691impl IndexExpr {} 5021impl ast::AttrsOwner for IndexExpr {}
5022impl IndexExpr {
5023 pub fn l_brack(&self) -> Option<LBrack> {
5024 support::token(&self.syntax)
5025 }
5026 pub fn r_brack(&self) -> Option<RBrack> {
5027 support::token(&self.syntax)
5028 }
5029}
4692#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4693pub struct FieldExpr { 5031pub struct FieldExpr {
4694 pub(crate) syntax: SyntaxNode, 5032 pub(crate) syntax: SyntaxNode,
@@ -4716,12 +5054,16 @@ impl AstNode for FieldExpr {
4716 &self.syntax 5054 &self.syntax
4717 } 5055 }
4718} 5056}
5057impl ast::AttrsOwner for FieldExpr {}
4719impl FieldExpr { 5058impl FieldExpr {
4720 pub fn expr(&self) -> Option<Expr> { 5059 pub fn expr(&self) -> Option<Expr> {
4721 AstChildren::new(&self.syntax).next() 5060 support::child(&self.syntax)
5061 }
5062 pub fn dot(&self) -> Option<Dot> {
5063 support::token(&self.syntax)
4722 } 5064 }
4723 pub fn name_ref(&self) -> Option<NameRef> { 5065 pub fn name_ref(&self) -> Option<NameRef> {
4724 AstChildren::new(&self.syntax).next() 5066 support::child(&self.syntax)
4725 } 5067 }
4726} 5068}
4727#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5069#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4751,9 +5093,16 @@ impl AstNode for AwaitExpr {
4751 &self.syntax 5093 &self.syntax
4752 } 5094 }
4753} 5095}
5096impl ast::AttrsOwner for AwaitExpr {}
4754impl AwaitExpr { 5097impl AwaitExpr {
4755 pub fn expr(&self) -> Option<Expr> { 5098 pub fn expr(&self) -> Option<Expr> {
4756 AstChildren::new(&self.syntax).next() 5099 support::child(&self.syntax)
5100 }
5101 pub fn dot(&self) -> Option<Dot> {
5102 support::token(&self.syntax)
5103 }
5104 pub fn await_kw(&self) -> Option<AwaitKw> {
5105 support::token(&self.syntax)
4757 } 5106 }
4758} 5107}
4759#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4783,9 +5132,13 @@ impl AstNode for TryExpr {
4783 &self.syntax 5132 &self.syntax
4784 } 5133 }
4785} 5134}
5135impl ast::AttrsOwner for TryExpr {}
4786impl TryExpr { 5136impl TryExpr {
5137 pub fn try_kw(&self) -> Option<TryKw> {
5138 support::token(&self.syntax)
5139 }
4787 pub fn expr(&self) -> Option<Expr> { 5140 pub fn expr(&self) -> Option<Expr> {
4788 AstChildren::new(&self.syntax).next() 5141 support::child(&self.syntax)
4789 } 5142 }
4790} 5143}
4791#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4815,12 +5168,16 @@ impl AstNode for CastExpr {
4815 &self.syntax 5168 &self.syntax
4816 } 5169 }
4817} 5170}
5171impl ast::AttrsOwner for CastExpr {}
4818impl CastExpr { 5172impl CastExpr {
4819 pub fn expr(&self) -> Option<Expr> { 5173 pub fn expr(&self) -> Option<Expr> {
4820 AstChildren::new(&self.syntax).next() 5174 support::child(&self.syntax)
5175 }
5176 pub fn as_kw(&self) -> Option<AsKw> {
5177 support::token(&self.syntax)
4821 } 5178 }
4822 pub fn type_ref(&self) -> Option<TypeRef> { 5179 pub fn type_ref(&self) -> Option<TypeRef> {
4823 AstChildren::new(&self.syntax).next() 5180 support::child(&self.syntax)
4824 } 5181 }
4825} 5182}
4826#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4850,9 +5207,19 @@ impl AstNode for RefExpr {
4850 &self.syntax 5207 &self.syntax
4851 } 5208 }
4852} 5209}
5210impl ast::AttrsOwner for RefExpr {}
4853impl RefExpr { 5211impl RefExpr {
5212 pub fn amp(&self) -> Option<Amp> {
5213 support::token(&self.syntax)
5214 }
5215 pub fn raw_kw(&self) -> Option<RawKw> {
5216 support::token(&self.syntax)
5217 }
5218 pub fn mut_kw(&self) -> Option<MutKw> {
5219 support::token(&self.syntax)
5220 }
4854 pub fn expr(&self) -> Option<Expr> { 5221 pub fn expr(&self) -> Option<Expr> {
4855 AstChildren::new(&self.syntax).next() 5222 support::child(&self.syntax)
4856 } 5223 }
4857} 5224}
4858#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5225#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4882,9 +5249,13 @@ impl AstNode for PrefixExpr {
4882 &self.syntax 5249 &self.syntax
4883 } 5250 }
4884} 5251}
5252impl ast::AttrsOwner for PrefixExpr {}
4885impl PrefixExpr { 5253impl PrefixExpr {
5254 pub fn prefix_op(&self) -> Option<PrefixOp> {
5255 support::token(&self.syntax)
5256 }
4886 pub fn expr(&self) -> Option<Expr> { 5257 pub fn expr(&self) -> Option<Expr> {
4887 AstChildren::new(&self.syntax).next() 5258 support::child(&self.syntax)
4888 } 5259 }
4889} 5260}
4890#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5261#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4914,9 +5285,13 @@ impl AstNode for BoxExpr {
4914 &self.syntax 5285 &self.syntax
4915 } 5286 }
4916} 5287}
5288impl ast::AttrsOwner for BoxExpr {}
4917impl BoxExpr { 5289impl BoxExpr {
5290 pub fn box_kw(&self) -> Option<BoxKw> {
5291 support::token(&self.syntax)
5292 }
4918 pub fn expr(&self) -> Option<Expr> { 5293 pub fn expr(&self) -> Option<Expr> {
4919 AstChildren::new(&self.syntax).next() 5294 support::child(&self.syntax)
4920 } 5295 }
4921} 5296}
4922#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5297#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -4946,7 +5321,12 @@ impl AstNode for RangeExpr {
4946 &self.syntax 5321 &self.syntax
4947 } 5322 }
4948} 5323}
4949impl RangeExpr {} 5324impl ast::AttrsOwner for RangeExpr {}
5325impl RangeExpr {
5326 pub fn range_op(&self) -> Option<RangeOp> {
5327 support::token(&self.syntax)
5328 }
5329}
4950#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4951pub struct BinExpr { 5331pub struct BinExpr {
4952 pub(crate) syntax: SyntaxNode, 5332 pub(crate) syntax: SyntaxNode,
@@ -4974,7 +5354,12 @@ impl AstNode for BinExpr {
4974 &self.syntax 5354 &self.syntax
4975 } 5355 }
4976} 5356}
4977impl BinExpr {} 5357impl ast::AttrsOwner for BinExpr {}
5358impl BinExpr {
5359 pub fn bin_op(&self) -> Option<BinOp> {
5360 support::token(&self.syntax)
5361 }
5362}
4978#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5363#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4979pub struct Literal { 5364pub struct Literal {
4980 pub(crate) syntax: SyntaxNode, 5365 pub(crate) syntax: SyntaxNode,
@@ -5002,7 +5387,11 @@ impl AstNode for Literal {
5002 &self.syntax 5387 &self.syntax
5003 } 5388 }
5004} 5389}
5005impl Literal {} 5390impl Literal {
5391 pub fn literal_token(&self) -> Option<LiteralToken> {
5392 support::token(&self.syntax)
5393 }
5394}
5006#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5395#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5007pub struct MatchExpr { 5396pub struct MatchExpr {
5008 pub(crate) syntax: SyntaxNode, 5397 pub(crate) syntax: SyntaxNode,
@@ -5030,12 +5419,16 @@ impl AstNode for MatchExpr {
5030 &self.syntax 5419 &self.syntax
5031 } 5420 }
5032} 5421}
5422impl ast::AttrsOwner for MatchExpr {}
5033impl MatchExpr { 5423impl MatchExpr {
5424 pub fn match_kw(&self) -> Option<MatchKw> {
5425 support::token(&self.syntax)
5426 }
5034 pub fn expr(&self) -> Option<Expr> { 5427 pub fn expr(&self) -> Option<Expr> {
5035 AstChildren::new(&self.syntax).next() 5428 support::child(&self.syntax)
5036 } 5429 }
5037 pub fn match_arm_list(&self) -> Option<MatchArmList> { 5430 pub fn match_arm_list(&self) -> Option<MatchArmList> {
5038 AstChildren::new(&self.syntax).next() 5431 support::child(&self.syntax)
5039 } 5432 }
5040} 5433}
5041#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5067,8 +5460,14 @@ impl AstNode for MatchArmList {
5067} 5460}
5068impl ast::AttrsOwner for MatchArmList {} 5461impl ast::AttrsOwner for MatchArmList {}
5069impl MatchArmList { 5462impl MatchArmList {
5463 pub fn l_curly(&self) -> Option<LCurly> {
5464 support::token(&self.syntax)
5465 }
5070 pub fn arms(&self) -> AstChildren<MatchArm> { 5466 pub fn arms(&self) -> AstChildren<MatchArm> {
5071 AstChildren::new(&self.syntax) 5467 support::children(&self.syntax)
5468 }
5469 pub fn r_curly(&self) -> Option<RCurly> {
5470 support::token(&self.syntax)
5072 } 5471 }
5073} 5472}
5074#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5101,13 +5500,16 @@ impl AstNode for MatchArm {
5101impl ast::AttrsOwner for MatchArm {} 5500impl ast::AttrsOwner for MatchArm {}
5102impl MatchArm { 5501impl MatchArm {
5103 pub fn pat(&self) -> Option<Pat> { 5502 pub fn pat(&self) -> Option<Pat> {
5104 AstChildren::new(&self.syntax).next() 5503 support::child(&self.syntax)
5105 } 5504 }
5106 pub fn guard(&self) -> Option<MatchGuard> { 5505 pub fn guard(&self) -> Option<MatchGuard> {
5107 AstChildren::new(&self.syntax).next() 5506 support::child(&self.syntax)
5507 }
5508 pub fn fat_arrow(&self) -> Option<FatArrow> {
5509 support::token(&self.syntax)
5108 } 5510 }
5109 pub fn expr(&self) -> Option<Expr> { 5511 pub fn expr(&self) -> Option<Expr> {
5110 AstChildren::new(&self.syntax).next() 5512 support::child(&self.syntax)
5111 } 5513 }
5112} 5514}
5113#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5515#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5138,8 +5540,11 @@ impl AstNode for MatchGuard {
5138 } 5540 }
5139} 5541}
5140impl MatchGuard { 5542impl MatchGuard {
5543 pub fn if_kw(&self) -> Option<IfKw> {
5544 support::token(&self.syntax)
5545 }
5141 pub fn expr(&self) -> Option<Expr> { 5546 pub fn expr(&self) -> Option<Expr> {
5142 AstChildren::new(&self.syntax).next() 5547 support::child(&self.syntax)
5143 } 5548 }
5144} 5549}
5145#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5171,10 +5576,10 @@ impl AstNode for RecordLit {
5171} 5576}
5172impl RecordLit { 5577impl RecordLit {
5173 pub fn path(&self) -> Option<Path> { 5578 pub fn path(&self) -> Option<Path> {
5174 AstChildren::new(&self.syntax).next() 5579 support::child(&self.syntax)
5175 } 5580 }
5176 pub fn record_field_list(&self) -> Option<RecordFieldList> { 5581 pub fn record_field_list(&self) -> Option<RecordFieldList> {
5177 AstChildren::new(&self.syntax).next() 5582 support::child(&self.syntax)
5178 } 5583 }
5179} 5584}
5180#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5585#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5205,11 +5610,20 @@ impl AstNode for RecordFieldList {
5205 } 5610 }
5206} 5611}
5207impl RecordFieldList { 5612impl RecordFieldList {
5613 pub fn l_curly(&self) -> Option<LCurly> {
5614 support::token(&self.syntax)
5615 }
5208 pub fn fields(&self) -> AstChildren<RecordField> { 5616 pub fn fields(&self) -> AstChildren<RecordField> {
5209 AstChildren::new(&self.syntax) 5617 support::children(&self.syntax)
5618 }
5619 pub fn dotdot(&self) -> Option<Dotdot> {
5620 support::token(&self.syntax)
5210 } 5621 }
5211 pub fn spread(&self) -> Option<Expr> { 5622 pub fn spread(&self) -> Option<Expr> {
5212 AstChildren::new(&self.syntax).next() 5623 support::child(&self.syntax)
5624 }
5625 pub fn r_curly(&self) -> Option<RCurly> {
5626 support::token(&self.syntax)
5213 } 5627 }
5214} 5628}
5215#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5239,12 +5653,16 @@ impl AstNode for RecordField {
5239 &self.syntax 5653 &self.syntax
5240 } 5654 }
5241} 5655}
5656impl ast::AttrsOwner for RecordField {}
5242impl RecordField { 5657impl RecordField {
5243 pub fn name_ref(&self) -> Option<NameRef> { 5658 pub fn name_ref(&self) -> Option<NameRef> {
5244 AstChildren::new(&self.syntax).next() 5659 support::child(&self.syntax)
5660 }
5661 pub fn colon(&self) -> Option<Colon> {
5662 support::token(&self.syntax)
5245 } 5663 }
5246 pub fn expr(&self) -> Option<Expr> { 5664 pub fn expr(&self) -> Option<Expr> {
5247 AstChildren::new(&self.syntax).next() 5665 support::child(&self.syntax)
5248 } 5666 }
5249} 5667}
5250#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5276,7 +5694,7 @@ impl AstNode for OrPat {
5276} 5694}
5277impl OrPat { 5695impl OrPat {
5278 pub fn pats(&self) -> AstChildren<Pat> { 5696 pub fn pats(&self) -> AstChildren<Pat> {
5279 AstChildren::new(&self.syntax) 5697 support::children(&self.syntax)
5280 } 5698 }
5281} 5699}
5282#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5307,8 +5725,14 @@ impl AstNode for ParenPat {
5307 } 5725 }
5308} 5726}
5309impl ParenPat { 5727impl ParenPat {
5728 pub fn l_paren(&self) -> Option<LParen> {
5729 support::token(&self.syntax)
5730 }
5310 pub fn pat(&self) -> Option<Pat> { 5731 pub fn pat(&self) -> Option<Pat> {
5311 AstChildren::new(&self.syntax).next() 5732 support::child(&self.syntax)
5733 }
5734 pub fn r_paren(&self) -> Option<RParen> {
5735 support::token(&self.syntax)
5312 } 5736 }
5313} 5737}
5314#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5738#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5339,8 +5763,14 @@ impl AstNode for RefPat {
5339 } 5763 }
5340} 5764}
5341impl RefPat { 5765impl RefPat {
5766 pub fn amp(&self) -> Option<Amp> {
5767 support::token(&self.syntax)
5768 }
5769 pub fn mut_kw(&self) -> Option<MutKw> {
5770 support::token(&self.syntax)
5771 }
5342 pub fn pat(&self) -> Option<Pat> { 5772 pub fn pat(&self) -> Option<Pat> {
5343 AstChildren::new(&self.syntax).next() 5773 support::child(&self.syntax)
5344 } 5774 }
5345} 5775}
5346#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5776#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5371,8 +5801,11 @@ impl AstNode for BoxPat {
5371 } 5801 }
5372} 5802}
5373impl BoxPat { 5803impl BoxPat {
5804 pub fn box_kw(&self) -> Option<BoxKw> {
5805 support::token(&self.syntax)
5806 }
5374 pub fn pat(&self) -> Option<Pat> { 5807 pub fn pat(&self) -> Option<Pat> {
5375 AstChildren::new(&self.syntax).next() 5808 support::child(&self.syntax)
5376 } 5809 }
5377} 5810}
5378#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5811#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5402,10 +5835,17 @@ impl AstNode for BindPat {
5402 &self.syntax 5835 &self.syntax
5403 } 5836 }
5404} 5837}
5838impl ast::AttrsOwner for BindPat {}
5405impl ast::NameOwner for BindPat {} 5839impl ast::NameOwner for BindPat {}
5406impl BindPat { 5840impl BindPat {
5841 pub fn ref_kw(&self) -> Option<RefKw> {
5842 support::token(&self.syntax)
5843 }
5844 pub fn mut_kw(&self) -> Option<MutKw> {
5845 support::token(&self.syntax)
5846 }
5407 pub fn pat(&self) -> Option<Pat> { 5847 pub fn pat(&self) -> Option<Pat> {
5408 AstChildren::new(&self.syntax).next() 5848 support::child(&self.syntax)
5409 } 5849 }
5410} 5850}
5411#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5851#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5435,7 +5875,11 @@ impl AstNode for PlaceholderPat {
5435 &self.syntax 5875 &self.syntax
5436 } 5876 }
5437} 5877}
5438impl PlaceholderPat {} 5878impl PlaceholderPat {
5879 pub fn underscore(&self) -> Option<Underscore> {
5880 support::token(&self.syntax)
5881 }
5882}
5439#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5883#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5440pub struct DotDotPat { 5884pub struct DotDotPat {
5441 pub(crate) syntax: SyntaxNode, 5885 pub(crate) syntax: SyntaxNode,
@@ -5463,7 +5907,11 @@ impl AstNode for DotDotPat {
5463 &self.syntax 5907 &self.syntax
5464 } 5908 }
5465} 5909}
5466impl DotDotPat {} 5910impl DotDotPat {
5911 pub fn dotdot(&self) -> Option<Dotdot> {
5912 support::token(&self.syntax)
5913 }
5914}
5467#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5915#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5468pub struct PathPat { 5916pub struct PathPat {
5469 pub(crate) syntax: SyntaxNode, 5917 pub(crate) syntax: SyntaxNode,
@@ -5493,7 +5941,7 @@ impl AstNode for PathPat {
5493} 5941}
5494impl PathPat { 5942impl PathPat {
5495 pub fn path(&self) -> Option<Path> { 5943 pub fn path(&self) -> Option<Path> {
5496 AstChildren::new(&self.syntax).next() 5944 support::child(&self.syntax)
5497 } 5945 }
5498} 5946}
5499#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5524,8 +5972,14 @@ impl AstNode for SlicePat {
5524 } 5972 }
5525} 5973}
5526impl SlicePat { 5974impl SlicePat {
5975 pub fn l_brack(&self) -> Option<LBrack> {
5976 support::token(&self.syntax)
5977 }
5527 pub fn args(&self) -> AstChildren<Pat> { 5978 pub fn args(&self) -> AstChildren<Pat> {
5528 AstChildren::new(&self.syntax) 5979 support::children(&self.syntax)
5980 }
5981 pub fn r_brack(&self) -> Option<RBrack> {
5982 support::token(&self.syntax)
5529 } 5983 }
5530} 5984}
5531#[derive(Debug, Clone, PartialEq, Eq, Hash)] 5985#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5555,7 +6009,11 @@ impl AstNode for RangePat {
5555 &self.syntax 6009 &self.syntax
5556 } 6010 }
5557} 6011}
5558impl RangePat {} 6012impl RangePat {
6013 pub fn range_separator(&self) -> Option<RangeSeparator> {
6014 support::token(&self.syntax)
6015 }
6016}
5559#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6017#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5560pub struct LiteralPat { 6018pub struct LiteralPat {
5561 pub(crate) syntax: SyntaxNode, 6019 pub(crate) syntax: SyntaxNode,
@@ -5585,7 +6043,7 @@ impl AstNode for LiteralPat {
5585} 6043}
5586impl LiteralPat { 6044impl LiteralPat {
5587 pub fn literal(&self) -> Option<Literal> { 6045 pub fn literal(&self) -> Option<Literal> {
5588 AstChildren::new(&self.syntax).next() 6046 support::child(&self.syntax)
5589 } 6047 }
5590} 6048}
5591#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6049#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5617,7 +6075,7 @@ impl AstNode for MacroPat {
5617} 6075}
5618impl MacroPat { 6076impl MacroPat {
5619 pub fn macro_call(&self) -> Option<MacroCall> { 6077 pub fn macro_call(&self) -> Option<MacroCall> {
5620 AstChildren::new(&self.syntax).next() 6078 support::child(&self.syntax)
5621 } 6079 }
5622} 6080}
5623#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5649,10 +6107,10 @@ impl AstNode for RecordPat {
5649} 6107}
5650impl RecordPat { 6108impl RecordPat {
5651 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { 6109 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
5652 AstChildren::new(&self.syntax).next() 6110 support::child(&self.syntax)
5653 } 6111 }
5654 pub fn path(&self) -> Option<Path> { 6112 pub fn path(&self) -> Option<Path> {
5655 AstChildren::new(&self.syntax).next() 6113 support::child(&self.syntax)
5656 } 6114 }
5657} 6115}
5658#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5683,11 +6141,23 @@ impl AstNode for RecordFieldPatList {
5683 } 6141 }
5684} 6142}
5685impl RecordFieldPatList { 6143impl RecordFieldPatList {
6144 pub fn l_curly(&self) -> Option<LCurly> {
6145 support::token(&self.syntax)
6146 }
6147 pub fn pats(&self) -> AstChildren<RecordInnerPat> {
6148 support::children(&self.syntax)
6149 }
5686 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { 6150 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
5687 AstChildren::new(&self.syntax) 6151 support::children(&self.syntax)
5688 } 6152 }
5689 pub fn bind_pats(&self) -> AstChildren<BindPat> { 6153 pub fn bind_pats(&self) -> AstChildren<BindPat> {
5690 AstChildren::new(&self.syntax) 6154 support::children(&self.syntax)
6155 }
6156 pub fn dotdot(&self) -> Option<Dotdot> {
6157 support::token(&self.syntax)
6158 }
6159 pub fn r_curly(&self) -> Option<RCurly> {
6160 support::token(&self.syntax)
5691 } 6161 }
5692} 6162}
5693#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6163#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5717,10 +6187,14 @@ impl AstNode for RecordFieldPat {
5717 &self.syntax 6187 &self.syntax
5718 } 6188 }
5719} 6189}
6190impl ast::AttrsOwner for RecordFieldPat {}
5720impl ast::NameOwner for RecordFieldPat {} 6191impl ast::NameOwner for RecordFieldPat {}
5721impl RecordFieldPat { 6192impl RecordFieldPat {
6193 pub fn colon(&self) -> Option<Colon> {
6194 support::token(&self.syntax)
6195 }
5722 pub fn pat(&self) -> Option<Pat> { 6196 pub fn pat(&self) -> Option<Pat> {
5723 AstChildren::new(&self.syntax).next() 6197 support::child(&self.syntax)
5724 } 6198 }
5725} 6199}
5726#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5752,10 +6226,16 @@ impl AstNode for TupleStructPat {
5752} 6226}
5753impl TupleStructPat { 6227impl TupleStructPat {
5754 pub fn path(&self) -> Option<Path> { 6228 pub fn path(&self) -> Option<Path> {
5755 AstChildren::new(&self.syntax).next() 6229 support::child(&self.syntax)
6230 }
6231 pub fn l_paren(&self) -> Option<LParen> {
6232 support::token(&self.syntax)
5756 } 6233 }
5757 pub fn args(&self) -> AstChildren<Pat> { 6234 pub fn args(&self) -> AstChildren<Pat> {
5758 AstChildren::new(&self.syntax) 6235 support::children(&self.syntax)
6236 }
6237 pub fn r_paren(&self) -> Option<RParen> {
6238 support::token(&self.syntax)
5759 } 6239 }
5760} 6240}
5761#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6241#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5786,8 +6266,14 @@ impl AstNode for TuplePat {
5786 } 6266 }
5787} 6267}
5788impl TuplePat { 6268impl TuplePat {
6269 pub fn l_paren(&self) -> Option<LParen> {
6270 support::token(&self.syntax)
6271 }
5789 pub fn args(&self) -> AstChildren<Pat> { 6272 pub fn args(&self) -> AstChildren<Pat> {
5790 AstChildren::new(&self.syntax) 6273 support::children(&self.syntax)
6274 }
6275 pub fn r_paren(&self) -> Option<RParen> {
6276 support::token(&self.syntax)
5791 } 6277 }
5792} 6278}
5793#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6279#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5817,7 +6303,20 @@ impl AstNode for Visibility {
5817 &self.syntax 6303 &self.syntax
5818 } 6304 }
5819} 6305}
5820impl Visibility {} 6306impl Visibility {
6307 pub fn pub_kw(&self) -> Option<PubKw> {
6308 support::token(&self.syntax)
6309 }
6310 pub fn super_kw(&self) -> Option<SuperKw> {
6311 support::token(&self.syntax)
6312 }
6313 pub fn self_kw(&self) -> Option<SelfKw> {
6314 support::token(&self.syntax)
6315 }
6316 pub fn crate_kw(&self) -> Option<CrateKw> {
6317 support::token(&self.syntax)
6318 }
6319}
5821#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5822pub struct Name { 6321pub struct Name {
5823 pub(crate) syntax: SyntaxNode, 6322 pub(crate) syntax: SyntaxNode,
@@ -5845,7 +6344,11 @@ impl AstNode for Name {
5845 &self.syntax 6344 &self.syntax
5846 } 6345 }
5847} 6346}
5848impl Name {} 6347impl Name {
6348 pub fn ident(&self) -> Option<Ident> {
6349 support::token(&self.syntax)
6350 }
6351}
5849#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6352#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5850pub struct NameRef { 6353pub struct NameRef {
5851 pub(crate) syntax: SyntaxNode, 6354 pub(crate) syntax: SyntaxNode,
@@ -5873,7 +6376,11 @@ impl AstNode for NameRef {
5873 &self.syntax 6376 &self.syntax
5874 } 6377 }
5875} 6378}
5876impl NameRef {} 6379impl NameRef {
6380 pub fn name_ref_token(&self) -> Option<NameRefToken> {
6381 support::token(&self.syntax)
6382 }
6383}
5877#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6384#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5878pub struct MacroCall { 6385pub struct MacroCall {
5879 pub(crate) syntax: SyntaxNode, 6386 pub(crate) syntax: SyntaxNode,
@@ -5905,11 +6412,17 @@ impl ast::NameOwner for MacroCall {}
5905impl ast::AttrsOwner for MacroCall {} 6412impl ast::AttrsOwner for MacroCall {}
5906impl ast::DocCommentsOwner for MacroCall {} 6413impl ast::DocCommentsOwner for MacroCall {}
5907impl MacroCall { 6414impl MacroCall {
6415 pub fn path(&self) -> Option<Path> {
6416 support::child(&self.syntax)
6417 }
6418 pub fn excl(&self) -> Option<Excl> {
6419 support::token(&self.syntax)
6420 }
5908 pub fn token_tree(&self) -> Option<TokenTree> { 6421 pub fn token_tree(&self) -> Option<TokenTree> {
5909 AstChildren::new(&self.syntax).next() 6422 support::child(&self.syntax)
5910 } 6423 }
5911 pub fn path(&self) -> Option<Path> { 6424 pub fn semi(&self) -> Option<Semi> {
5912 AstChildren::new(&self.syntax).next() 6425 support::token(&self.syntax)
5913 } 6426 }
5914} 6427}
5915#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6428#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -5940,11 +6453,26 @@ impl AstNode for Attr {
5940 } 6453 }
5941} 6454}
5942impl Attr { 6455impl Attr {
6456 pub fn pound(&self) -> Option<Pound> {
6457 support::token(&self.syntax)
6458 }
6459 pub fn excl(&self) -> Option<Excl> {
6460 support::token(&self.syntax)
6461 }
6462 pub fn l_brack(&self) -> Option<LBrack> {
6463 support::token(&self.syntax)
6464 }
5943 pub fn path(&self) -> Option<Path> { 6465 pub fn path(&self) -> Option<Path> {
5944 AstChildren::new(&self.syntax).next() 6466 support::child(&self.syntax)
6467 }
6468 pub fn eq(&self) -> Option<Eq> {
6469 support::token(&self.syntax)
5945 } 6470 }
5946 pub fn input(&self) -> Option<AttrInput> { 6471 pub fn input(&self) -> Option<AttrInput> {
5947 AstChildren::new(&self.syntax).next() 6472 support::child(&self.syntax)
6473 }
6474 pub fn r_brack(&self) -> Option<RBrack> {
6475 support::token(&self.syntax)
5948 } 6476 }
5949} 6477}
5950#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6478#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6003,11 +6531,23 @@ impl AstNode for TypeParamList {
6003 } 6531 }
6004} 6532}
6005impl TypeParamList { 6533impl TypeParamList {
6534 pub fn l_angle(&self) -> Option<LAngle> {
6535 support::token(&self.syntax)
6536 }
6537 pub fn generic_params(&self) -> AstChildren<GenericParam> {
6538 support::children(&self.syntax)
6539 }
6006 pub fn type_params(&self) -> AstChildren<TypeParam> { 6540 pub fn type_params(&self) -> AstChildren<TypeParam> {
6007 AstChildren::new(&self.syntax) 6541 support::children(&self.syntax)
6008 } 6542 }
6009 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { 6543 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
6010 AstChildren::new(&self.syntax) 6544 support::children(&self.syntax)
6545 }
6546 pub fn const_params(&self) -> AstChildren<ConstParam> {
6547 support::children(&self.syntax)
6548 }
6549 pub fn r_angle(&self) -> Option<RAngle> {
6550 support::token(&self.syntax)
6011 } 6551 }
6012} 6552}
6013#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6553#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6041,8 +6581,11 @@ impl ast::NameOwner for TypeParam {}
6041impl ast::AttrsOwner for TypeParam {} 6581impl ast::AttrsOwner for TypeParam {}
6042impl ast::TypeBoundsOwner for TypeParam {} 6582impl ast::TypeBoundsOwner for TypeParam {}
6043impl TypeParam { 6583impl TypeParam {
6584 pub fn eq(&self) -> Option<Eq> {
6585 support::token(&self.syntax)
6586 }
6044 pub fn default_type(&self) -> Option<TypeRef> { 6587 pub fn default_type(&self) -> Option<TypeRef> {
6045 AstChildren::new(&self.syntax).next() 6588 support::child(&self.syntax)
6046 } 6589 }
6047} 6590}
6048#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6591#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6076,8 +6619,11 @@ impl ast::NameOwner for ConstParam {}
6076impl ast::AttrsOwner for ConstParam {} 6619impl ast::AttrsOwner for ConstParam {}
6077impl ast::TypeAscriptionOwner for ConstParam {} 6620impl ast::TypeAscriptionOwner for ConstParam {}
6078impl ConstParam { 6621impl ConstParam {
6622 pub fn eq(&self) -> Option<Eq> {
6623 support::token(&self.syntax)
6624 }
6079 pub fn default_val(&self) -> Option<Expr> { 6625 pub fn default_val(&self) -> Option<Expr> {
6080 AstChildren::new(&self.syntax).next() 6626 support::child(&self.syntax)
6081 } 6627 }
6082} 6628}
6083#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6629#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6108,7 +6654,11 @@ impl AstNode for LifetimeParam {
6108 } 6654 }
6109} 6655}
6110impl ast::AttrsOwner for LifetimeParam {} 6656impl ast::AttrsOwner for LifetimeParam {}
6111impl LifetimeParam {} 6657impl LifetimeParam {
6658 pub fn lifetime(&self) -> Option<Lifetime> {
6659 support::token(&self.syntax)
6660 }
6661}
6112#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6662#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6113pub struct TypeBound { 6663pub struct TypeBound {
6114 pub(crate) syntax: SyntaxNode, 6664 pub(crate) syntax: SyntaxNode,
@@ -6137,8 +6687,14 @@ impl AstNode for TypeBound {
6137 } 6687 }
6138} 6688}
6139impl TypeBound { 6689impl TypeBound {
6690 pub fn lifetime(&self) -> Option<Lifetime> {
6691 support::token(&self.syntax)
6692 }
6693 pub fn const_kw(&self) -> Option<ConstKw> {
6694 support::token(&self.syntax)
6695 }
6140 pub fn type_ref(&self) -> Option<TypeRef> { 6696 pub fn type_ref(&self) -> Option<TypeRef> {
6141 AstChildren::new(&self.syntax).next() 6697 support::child(&self.syntax)
6142 } 6698 }
6143} 6699}
6144#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6170,7 +6726,7 @@ impl AstNode for TypeBoundList {
6170} 6726}
6171impl TypeBoundList { 6727impl TypeBoundList {
6172 pub fn bounds(&self) -> AstChildren<TypeBound> { 6728 pub fn bounds(&self) -> AstChildren<TypeBound> {
6173 AstChildren::new(&self.syntax) 6729 support::children(&self.syntax)
6174 } 6730 }
6175} 6731}
6176#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6732#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6202,8 +6758,11 @@ impl AstNode for WherePred {
6202} 6758}
6203impl ast::TypeBoundsOwner for WherePred {} 6759impl ast::TypeBoundsOwner for WherePred {}
6204impl WherePred { 6760impl WherePred {
6761 pub fn lifetime(&self) -> Option<Lifetime> {
6762 support::token(&self.syntax)
6763 }
6205 pub fn type_ref(&self) -> Option<TypeRef> { 6764 pub fn type_ref(&self) -> Option<TypeRef> {
6206 AstChildren::new(&self.syntax).next() 6765 support::child(&self.syntax)
6207 } 6766 }
6208} 6767}
6209#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6234,8 +6793,43 @@ impl AstNode for WhereClause {
6234 } 6793 }
6235} 6794}
6236impl WhereClause { 6795impl WhereClause {
6796 pub fn where_kw(&self) -> Option<WhereKw> {
6797 support::token(&self.syntax)
6798 }
6237 pub fn predicates(&self) -> AstChildren<WherePred> { 6799 pub fn predicates(&self) -> AstChildren<WherePred> {
6238 AstChildren::new(&self.syntax) 6800 support::children(&self.syntax)
6801 }
6802}
6803#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6804pub struct Abi {
6805 pub(crate) syntax: SyntaxNode,
6806}
6807impl std::fmt::Display for Abi {
6808 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
6809 std::fmt::Display::fmt(self.syntax(), f)
6810 }
6811}
6812impl AstNode for Abi {
6813 fn can_cast(kind: SyntaxKind) -> bool {
6814 match kind {
6815 ABI => true,
6816 _ => false,
6817 }
6818 }
6819 fn cast(syntax: SyntaxNode) -> Option<Self> {
6820 if Self::can_cast(syntax.kind()) {
6821 Some(Self { syntax })
6822 } else {
6823 None
6824 }
6825 }
6826 fn syntax(&self) -> &SyntaxNode {
6827 &self.syntax
6828 }
6829}
6830impl Abi {
6831 pub fn string(&self) -> Option<String> {
6832 support::token(&self.syntax)
6239 } 6833 }
6240} 6834}
6241#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6835#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6265,9 +6859,13 @@ impl AstNode for ExprStmt {
6265 &self.syntax 6859 &self.syntax
6266 } 6860 }
6267} 6861}
6862impl ast::AttrsOwner for ExprStmt {}
6268impl ExprStmt { 6863impl ExprStmt {
6269 pub fn expr(&self) -> Option<Expr> { 6864 pub fn expr(&self) -> Option<Expr> {
6270 AstChildren::new(&self.syntax).next() 6865 support::child(&self.syntax)
6866 }
6867 pub fn semi(&self) -> Option<Semi> {
6868 support::token(&self.syntax)
6271 } 6869 }
6272} 6870}
6273#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6871#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6297,13 +6895,20 @@ impl AstNode for LetStmt {
6297 &self.syntax 6895 &self.syntax
6298 } 6896 }
6299} 6897}
6898impl ast::AttrsOwner for LetStmt {}
6300impl ast::TypeAscriptionOwner for LetStmt {} 6899impl ast::TypeAscriptionOwner for LetStmt {}
6301impl LetStmt { 6900impl LetStmt {
6901 pub fn let_kw(&self) -> Option<LetKw> {
6902 support::token(&self.syntax)
6903 }
6302 pub fn pat(&self) -> Option<Pat> { 6904 pub fn pat(&self) -> Option<Pat> {
6303 AstChildren::new(&self.syntax).next() 6905 support::child(&self.syntax)
6906 }
6907 pub fn eq(&self) -> Option<Eq> {
6908 support::token(&self.syntax)
6304 } 6909 }
6305 pub fn initializer(&self) -> Option<Expr> { 6910 pub fn initializer(&self) -> Option<Expr> {
6306 AstChildren::new(&self.syntax).next() 6911 support::child(&self.syntax)
6307 } 6912 }
6308} 6913}
6309#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6914#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6334,11 +6939,17 @@ impl AstNode for Condition {
6334 } 6939 }
6335} 6940}
6336impl Condition { 6941impl Condition {
6942 pub fn let_kw(&self) -> Option<LetKw> {
6943 support::token(&self.syntax)
6944 }
6337 pub fn pat(&self) -> Option<Pat> { 6945 pub fn pat(&self) -> Option<Pat> {
6338 AstChildren::new(&self.syntax).next() 6946 support::child(&self.syntax)
6947 }
6948 pub fn eq(&self) -> Option<Eq> {
6949 support::token(&self.syntax)
6339 } 6950 }
6340 pub fn expr(&self) -> Option<Expr> { 6951 pub fn expr(&self) -> Option<Expr> {
6341 AstChildren::new(&self.syntax).next() 6952 support::child(&self.syntax)
6342 } 6953 }
6343} 6954}
6344#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6955#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6371,11 +6982,17 @@ impl AstNode for Block {
6371impl ast::AttrsOwner for Block {} 6982impl ast::AttrsOwner for Block {}
6372impl ast::ModuleItemOwner for Block {} 6983impl ast::ModuleItemOwner for Block {}
6373impl Block { 6984impl Block {
6985 pub fn l_curly(&self) -> Option<LCurly> {
6986 support::token(&self.syntax)
6987 }
6374 pub fn statements(&self) -> AstChildren<Stmt> { 6988 pub fn statements(&self) -> AstChildren<Stmt> {
6375 AstChildren::new(&self.syntax) 6989 support::children(&self.syntax)
6376 } 6990 }
6377 pub fn expr(&self) -> Option<Expr> { 6991 pub fn expr(&self) -> Option<Expr> {
6378 AstChildren::new(&self.syntax).next() 6992 support::child(&self.syntax)
6993 }
6994 pub fn r_curly(&self) -> Option<RCurly> {
6995 support::token(&self.syntax)
6379 } 6996 }
6380} 6997}
6381#[derive(Debug, Clone, PartialEq, Eq, Hash)] 6998#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6406,11 +7023,17 @@ impl AstNode for ParamList {
6406 } 7023 }
6407} 7024}
6408impl ParamList { 7025impl ParamList {
7026 pub fn l_paren(&self) -> Option<LParen> {
7027 support::token(&self.syntax)
7028 }
6409 pub fn self_param(&self) -> Option<SelfParam> { 7029 pub fn self_param(&self) -> Option<SelfParam> {
6410 AstChildren::new(&self.syntax).next() 7030 support::child(&self.syntax)
6411 } 7031 }
6412 pub fn params(&self) -> AstChildren<Param> { 7032 pub fn params(&self) -> AstChildren<Param> {
6413 AstChildren::new(&self.syntax) 7033 support::children(&self.syntax)
7034 }
7035 pub fn r_paren(&self) -> Option<RParen> {
7036 support::token(&self.syntax)
6414 } 7037 }
6415} 7038}
6416#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7039#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6442,7 +7065,17 @@ impl AstNode for SelfParam {
6442} 7065}
6443impl ast::TypeAscriptionOwner for SelfParam {} 7066impl ast::TypeAscriptionOwner for SelfParam {}
6444impl ast::AttrsOwner for SelfParam {} 7067impl ast::AttrsOwner for SelfParam {}
6445impl SelfParam {} 7068impl SelfParam {
7069 pub fn amp(&self) -> Option<Amp> {
7070 support::token(&self.syntax)
7071 }
7072 pub fn lifetime(&self) -> Option<Lifetime> {
7073 support::token(&self.syntax)
7074 }
7075 pub fn self_kw(&self) -> Option<SelfKw> {
7076 support::token(&self.syntax)
7077 }
7078}
6446#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7079#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6447pub struct Param { 7080pub struct Param {
6448 pub(crate) syntax: SyntaxNode, 7081 pub(crate) syntax: SyntaxNode,
@@ -6474,7 +7107,10 @@ impl ast::TypeAscriptionOwner for Param {}
6474impl ast::AttrsOwner for Param {} 7107impl ast::AttrsOwner for Param {}
6475impl Param { 7108impl Param {
6476 pub fn pat(&self) -> Option<Pat> { 7109 pub fn pat(&self) -> Option<Pat> {
6477 AstChildren::new(&self.syntax).next() 7110 support::child(&self.syntax)
7111 }
7112 pub fn dotdotdot(&self) -> Option<Dotdotdot> {
7113 support::token(&self.syntax)
6478 } 7114 }
6479} 7115}
6480#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7116#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6507,8 +7143,11 @@ impl AstNode for UseItem {
6507impl ast::AttrsOwner for UseItem {} 7143impl ast::AttrsOwner for UseItem {}
6508impl ast::VisibilityOwner for UseItem {} 7144impl ast::VisibilityOwner for UseItem {}
6509impl UseItem { 7145impl UseItem {
7146 pub fn use_kw(&self) -> Option<UseKw> {
7147 support::token(&self.syntax)
7148 }
6510 pub fn use_tree(&self) -> Option<UseTree> { 7149 pub fn use_tree(&self) -> Option<UseTree> {
6511 AstChildren::new(&self.syntax).next() 7150 support::child(&self.syntax)
6512 } 7151 }
6513} 7152}
6514#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7153#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6540,13 +7179,16 @@ impl AstNode for UseTree {
6540} 7179}
6541impl UseTree { 7180impl UseTree {
6542 pub fn path(&self) -> Option<Path> { 7181 pub fn path(&self) -> Option<Path> {
6543 AstChildren::new(&self.syntax).next() 7182 support::child(&self.syntax)
7183 }
7184 pub fn star(&self) -> Option<Star> {
7185 support::token(&self.syntax)
6544 } 7186 }
6545 pub fn use_tree_list(&self) -> Option<UseTreeList> { 7187 pub fn use_tree_list(&self) -> Option<UseTreeList> {
6546 AstChildren::new(&self.syntax).next() 7188 support::child(&self.syntax)
6547 } 7189 }
6548 pub fn alias(&self) -> Option<Alias> { 7190 pub fn alias(&self) -> Option<Alias> {
6549 AstChildren::new(&self.syntax).next() 7191 support::child(&self.syntax)
6550 } 7192 }
6551} 7193}
6552#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7194#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6577,7 +7219,11 @@ impl AstNode for Alias {
6577 } 7219 }
6578} 7220}
6579impl ast::NameOwner for Alias {} 7221impl ast::NameOwner for Alias {}
6580impl Alias {} 7222impl Alias {
7223 pub fn as_kw(&self) -> Option<AsKw> {
7224 support::token(&self.syntax)
7225 }
7226}
6581#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6582pub struct UseTreeList { 7228pub struct UseTreeList {
6583 pub(crate) syntax: SyntaxNode, 7229 pub(crate) syntax: SyntaxNode,
@@ -6606,8 +7252,14 @@ impl AstNode for UseTreeList {
6606 } 7252 }
6607} 7253}
6608impl UseTreeList { 7254impl UseTreeList {
7255 pub fn l_curly(&self) -> Option<LCurly> {
7256 support::token(&self.syntax)
7257 }
6609 pub fn use_trees(&self) -> AstChildren<UseTree> { 7258 pub fn use_trees(&self) -> AstChildren<UseTree> {
6610 AstChildren::new(&self.syntax) 7259 support::children(&self.syntax)
7260 }
7261 pub fn r_curly(&self) -> Option<RCurly> {
7262 support::token(&self.syntax)
6611 } 7263 }
6612} 7264}
6613#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7265#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6640,11 +7292,17 @@ impl AstNode for ExternCrateItem {
6640impl ast::AttrsOwner for ExternCrateItem {} 7292impl ast::AttrsOwner for ExternCrateItem {}
6641impl ast::VisibilityOwner for ExternCrateItem {} 7293impl ast::VisibilityOwner for ExternCrateItem {}
6642impl ExternCrateItem { 7294impl ExternCrateItem {
7295 pub fn extern_kw(&self) -> Option<ExternKw> {
7296 support::token(&self.syntax)
7297 }
7298 pub fn crate_kw(&self) -> Option<CrateKw> {
7299 support::token(&self.syntax)
7300 }
6643 pub fn name_ref(&self) -> Option<NameRef> { 7301 pub fn name_ref(&self) -> Option<NameRef> {
6644 AstChildren::new(&self.syntax).next() 7302 support::child(&self.syntax)
6645 } 7303 }
6646 pub fn alias(&self) -> Option<Alias> { 7304 pub fn alias(&self) -> Option<Alias> {
6647 AstChildren::new(&self.syntax).next() 7305 support::child(&self.syntax)
6648 } 7306 }
6649} 7307}
6650#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6675,8 +7333,14 @@ impl AstNode for ArgList {
6675 } 7333 }
6676} 7334}
6677impl ArgList { 7335impl ArgList {
7336 pub fn l_paren(&self) -> Option<LParen> {
7337 support::token(&self.syntax)
7338 }
6678 pub fn args(&self) -> AstChildren<Expr> { 7339 pub fn args(&self) -> AstChildren<Expr> {
6679 AstChildren::new(&self.syntax) 7340 support::children(&self.syntax)
7341 }
7342 pub fn r_paren(&self) -> Option<RParen> {
7343 support::token(&self.syntax)
6680 } 7344 }
6681} 7345}
6682#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7346#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6708,10 +7372,10 @@ impl AstNode for Path {
6708} 7372}
6709impl Path { 7373impl Path {
6710 pub fn segment(&self) -> Option<PathSegment> { 7374 pub fn segment(&self) -> Option<PathSegment> {
6711 AstChildren::new(&self.syntax).next() 7375 support::child(&self.syntax)
6712 } 7376 }
6713 pub fn qualifier(&self) -> Option<Path> { 7377 pub fn qualifier(&self) -> Option<Path> {
6714 AstChildren::new(&self.syntax).next() 7378 support::child(&self.syntax)
6715 } 7379 }
6716} 7380}
6717#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6742,20 +7406,29 @@ impl AstNode for PathSegment {
6742 } 7406 }
6743} 7407}
6744impl PathSegment { 7408impl PathSegment {
7409 pub fn coloncolon(&self) -> Option<Coloncolon> {
7410 support::token(&self.syntax)
7411 }
7412 pub fn l_angle(&self) -> Option<LAngle> {
7413 support::token(&self.syntax)
7414 }
6745 pub fn name_ref(&self) -> Option<NameRef> { 7415 pub fn name_ref(&self) -> Option<NameRef> {
6746 AstChildren::new(&self.syntax).next() 7416 support::child(&self.syntax)
6747 } 7417 }
6748 pub fn type_arg_list(&self) -> Option<TypeArgList> { 7418 pub fn type_arg_list(&self) -> Option<TypeArgList> {
6749 AstChildren::new(&self.syntax).next() 7419 support::child(&self.syntax)
6750 } 7420 }
6751 pub fn param_list(&self) -> Option<ParamList> { 7421 pub fn param_list(&self) -> Option<ParamList> {
6752 AstChildren::new(&self.syntax).next() 7422 support::child(&self.syntax)
6753 } 7423 }
6754 pub fn ret_type(&self) -> Option<RetType> { 7424 pub fn ret_type(&self) -> Option<RetType> {
6755 AstChildren::new(&self.syntax).next() 7425 support::child(&self.syntax)
6756 } 7426 }
6757 pub fn path_type(&self) -> Option<PathType> { 7427 pub fn path_type(&self) -> Option<PathType> {
6758 AstChildren::new(&self.syntax).next() 7428 support::child(&self.syntax)
7429 }
7430 pub fn r_angle(&self) -> Option<RAngle> {
7431 support::token(&self.syntax)
6759 } 7432 }
6760} 7433}
6761#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7434#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6786,17 +7459,29 @@ impl AstNode for TypeArgList {
6786 } 7459 }
6787} 7460}
6788impl TypeArgList { 7461impl TypeArgList {
7462 pub fn coloncolon(&self) -> Option<Coloncolon> {
7463 support::token(&self.syntax)
7464 }
7465 pub fn l_angle(&self) -> Option<LAngle> {
7466 support::token(&self.syntax)
7467 }
7468 pub fn generic_args(&self) -> AstChildren<GenericArg> {
7469 support::children(&self.syntax)
7470 }
6789 pub fn type_args(&self) -> AstChildren<TypeArg> { 7471 pub fn type_args(&self) -> AstChildren<TypeArg> {
6790 AstChildren::new(&self.syntax) 7472 support::children(&self.syntax)
6791 } 7473 }
6792 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { 7474 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
6793 AstChildren::new(&self.syntax) 7475 support::children(&self.syntax)
6794 } 7476 }
6795 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { 7477 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
6796 AstChildren::new(&self.syntax) 7478 support::children(&self.syntax)
7479 }
7480 pub fn const_args(&self) -> AstChildren<ConstArg> {
7481 support::children(&self.syntax)
6797 } 7482 }
6798 pub fn const_arg(&self) -> AstChildren<ConstArg> { 7483 pub fn r_angle(&self) -> Option<RAngle> {
6799 AstChildren::new(&self.syntax) 7484 support::token(&self.syntax)
6800 } 7485 }
6801} 7486}
6802#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7487#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6828,7 +7513,7 @@ impl AstNode for TypeArg {
6828} 7513}
6829impl TypeArg { 7514impl TypeArg {
6830 pub fn type_ref(&self) -> Option<TypeRef> { 7515 pub fn type_ref(&self) -> Option<TypeRef> {
6831 AstChildren::new(&self.syntax).next() 7516 support::child(&self.syntax)
6832 } 7517 }
6833} 7518}
6834#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7519#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6858,12 +7543,16 @@ impl AstNode for AssocTypeArg {
6858 &self.syntax 7543 &self.syntax
6859 } 7544 }
6860} 7545}
7546impl ast::TypeBoundsOwner for AssocTypeArg {}
6861impl AssocTypeArg { 7547impl AssocTypeArg {
6862 pub fn name_ref(&self) -> Option<NameRef> { 7548 pub fn name_ref(&self) -> Option<NameRef> {
6863 AstChildren::new(&self.syntax).next() 7549 support::child(&self.syntax)
7550 }
7551 pub fn eq(&self) -> Option<Eq> {
7552 support::token(&self.syntax)
6864 } 7553 }
6865 pub fn type_ref(&self) -> Option<TypeRef> { 7554 pub fn type_ref(&self) -> Option<TypeRef> {
6866 AstChildren::new(&self.syntax).next() 7555 support::child(&self.syntax)
6867 } 7556 }
6868} 7557}
6869#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7558#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6893,7 +7582,11 @@ impl AstNode for LifetimeArg {
6893 &self.syntax 7582 &self.syntax
6894 } 7583 }
6895} 7584}
6896impl LifetimeArg {} 7585impl LifetimeArg {
7586 pub fn lifetime(&self) -> Option<Lifetime> {
7587 support::token(&self.syntax)
7588 }
7589}
6897#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7590#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6898pub struct ConstArg { 7591pub struct ConstArg {
6899 pub(crate) syntax: SyntaxNode, 7592 pub(crate) syntax: SyntaxNode,
@@ -6923,10 +7616,13 @@ impl AstNode for ConstArg {
6923} 7616}
6924impl ConstArg { 7617impl ConstArg {
6925 pub fn literal(&self) -> Option<Literal> { 7618 pub fn literal(&self) -> Option<Literal> {
6926 AstChildren::new(&self.syntax).next() 7619 support::child(&self.syntax)
7620 }
7621 pub fn eq(&self) -> Option<Eq> {
7622 support::token(&self.syntax)
6927 } 7623 }
6928 pub fn block_expr(&self) -> Option<BlockExpr> { 7624 pub fn block_expr(&self) -> Option<BlockExpr> {
6929 AstChildren::new(&self.syntax).next() 7625 support::child(&self.syntax)
6930 } 7626 }
6931} 7627}
6932#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7628#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6988,10 +7684,161 @@ impl AstNode for MacroStmts {
6988} 7684}
6989impl MacroStmts { 7685impl MacroStmts {
6990 pub fn statements(&self) -> AstChildren<Stmt> { 7686 pub fn statements(&self) -> AstChildren<Stmt> {
6991 AstChildren::new(&self.syntax) 7687 support::children(&self.syntax)
6992 } 7688 }
6993 pub fn expr(&self) -> Option<Expr> { 7689 pub fn expr(&self) -> Option<Expr> {
6994 AstChildren::new(&self.syntax).next() 7690 support::child(&self.syntax)
7691 }
7692}
7693#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7694pub struct ExternItemList {
7695 pub(crate) syntax: SyntaxNode,
7696}
7697impl std::fmt::Display for ExternItemList {
7698 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7699 std::fmt::Display::fmt(self.syntax(), f)
7700 }
7701}
7702impl AstNode for ExternItemList {
7703 fn can_cast(kind: SyntaxKind) -> bool {
7704 match kind {
7705 EXTERN_ITEM_LIST => true,
7706 _ => false,
7707 }
7708 }
7709 fn cast(syntax: SyntaxNode) -> Option<Self> {
7710 if Self::can_cast(syntax.kind()) {
7711 Some(Self { syntax })
7712 } else {
7713 None
7714 }
7715 }
7716 fn syntax(&self) -> &SyntaxNode {
7717 &self.syntax
7718 }
7719}
7720impl ast::FnDefOwner for ExternItemList {}
7721impl ast::ModuleItemOwner for ExternItemList {}
7722impl ExternItemList {
7723 pub fn l_curly(&self) -> Option<LCurly> {
7724 support::token(&self.syntax)
7725 }
7726 pub fn extern_items(&self) -> AstChildren<ExternItem> {
7727 support::children(&self.syntax)
7728 }
7729 pub fn r_curly(&self) -> Option<RCurly> {
7730 support::token(&self.syntax)
7731 }
7732}
7733#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7734pub struct ExternBlock {
7735 pub(crate) syntax: SyntaxNode,
7736}
7737impl std::fmt::Display for ExternBlock {
7738 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7739 std::fmt::Display::fmt(self.syntax(), f)
7740 }
7741}
7742impl AstNode for ExternBlock {
7743 fn can_cast(kind: SyntaxKind) -> bool {
7744 match kind {
7745 EXTERN_BLOCK => true,
7746 _ => false,
7747 }
7748 }
7749 fn cast(syntax: SyntaxNode) -> Option<Self> {
7750 if Self::can_cast(syntax.kind()) {
7751 Some(Self { syntax })
7752 } else {
7753 None
7754 }
7755 }
7756 fn syntax(&self) -> &SyntaxNode {
7757 &self.syntax
7758 }
7759}
7760impl ExternBlock {
7761 pub fn abi(&self) -> Option<Abi> {
7762 support::child(&self.syntax)
7763 }
7764 pub fn extern_item_list(&self) -> Option<ExternItemList> {
7765 support::child(&self.syntax)
7766 }
7767}
7768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7769pub struct MetaItem {
7770 pub(crate) syntax: SyntaxNode,
7771}
7772impl std::fmt::Display for MetaItem {
7773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7774 std::fmt::Display::fmt(self.syntax(), f)
7775 }
7776}
7777impl AstNode for MetaItem {
7778 fn can_cast(kind: SyntaxKind) -> bool {
7779 match kind {
7780 META_ITEM => true,
7781 _ => false,
7782 }
7783 }
7784 fn cast(syntax: SyntaxNode) -> Option<Self> {
7785 if Self::can_cast(syntax.kind()) {
7786 Some(Self { syntax })
7787 } else {
7788 None
7789 }
7790 }
7791 fn syntax(&self) -> &SyntaxNode {
7792 &self.syntax
7793 }
7794}
7795impl MetaItem {
7796 pub fn path(&self) -> Option<Path> {
7797 support::child(&self.syntax)
7798 }
7799 pub fn eq(&self) -> Option<Eq> {
7800 support::token(&self.syntax)
7801 }
7802 pub fn attr_input(&self) -> Option<AttrInput> {
7803 support::child(&self.syntax)
7804 }
7805 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> {
7806 support::children(&self.syntax)
7807 }
7808}
7809#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7810pub struct MacroDef {
7811 pub(crate) syntax: SyntaxNode,
7812}
7813impl std::fmt::Display for MacroDef {
7814 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7815 std::fmt::Display::fmt(self.syntax(), f)
7816 }
7817}
7818impl AstNode for MacroDef {
7819 fn can_cast(kind: SyntaxKind) -> bool {
7820 match kind {
7821 MACRO_DEF => true,
7822 _ => false,
7823 }
7824 }
7825 fn cast(syntax: SyntaxNode) -> Option<Self> {
7826 if Self::can_cast(syntax.kind()) {
7827 Some(Self { syntax })
7828 } else {
7829 None
7830 }
7831 }
7832 fn syntax(&self) -> &SyntaxNode {
7833 &self.syntax
7834 }
7835}
7836impl MacroDef {
7837 pub fn name(&self) -> Option<Name> {
7838 support::child(&self.syntax)
7839 }
7840 pub fn token_tree(&self) -> Option<TokenTree> {
7841 support::child(&self.syntax)
6995 } 7842 }
6996} 7843}
6997#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7844#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -7048,6 +7895,114 @@ impl ast::NameOwner for NominalDef {}
7048impl ast::TypeParamsOwner for NominalDef {} 7895impl ast::TypeParamsOwner for NominalDef {}
7049impl ast::AttrsOwner for NominalDef {} 7896impl ast::AttrsOwner for NominalDef {}
7050#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7897#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7898pub enum GenericParam {
7899 LifetimeParam(LifetimeParam),
7900 TypeParam(TypeParam),
7901 ConstParam(ConstParam),
7902}
7903impl From<LifetimeParam> for GenericParam {
7904 fn from(node: LifetimeParam) -> GenericParam {
7905 GenericParam::LifetimeParam(node)
7906 }
7907}
7908impl From<TypeParam> for GenericParam {
7909 fn from(node: TypeParam) -> GenericParam {
7910 GenericParam::TypeParam(node)
7911 }
7912}
7913impl From<ConstParam> for GenericParam {
7914 fn from(node: ConstParam) -> GenericParam {
7915 GenericParam::ConstParam(node)
7916 }
7917}
7918impl std::fmt::Display for GenericParam {
7919 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7920 std::fmt::Display::fmt(self.syntax(), f)
7921 }
7922}
7923impl AstNode for GenericParam {
7924 fn can_cast(kind: SyntaxKind) -> bool {
7925 match kind {
7926 LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
7927 _ => false,
7928 }
7929 }
7930 fn cast(syntax: SyntaxNode) -> Option<Self> {
7931 let res = match syntax.kind() {
7932 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
7933 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
7934 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
7935 _ => return None,
7936 };
7937 Some(res)
7938 }
7939 fn syntax(&self) -> &SyntaxNode {
7940 match self {
7941 GenericParam::LifetimeParam(it) => &it.syntax,
7942 GenericParam::TypeParam(it) => &it.syntax,
7943 GenericParam::ConstParam(it) => &it.syntax,
7944 }
7945 }
7946}
7947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7948pub enum GenericArg {
7949 LifetimeArg(LifetimeArg),
7950 TypeArg(TypeArg),
7951 ConstArg(ConstArg),
7952 AssocTypeArg(AssocTypeArg),
7953}
7954impl From<LifetimeArg> for GenericArg {
7955 fn from(node: LifetimeArg) -> GenericArg {
7956 GenericArg::LifetimeArg(node)
7957 }
7958}
7959impl From<TypeArg> for GenericArg {
7960 fn from(node: TypeArg) -> GenericArg {
7961 GenericArg::TypeArg(node)
7962 }
7963}
7964impl From<ConstArg> for GenericArg {
7965 fn from(node: ConstArg) -> GenericArg {
7966 GenericArg::ConstArg(node)
7967 }
7968}
7969impl From<AssocTypeArg> for GenericArg {
7970 fn from(node: AssocTypeArg) -> GenericArg {
7971 GenericArg::AssocTypeArg(node)
7972 }
7973}
7974impl std::fmt::Display for GenericArg {
7975 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7976 std::fmt::Display::fmt(self.syntax(), f)
7977 }
7978}
7979impl AstNode for GenericArg {
7980 fn can_cast(kind: SyntaxKind) -> bool {
7981 match kind {
7982 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true,
7983 _ => false,
7984 }
7985 }
7986 fn cast(syntax: SyntaxNode) -> Option<Self> {
7987 let res = match syntax.kind() {
7988 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
7989 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
7990 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
7991 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
7992 _ => return None,
7993 };
7994 Some(res)
7995 }
7996 fn syntax(&self) -> &SyntaxNode {
7997 match self {
7998 GenericArg::LifetimeArg(it) => &it.syntax,
7999 GenericArg::TypeArg(it) => &it.syntax,
8000 GenericArg::ConstArg(it) => &it.syntax,
8001 GenericArg::AssocTypeArg(it) => &it.syntax,
8002 }
8003 }
8004}
8005#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7051pub enum TypeRef { 8006pub enum TypeRef {
7052 ParenType(ParenType), 8007 ParenType(ParenType),
7053 TupleType(TupleType), 8008 TupleType(TupleType),
@@ -7194,6 +8149,7 @@ pub enum ModuleItem {
7194 StaticDef(StaticDef), 8149 StaticDef(StaticDef),
7195 Module(Module), 8150 Module(Module),
7196 MacroCall(MacroCall), 8151 MacroCall(MacroCall),
8152 ExternBlock(ExternBlock),
7197} 8153}
7198impl From<StructDef> for ModuleItem { 8154impl From<StructDef> for ModuleItem {
7199 fn from(node: StructDef) -> ModuleItem { 8155 fn from(node: StructDef) -> ModuleItem {
@@ -7260,6 +8216,11 @@ impl From<MacroCall> for ModuleItem {
7260 ModuleItem::MacroCall(node) 8216 ModuleItem::MacroCall(node)
7261 } 8217 }
7262} 8218}
8219impl From<ExternBlock> for ModuleItem {
8220 fn from(node: ExternBlock) -> ModuleItem {
8221 ModuleItem::ExternBlock(node)
8222 }
8223}
7263impl std::fmt::Display for ModuleItem { 8224impl std::fmt::Display for ModuleItem {
7264 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 8225 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7265 std::fmt::Display::fmt(self.syntax(), f) 8226 std::fmt::Display::fmt(self.syntax(), f)
@@ -7269,7 +8230,8 @@ impl AstNode for ModuleItem {
7269 fn can_cast(kind: SyntaxKind) -> bool { 8230 fn can_cast(kind: SyntaxKind) -> bool {
7270 match kind { 8231 match kind {
7271 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF 8232 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
7272 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL => true, 8233 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
8234 | EXTERN_BLOCK => true,
7273 _ => false, 8235 _ => false,
7274 } 8236 }
7275 } 8237 }
@@ -7288,6 +8250,7 @@ impl AstNode for ModuleItem {
7288 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }), 8250 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
7289 MODULE => ModuleItem::Module(Module { syntax }), 8251 MODULE => ModuleItem::Module(Module { syntax }),
7290 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }), 8252 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
8253 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
7291 _ => return None, 8254 _ => return None,
7292 }; 8255 };
7293 Some(res) 8256 Some(res)
@@ -7307,9 +8270,11 @@ impl AstNode for ModuleItem {
7307 ModuleItem::StaticDef(it) => &it.syntax, 8270 ModuleItem::StaticDef(it) => &it.syntax,
7308 ModuleItem::Module(it) => &it.syntax, 8271 ModuleItem::Module(it) => &it.syntax,
7309 ModuleItem::MacroCall(it) => &it.syntax, 8272 ModuleItem::MacroCall(it) => &it.syntax,
8273 ModuleItem::ExternBlock(it) => &it.syntax,
7310 } 8274 }
7311 } 8275 }
7312} 8276}
8277impl ast::NameOwner for ModuleItem {}
7313impl ast::AttrsOwner for ModuleItem {} 8278impl ast::AttrsOwner for ModuleItem {}
7314impl ast::VisibilityOwner for ModuleItem {} 8279impl ast::VisibilityOwner for ModuleItem {}
7315#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8280#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -7362,8 +8327,54 @@ impl AstNode for ImplItem {
7362 } 8327 }
7363 } 8328 }
7364} 8329}
8330impl ast::NameOwner for ImplItem {}
7365impl ast::AttrsOwner for ImplItem {} 8331impl ast::AttrsOwner for ImplItem {}
7366#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8333pub enum ExternItem {
8334 FnDef(FnDef),
8335 StaticDef(StaticDef),
8336}
8337impl From<FnDef> for ExternItem {
8338 fn from(node: FnDef) -> ExternItem {
8339 ExternItem::FnDef(node)
8340 }
8341}
8342impl From<StaticDef> for ExternItem {
8343 fn from(node: StaticDef) -> ExternItem {
8344 ExternItem::StaticDef(node)
8345 }
8346}
8347impl std::fmt::Display for ExternItem {
8348 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8349 std::fmt::Display::fmt(self.syntax(), f)
8350 }
8351}
8352impl AstNode for ExternItem {
8353 fn can_cast(kind: SyntaxKind) -> bool {
8354 match kind {
8355 FN_DEF | STATIC_DEF => true,
8356 _ => false,
8357 }
8358 }
8359 fn cast(syntax: SyntaxNode) -> Option<Self> {
8360 let res = match syntax.kind() {
8361 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
8362 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
8363 _ => return None,
8364 };
8365 Some(res)
8366 }
8367 fn syntax(&self) -> &SyntaxNode {
8368 match self {
8369 ExternItem::FnDef(it) => &it.syntax,
8370 ExternItem::StaticDef(it) => &it.syntax,
8371 }
8372 }
8373}
8374impl ast::NameOwner for ExternItem {}
8375impl ast::AttrsOwner for ExternItem {}
8376impl ast::VisibilityOwner for ExternItem {}
8377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7367pub enum Expr { 8378pub enum Expr {
7368 TupleExpr(TupleExpr), 8379 TupleExpr(TupleExpr),
7369 ArrayExpr(ArrayExpr), 8380 ArrayExpr(ArrayExpr),
@@ -7642,6 +8653,7 @@ impl AstNode for Expr {
7642 } 8653 }
7643 } 8654 }
7644} 8655}
8656impl ast::AttrsOwner for Expr {}
7645#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8657#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7646pub enum Pat { 8658pub enum Pat {
7647 OrPat(OrPat), 8659 OrPat(OrPat),
@@ -7791,6 +8803,48 @@ impl AstNode for Pat {
7791 } 8803 }
7792} 8804}
7793#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8805#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8806pub enum RecordInnerPat {
8807 RecordFieldPat(RecordFieldPat),
8808 BindPat(BindPat),
8809}
8810impl From<RecordFieldPat> for RecordInnerPat {
8811 fn from(node: RecordFieldPat) -> RecordInnerPat {
8812 RecordInnerPat::RecordFieldPat(node)
8813 }
8814}
8815impl From<BindPat> for RecordInnerPat {
8816 fn from(node: BindPat) -> RecordInnerPat {
8817 RecordInnerPat::BindPat(node)
8818 }
8819}
8820impl std::fmt::Display for RecordInnerPat {
8821 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8822 std::fmt::Display::fmt(self.syntax(), f)
8823 }
8824}
8825impl AstNode for RecordInnerPat {
8826 fn can_cast(kind: SyntaxKind) -> bool {
8827 match kind {
8828 RECORD_FIELD_PAT | BIND_PAT => true,
8829 _ => false,
8830 }
8831 }
8832 fn cast(syntax: SyntaxNode) -> Option<Self> {
8833 let res = match syntax.kind() {
8834 RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }),
8835 BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }),
8836 _ => return None,
8837 };
8838 Some(res)
8839 }
8840 fn syntax(&self) -> &SyntaxNode {
8841 match self {
8842 RecordInnerPat::RecordFieldPat(it) => &it.syntax,
8843 RecordInnerPat::BindPat(it) => &it.syntax,
8844 }
8845 }
8846}
8847#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7794pub enum AttrInput { 8848pub enum AttrInput {
7795 Literal(Literal), 8849 Literal(Literal),
7796 TokenTree(TokenTree), 8850 TokenTree(TokenTree),
@@ -7834,19 +8888,19 @@ impl AstNode for AttrInput {
7834} 8888}
7835#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8889#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7836pub enum Stmt { 8890pub enum Stmt {
7837 ExprStmt(ExprStmt),
7838 LetStmt(LetStmt), 8891 LetStmt(LetStmt),
7839} 8892 ExprStmt(ExprStmt),
7840impl From<ExprStmt> for Stmt {
7841 fn from(node: ExprStmt) -> Stmt {
7842 Stmt::ExprStmt(node)
7843 }
7844} 8893}
7845impl From<LetStmt> for Stmt { 8894impl From<LetStmt> for Stmt {
7846 fn from(node: LetStmt) -> Stmt { 8895 fn from(node: LetStmt) -> Stmt {
7847 Stmt::LetStmt(node) 8896 Stmt::LetStmt(node)
7848 } 8897 }
7849} 8898}
8899impl From<ExprStmt> for Stmt {
8900 fn from(node: ExprStmt) -> Stmt {
8901 Stmt::ExprStmt(node)
8902 }
8903}
7850impl std::fmt::Display for Stmt { 8904impl std::fmt::Display for Stmt {
7851 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 8905 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
7852 std::fmt::Display::fmt(self.syntax(), f) 8906 std::fmt::Display::fmt(self.syntax(), f)
@@ -7855,22 +8909,717 @@ impl std::fmt::Display for Stmt {
7855impl AstNode for Stmt { 8909impl AstNode for Stmt {
7856 fn can_cast(kind: SyntaxKind) -> bool { 8910 fn can_cast(kind: SyntaxKind) -> bool {
7857 match kind { 8911 match kind {
7858 EXPR_STMT | LET_STMT => true, 8912 LET_STMT | EXPR_STMT => true,
7859 _ => false, 8913 _ => false,
7860 } 8914 }
7861 } 8915 }
7862 fn cast(syntax: SyntaxNode) -> Option<Self> { 8916 fn cast(syntax: SyntaxNode) -> Option<Self> {
7863 let res = match syntax.kind() { 8917 let res = match syntax.kind() {
7864 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
7865 LET_STMT => Stmt::LetStmt(LetStmt { syntax }), 8918 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
8919 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
7866 _ => return None, 8920 _ => return None,
7867 }; 8921 };
7868 Some(res) 8922 Some(res)
7869 } 8923 }
7870 fn syntax(&self) -> &SyntaxNode { 8924 fn syntax(&self) -> &SyntaxNode {
7871 match self { 8925 match self {
7872 Stmt::ExprStmt(it) => &it.syntax,
7873 Stmt::LetStmt(it) => &it.syntax, 8926 Stmt::LetStmt(it) => &it.syntax,
8927 Stmt::ExprStmt(it) => &it.syntax,
8928 }
8929 }
8930}
8931#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8932pub enum LeftDelimiter {
8933 LParen(LParen),
8934 LBrack(LBrack),
8935 LCurly(LCurly),
8936}
8937impl From<LParen> for LeftDelimiter {
8938 fn from(node: LParen) -> LeftDelimiter {
8939 LeftDelimiter::LParen(node)
8940 }
8941}
8942impl From<LBrack> for LeftDelimiter {
8943 fn from(node: LBrack) -> LeftDelimiter {
8944 LeftDelimiter::LBrack(node)
8945 }
8946}
8947impl From<LCurly> for LeftDelimiter {
8948 fn from(node: LCurly) -> LeftDelimiter {
8949 LeftDelimiter::LCurly(node)
8950 }
8951}
8952impl std::fmt::Display for LeftDelimiter {
8953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8954 std::fmt::Display::fmt(self.syntax(), f)
8955 }
8956}
8957impl AstToken for LeftDelimiter {
8958 fn can_cast(kind: SyntaxKind) -> bool {
8959 match kind {
8960 L_PAREN | L_BRACK | L_CURLY => true,
8961 _ => false,
8962 }
8963 }
8964 fn cast(syntax: SyntaxToken) -> Option<Self> {
8965 let res = match syntax.kind() {
8966 L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
8967 L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
8968 L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
8969 _ => return None,
8970 };
8971 Some(res)
8972 }
8973 fn syntax(&self) -> &SyntaxToken {
8974 match self {
8975 LeftDelimiter::LParen(it) => &it.syntax,
8976 LeftDelimiter::LBrack(it) => &it.syntax,
8977 LeftDelimiter::LCurly(it) => &it.syntax,
8978 }
8979 }
8980}
8981#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8982pub enum RightDelimiter {
8983 RParen(RParen),
8984 RBrack(RBrack),
8985 RCurly(RCurly),
8986}
8987impl From<RParen> for RightDelimiter {
8988 fn from(node: RParen) -> RightDelimiter {
8989 RightDelimiter::RParen(node)
8990 }
8991}
8992impl From<RBrack> for RightDelimiter {
8993 fn from(node: RBrack) -> RightDelimiter {
8994 RightDelimiter::RBrack(node)
8995 }
8996}
8997impl From<RCurly> for RightDelimiter {
8998 fn from(node: RCurly) -> RightDelimiter {
8999 RightDelimiter::RCurly(node)
9000 }
9001}
9002impl std::fmt::Display for RightDelimiter {
9003 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9004 std::fmt::Display::fmt(self.syntax(), f)
9005 }
9006}
9007impl AstToken for RightDelimiter {
9008 fn can_cast(kind: SyntaxKind) -> bool {
9009 match kind {
9010 R_PAREN | R_BRACK | R_CURLY => true,
9011 _ => false,
9012 }
9013 }
9014 fn cast(syntax: SyntaxToken) -> Option<Self> {
9015 let res = match syntax.kind() {
9016 R_PAREN => RightDelimiter::RParen(RParen { syntax }),
9017 R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
9018 R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
9019 _ => return None,
9020 };
9021 Some(res)
9022 }
9023 fn syntax(&self) -> &SyntaxToken {
9024 match self {
9025 RightDelimiter::RParen(it) => &it.syntax,
9026 RightDelimiter::RBrack(it) => &it.syntax,
9027 RightDelimiter::RCurly(it) => &it.syntax,
9028 }
9029 }
9030}
9031#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9032pub enum RangeSeparator {
9033 Dotdot(Dotdot),
9034 Dotdotdot(Dotdotdot),
9035 Dotdoteq(Dotdoteq),
9036}
9037impl From<Dotdot> for RangeSeparator {
9038 fn from(node: Dotdot) -> RangeSeparator {
9039 RangeSeparator::Dotdot(node)
9040 }
9041}
9042impl From<Dotdotdot> for RangeSeparator {
9043 fn from(node: Dotdotdot) -> RangeSeparator {
9044 RangeSeparator::Dotdotdot(node)
9045 }
9046}
9047impl From<Dotdoteq> for RangeSeparator {
9048 fn from(node: Dotdoteq) -> RangeSeparator {
9049 RangeSeparator::Dotdoteq(node)
9050 }
9051}
9052impl std::fmt::Display for RangeSeparator {
9053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9054 std::fmt::Display::fmt(self.syntax(), f)
9055 }
9056}
9057impl AstToken for RangeSeparator {
9058 fn can_cast(kind: SyntaxKind) -> bool {
9059 match kind {
9060 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
9061 _ => false,
9062 }
9063 }
9064 fn cast(syntax: SyntaxToken) -> Option<Self> {
9065 let res = match syntax.kind() {
9066 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
9067 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
9068 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
9069 _ => return None,
9070 };
9071 Some(res)
9072 }
9073 fn syntax(&self) -> &SyntaxToken {
9074 match self {
9075 RangeSeparator::Dotdot(it) => &it.syntax,
9076 RangeSeparator::Dotdotdot(it) => &it.syntax,
9077 RangeSeparator::Dotdoteq(it) => &it.syntax,
9078 }
9079 }
9080}
9081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9082pub enum BinOp {
9083 Pipepipe(Pipepipe),
9084 Ampamp(Ampamp),
9085 Eqeq(Eqeq),
9086 Neq(Neq),
9087 Lteq(Lteq),
9088 Gteq(Gteq),
9089 LAngle(LAngle),
9090 RAngle(RAngle),
9091 Plus(Plus),
9092 Star(Star),
9093 Minus(Minus),
9094 Slash(Slash),
9095 Percent(Percent),
9096 Shl(Shl),
9097 Shr(Shr),
9098 Caret(Caret),
9099 Pipe(Pipe),
9100 Amp(Amp),
9101 Eq(Eq),
9102 Pluseq(Pluseq),
9103 Slasheq(Slasheq),
9104 Stareq(Stareq),
9105 Percenteq(Percenteq),
9106 Shreq(Shreq),
9107 Shleq(Shleq),
9108 Minuseq(Minuseq),
9109 Pipeeq(Pipeeq),
9110 Ampeq(Ampeq),
9111 Careteq(Careteq),
9112}
9113impl From<Pipepipe> for BinOp {
9114 fn from(node: Pipepipe) -> BinOp {
9115 BinOp::Pipepipe(node)
9116 }
9117}
9118impl From<Ampamp> for BinOp {
9119 fn from(node: Ampamp) -> BinOp {
9120 BinOp::Ampamp(node)
9121 }
9122}
9123impl From<Eqeq> for BinOp {
9124 fn from(node: Eqeq) -> BinOp {
9125 BinOp::Eqeq(node)
9126 }
9127}
9128impl From<Neq> for BinOp {
9129 fn from(node: Neq) -> BinOp {
9130 BinOp::Neq(node)
9131 }
9132}
9133impl From<Lteq> for BinOp {
9134 fn from(node: Lteq) -> BinOp {
9135 BinOp::Lteq(node)
9136 }
9137}
9138impl From<Gteq> for BinOp {
9139 fn from(node: Gteq) -> BinOp {
9140 BinOp::Gteq(node)
9141 }
9142}
9143impl From<LAngle> for BinOp {
9144 fn from(node: LAngle) -> BinOp {
9145 BinOp::LAngle(node)
9146 }
9147}
9148impl From<RAngle> for BinOp {
9149 fn from(node: RAngle) -> BinOp {
9150 BinOp::RAngle(node)
9151 }
9152}
9153impl From<Plus> for BinOp {
9154 fn from(node: Plus) -> BinOp {
9155 BinOp::Plus(node)
9156 }
9157}
9158impl From<Star> for BinOp {
9159 fn from(node: Star) -> BinOp {
9160 BinOp::Star(node)
9161 }
9162}
9163impl From<Minus> for BinOp {
9164 fn from(node: Minus) -> BinOp {
9165 BinOp::Minus(node)
9166 }
9167}
9168impl From<Slash> for BinOp {
9169 fn from(node: Slash) -> BinOp {
9170 BinOp::Slash(node)
9171 }
9172}
9173impl From<Percent> for BinOp {
9174 fn from(node: Percent) -> BinOp {
9175 BinOp::Percent(node)
9176 }
9177}
9178impl From<Shl> for BinOp {
9179 fn from(node: Shl) -> BinOp {
9180 BinOp::Shl(node)
9181 }
9182}
9183impl From<Shr> for BinOp {
9184 fn from(node: Shr) -> BinOp {
9185 BinOp::Shr(node)
9186 }
9187}
9188impl From<Caret> for BinOp {
9189 fn from(node: Caret) -> BinOp {
9190 BinOp::Caret(node)
9191 }
9192}
9193impl From<Pipe> for BinOp {
9194 fn from(node: Pipe) -> BinOp {
9195 BinOp::Pipe(node)
9196 }
9197}
9198impl From<Amp> for BinOp {
9199 fn from(node: Amp) -> BinOp {
9200 BinOp::Amp(node)
9201 }
9202}
9203impl From<Eq> for BinOp {
9204 fn from(node: Eq) -> BinOp {
9205 BinOp::Eq(node)
9206 }
9207}
9208impl From<Pluseq> for BinOp {
9209 fn from(node: Pluseq) -> BinOp {
9210 BinOp::Pluseq(node)
9211 }
9212}
9213impl From<Slasheq> for BinOp {
9214 fn from(node: Slasheq) -> BinOp {
9215 BinOp::Slasheq(node)
9216 }
9217}
9218impl From<Stareq> for BinOp {
9219 fn from(node: Stareq) -> BinOp {
9220 BinOp::Stareq(node)
9221 }
9222}
9223impl From<Percenteq> for BinOp {
9224 fn from(node: Percenteq) -> BinOp {
9225 BinOp::Percenteq(node)
9226 }
9227}
9228impl From<Shreq> for BinOp {
9229 fn from(node: Shreq) -> BinOp {
9230 BinOp::Shreq(node)
9231 }
9232}
9233impl From<Shleq> for BinOp {
9234 fn from(node: Shleq) -> BinOp {
9235 BinOp::Shleq(node)
9236 }
9237}
9238impl From<Minuseq> for BinOp {
9239 fn from(node: Minuseq) -> BinOp {
9240 BinOp::Minuseq(node)
9241 }
9242}
9243impl From<Pipeeq> for BinOp {
9244 fn from(node: Pipeeq) -> BinOp {
9245 BinOp::Pipeeq(node)
9246 }
9247}
9248impl From<Ampeq> for BinOp {
9249 fn from(node: Ampeq) -> BinOp {
9250 BinOp::Ampeq(node)
9251 }
9252}
9253impl From<Careteq> for BinOp {
9254 fn from(node: Careteq) -> BinOp {
9255 BinOp::Careteq(node)
9256 }
9257}
9258impl std::fmt::Display for BinOp {
9259 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9260 std::fmt::Display::fmt(self.syntax(), f)
9261 }
9262}
9263impl AstToken for BinOp {
9264 fn can_cast(kind: SyntaxKind) -> bool {
9265 match kind {
9266 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
9267 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
9268 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
9269 _ => false,
9270 }
9271 }
9272 fn cast(syntax: SyntaxToken) -> Option<Self> {
9273 let res = match syntax.kind() {
9274 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
9275 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
9276 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
9277 NEQ => BinOp::Neq(Neq { syntax }),
9278 LTEQ => BinOp::Lteq(Lteq { syntax }),
9279 GTEQ => BinOp::Gteq(Gteq { syntax }),
9280 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
9281 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
9282 PLUS => BinOp::Plus(Plus { syntax }),
9283 STAR => BinOp::Star(Star { syntax }),
9284 MINUS => BinOp::Minus(Minus { syntax }),
9285 SLASH => BinOp::Slash(Slash { syntax }),
9286 PERCENT => BinOp::Percent(Percent { syntax }),
9287 SHL => BinOp::Shl(Shl { syntax }),
9288 SHR => BinOp::Shr(Shr { syntax }),
9289 CARET => BinOp::Caret(Caret { syntax }),
9290 PIPE => BinOp::Pipe(Pipe { syntax }),
9291 AMP => BinOp::Amp(Amp { syntax }),
9292 EQ => BinOp::Eq(Eq { syntax }),
9293 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
9294 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
9295 STAREQ => BinOp::Stareq(Stareq { syntax }),
9296 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
9297 SHREQ => BinOp::Shreq(Shreq { syntax }),
9298 SHLEQ => BinOp::Shleq(Shleq { syntax }),
9299 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
9300 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
9301 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
9302 CARETEQ => BinOp::Careteq(Careteq { syntax }),
9303 _ => return None,
9304 };
9305 Some(res)
9306 }
9307 fn syntax(&self) -> &SyntaxToken {
9308 match self {
9309 BinOp::Pipepipe(it) => &it.syntax,
9310 BinOp::Ampamp(it) => &it.syntax,
9311 BinOp::Eqeq(it) => &it.syntax,
9312 BinOp::Neq(it) => &it.syntax,
9313 BinOp::Lteq(it) => &it.syntax,
9314 BinOp::Gteq(it) => &it.syntax,
9315 BinOp::LAngle(it) => &it.syntax,
9316 BinOp::RAngle(it) => &it.syntax,
9317 BinOp::Plus(it) => &it.syntax,
9318 BinOp::Star(it) => &it.syntax,
9319 BinOp::Minus(it) => &it.syntax,
9320 BinOp::Slash(it) => &it.syntax,
9321 BinOp::Percent(it) => &it.syntax,
9322 BinOp::Shl(it) => &it.syntax,
9323 BinOp::Shr(it) => &it.syntax,
9324 BinOp::Caret(it) => &it.syntax,
9325 BinOp::Pipe(it) => &it.syntax,
9326 BinOp::Amp(it) => &it.syntax,
9327 BinOp::Eq(it) => &it.syntax,
9328 BinOp::Pluseq(it) => &it.syntax,
9329 BinOp::Slasheq(it) => &it.syntax,
9330 BinOp::Stareq(it) => &it.syntax,
9331 BinOp::Percenteq(it) => &it.syntax,
9332 BinOp::Shreq(it) => &it.syntax,
9333 BinOp::Shleq(it) => &it.syntax,
9334 BinOp::Minuseq(it) => &it.syntax,
9335 BinOp::Pipeeq(it) => &it.syntax,
9336 BinOp::Ampeq(it) => &it.syntax,
9337 BinOp::Careteq(it) => &it.syntax,
9338 }
9339 }
9340}
9341#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9342pub enum PrefixOp {
9343 Minus(Minus),
9344 Excl(Excl),
9345 Star(Star),
9346}
9347impl From<Minus> for PrefixOp {
9348 fn from(node: Minus) -> PrefixOp {
9349 PrefixOp::Minus(node)
9350 }
9351}
9352impl From<Excl> for PrefixOp {
9353 fn from(node: Excl) -> PrefixOp {
9354 PrefixOp::Excl(node)
9355 }
9356}
9357impl From<Star> for PrefixOp {
9358 fn from(node: Star) -> PrefixOp {
9359 PrefixOp::Star(node)
9360 }
9361}
9362impl std::fmt::Display for PrefixOp {
9363 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9364 std::fmt::Display::fmt(self.syntax(), f)
9365 }
9366}
9367impl AstToken for PrefixOp {
9368 fn can_cast(kind: SyntaxKind) -> bool {
9369 match kind {
9370 MINUS | EXCL | STAR => true,
9371 _ => false,
9372 }
9373 }
9374 fn cast(syntax: SyntaxToken) -> Option<Self> {
9375 let res = match syntax.kind() {
9376 MINUS => PrefixOp::Minus(Minus { syntax }),
9377 EXCL => PrefixOp::Excl(Excl { syntax }),
9378 STAR => PrefixOp::Star(Star { syntax }),
9379 _ => return None,
9380 };
9381 Some(res)
9382 }
9383 fn syntax(&self) -> &SyntaxToken {
9384 match self {
9385 PrefixOp::Minus(it) => &it.syntax,
9386 PrefixOp::Excl(it) => &it.syntax,
9387 PrefixOp::Star(it) => &it.syntax,
9388 }
9389 }
9390}
9391#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9392pub enum RangeOp {
9393 Dotdot(Dotdot),
9394 Dotdoteq(Dotdoteq),
9395}
9396impl From<Dotdot> for RangeOp {
9397 fn from(node: Dotdot) -> RangeOp {
9398 RangeOp::Dotdot(node)
9399 }
9400}
9401impl From<Dotdoteq> for RangeOp {
9402 fn from(node: Dotdoteq) -> RangeOp {
9403 RangeOp::Dotdoteq(node)
9404 }
9405}
9406impl std::fmt::Display for RangeOp {
9407 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9408 std::fmt::Display::fmt(self.syntax(), f)
9409 }
9410}
9411impl AstToken for RangeOp {
9412 fn can_cast(kind: SyntaxKind) -> bool {
9413 match kind {
9414 DOTDOT | DOTDOTEQ => true,
9415 _ => false,
9416 }
9417 }
9418 fn cast(syntax: SyntaxToken) -> Option<Self> {
9419 let res = match syntax.kind() {
9420 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
9421 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
9422 _ => return None,
9423 };
9424 Some(res)
9425 }
9426 fn syntax(&self) -> &SyntaxToken {
9427 match self {
9428 RangeOp::Dotdot(it) => &it.syntax,
9429 RangeOp::Dotdoteq(it) => &it.syntax,
9430 }
9431 }
9432}
9433#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9434pub enum LiteralToken {
9435 IntNumber(IntNumber),
9436 FloatNumber(FloatNumber),
9437 String(String),
9438 RawString(RawString),
9439 TrueKw(TrueKw),
9440 FalseKw(FalseKw),
9441 ByteString(ByteString),
9442 RawByteString(RawByteString),
9443 Char(Char),
9444 Byte(Byte),
9445}
9446impl From<IntNumber> for LiteralToken {
9447 fn from(node: IntNumber) -> LiteralToken {
9448 LiteralToken::IntNumber(node)
9449 }
9450}
9451impl From<FloatNumber> for LiteralToken {
9452 fn from(node: FloatNumber) -> LiteralToken {
9453 LiteralToken::FloatNumber(node)
9454 }
9455}
9456impl From<String> for LiteralToken {
9457 fn from(node: String) -> LiteralToken {
9458 LiteralToken::String(node)
9459 }
9460}
9461impl From<RawString> for LiteralToken {
9462 fn from(node: RawString) -> LiteralToken {
9463 LiteralToken::RawString(node)
9464 }
9465}
9466impl From<TrueKw> for LiteralToken {
9467 fn from(node: TrueKw) -> LiteralToken {
9468 LiteralToken::TrueKw(node)
9469 }
9470}
9471impl From<FalseKw> for LiteralToken {
9472 fn from(node: FalseKw) -> LiteralToken {
9473 LiteralToken::FalseKw(node)
9474 }
9475}
9476impl From<ByteString> for LiteralToken {
9477 fn from(node: ByteString) -> LiteralToken {
9478 LiteralToken::ByteString(node)
9479 }
9480}
9481impl From<RawByteString> for LiteralToken {
9482 fn from(node: RawByteString) -> LiteralToken {
9483 LiteralToken::RawByteString(node)
9484 }
9485}
9486impl From<Char> for LiteralToken {
9487 fn from(node: Char) -> LiteralToken {
9488 LiteralToken::Char(node)
9489 }
9490}
9491impl From<Byte> for LiteralToken {
9492 fn from(node: Byte) -> LiteralToken {
9493 LiteralToken::Byte(node)
9494 }
9495}
9496impl std::fmt::Display for LiteralToken {
9497 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9498 std::fmt::Display::fmt(self.syntax(), f)
9499 }
9500}
9501impl AstToken for LiteralToken {
9502 fn can_cast(kind: SyntaxKind) -> bool {
9503 match kind {
9504 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
9505 | RAW_BYTE_STRING | CHAR | BYTE => true,
9506 _ => false,
9507 }
9508 }
9509 fn cast(syntax: SyntaxToken) -> Option<Self> {
9510 let res = match syntax.kind() {
9511 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
9512 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
9513 STRING => LiteralToken::String(String { syntax }),
9514 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
9515 TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
9516 FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
9517 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
9518 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
9519 CHAR => LiteralToken::Char(Char { syntax }),
9520 BYTE => LiteralToken::Byte(Byte { syntax }),
9521 _ => return None,
9522 };
9523 Some(res)
9524 }
9525 fn syntax(&self) -> &SyntaxToken {
9526 match self {
9527 LiteralToken::IntNumber(it) => &it.syntax,
9528 LiteralToken::FloatNumber(it) => &it.syntax,
9529 LiteralToken::String(it) => &it.syntax,
9530 LiteralToken::RawString(it) => &it.syntax,
9531 LiteralToken::TrueKw(it) => &it.syntax,
9532 LiteralToken::FalseKw(it) => &it.syntax,
9533 LiteralToken::ByteString(it) => &it.syntax,
9534 LiteralToken::RawByteString(it) => &it.syntax,
9535 LiteralToken::Char(it) => &it.syntax,
9536 LiteralToken::Byte(it) => &it.syntax,
9537 }
9538 }
9539}
9540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9541pub enum NameRefToken {
9542 Ident(Ident),
9543 IntNumber(IntNumber),
9544}
9545impl From<Ident> for NameRefToken {
9546 fn from(node: Ident) -> NameRefToken {
9547 NameRefToken::Ident(node)
9548 }
9549}
9550impl From<IntNumber> for NameRefToken {
9551 fn from(node: IntNumber) -> NameRefToken {
9552 NameRefToken::IntNumber(node)
9553 }
9554}
9555impl std::fmt::Display for NameRefToken {
9556 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9557 std::fmt::Display::fmt(self.syntax(), f)
9558 }
9559}
9560impl AstToken for NameRefToken {
9561 fn can_cast(kind: SyntaxKind) -> bool {
9562 match kind {
9563 IDENT | INT_NUMBER => true,
9564 _ => false,
9565 }
9566 }
9567 fn cast(syntax: SyntaxToken) -> Option<Self> {
9568 let res = match syntax.kind() {
9569 IDENT => NameRefToken::Ident(Ident { syntax }),
9570 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
9571 _ => return None,
9572 };
9573 Some(res)
9574 }
9575 fn syntax(&self) -> &SyntaxToken {
9576 match self {
9577 NameRefToken::Ident(it) => &it.syntax,
9578 NameRefToken::IntNumber(it) => &it.syntax,
9579 }
9580 }
9581}
9582#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9583pub enum FieldDefList {
9584 RecordFieldDefList(RecordFieldDefList),
9585 TupleFieldDefList(TupleFieldDefList),
9586}
9587impl From<RecordFieldDefList> for FieldDefList {
9588 fn from(node: RecordFieldDefList) -> FieldDefList {
9589 FieldDefList::RecordFieldDefList(node)
9590 }
9591}
9592impl From<TupleFieldDefList> for FieldDefList {
9593 fn from(node: TupleFieldDefList) -> FieldDefList {
9594 FieldDefList::TupleFieldDefList(node)
9595 }
9596}
9597impl std::fmt::Display for FieldDefList {
9598 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
9599 std::fmt::Display::fmt(self.syntax(), f)
9600 }
9601}
9602impl AstNode for FieldDefList {
9603 fn can_cast(kind: SyntaxKind) -> bool {
9604 match kind {
9605 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
9606 _ => false,
9607 }
9608 }
9609 fn cast(syntax: SyntaxNode) -> Option<Self> {
9610 let res = match syntax.kind() {
9611 RECORD_FIELD_DEF_LIST => {
9612 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
9613 }
9614 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
9615 _ => return None,
9616 };
9617 Some(res)
9618 }
9619 fn syntax(&self) -> &SyntaxNode {
9620 match self {
9621 FieldDefList::RecordFieldDefList(it) => &it.syntax,
9622 FieldDefList::TupleFieldDefList(it) => &it.syntax,
7874 } 9623 }
7875 } 9624 }
7876} 9625}
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 576378306..870e83804 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -5,7 +5,7 @@
5use itertools::Itertools; 5use itertools::Itertools;
6 6
7use crate::{ 7use crate::{
8 ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, 8 ast::{self, child_opt, children, support, AstChildren, AstNode, AstToken},
9 syntax_node::SyntaxElementChildren, 9 syntax_node::SyntaxElementChildren,
10}; 10};
11 11
@@ -31,6 +31,10 @@ pub trait LoopBodyOwner: AstNode {
31 fn loop_body(&self) -> Option<ast::BlockExpr> { 31 fn loop_body(&self) -> Option<ast::BlockExpr> {
32 child_opt(self) 32 child_opt(self)
33 } 33 }
34
35 fn label(&self) -> Option<ast::Label> {
36 child_opt(self)
37 }
34} 38}
35 39
36pub trait ArgListOwner: AstNode { 40pub trait ArgListOwner: AstNode {
@@ -65,6 +69,10 @@ pub trait TypeBoundsOwner: AstNode {
65 fn type_bound_list(&self) -> Option<ast::TypeBoundList> { 69 fn type_bound_list(&self) -> Option<ast::TypeBoundList> {
66 child_opt(self) 70 child_opt(self)
67 } 71 }
72
73 fn colon(&self) -> Option<ast::Colon> {
74 support::token(self.syntax())
75 }
68} 76}
69 77
70pub trait AttrsOwner: AstNode { 78pub trait AttrsOwner: AstNode {
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index d9f51ec39..5fed777ac 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -70,7 +70,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
70 "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super", 70 "match", "mod", "move", "mut", "pub", "ref", "return", "self", "static", "struct", "super",
71 "trait", "true", "try", "type", "unsafe", "use", "where", "while", 71 "trait", "true", "try", "type", "unsafe", "use", "where", "while",
72 ], 72 ],
73 contextual_keywords: &["auto", "default", "existential", "union"], 73 contextual_keywords: &["auto", "default", "existential", "union", "raw"],
74 literals: &[ 74 literals: &[
75 "INT_NUMBER", 75 "INT_NUMBER",
76 "FLOAT_NUMBER", 76 "FLOAT_NUMBER",
@@ -297,235 +297,310 @@ macro_rules! ast_enums {
297 297
298pub(crate) const AST_SRC: AstSrc = AstSrc { 298pub(crate) const AST_SRC: AstSrc = AstSrc {
299 nodes: &ast_nodes! { 299 nodes: &ast_nodes! {
300 struct SourceFile: ModuleItemOwner, FnDefOwner { 300 struct SourceFile: ModuleItemOwner, FnDefOwner, AttrsOwner {
301 modules: [Module], 301 modules: [Module],
302 } 302 }
303 303
304 struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner { 304 struct FnDef: VisibilityOwner, NameOwner, TypeParamsOwner, DocCommentsOwner, AttrsOwner {
305 Abi,
306 ConstKw,
307 DefaultKw,
308 AsyncKw,
309 UnsafeKw,
310 FnKw,
305 ParamList, 311 ParamList,
306 RetType, 312 RetType,
307 body: BlockExpr, 313 body: BlockExpr,
314 Semi
308 } 315 }
309 316
310 struct RetType { TypeRef } 317 struct RetType { ThinArrow, TypeRef }
311 318
312 struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { 319 struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
320 StructKw,
321 FieldDefList,
322 Semi
313 } 323 }
314 324
315 struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { 325 struct UnionDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
326 UnionKw,
316 RecordFieldDefList, 327 RecordFieldDefList,
317 } 328 }
318 329
319 struct RecordFieldDefList { fields: [RecordFieldDef] } 330 struct RecordFieldDefList { LCurly, fields: [RecordFieldDef], RCurly }
320 struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { } 331 struct RecordFieldDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { }
321 332
322 struct TupleFieldDefList { fields: [TupleFieldDef] } 333 struct TupleFieldDefList { LParen, fields: [TupleFieldDef], RParen }
323 struct TupleFieldDef: VisibilityOwner, AttrsOwner { 334 struct TupleFieldDef: VisibilityOwner, AttrsOwner {
324 TypeRef, 335 TypeRef,
325 } 336 }
326 337
327 struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner { 338 struct EnumDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
339 EnumKw,
328 variant_list: EnumVariantList, 340 variant_list: EnumVariantList,
329 } 341 }
330 struct EnumVariantList { 342 struct EnumVariantList {
343 LCurly,
331 variants: [EnumVariant], 344 variants: [EnumVariant],
345 RCurly
332 } 346 }
333 struct EnumVariant: NameOwner, DocCommentsOwner, AttrsOwner { 347 struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
348 FieldDefList,
349 Eq,
334 Expr 350 Expr
335 } 351 }
336 352
337 struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner { 353 struct TraitDef: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner, TypeParamsOwner, TypeBoundsOwner {
354 UnsafeKw,
355 AutoKw,
356 TraitKw,
338 ItemList, 357 ItemList,
339 } 358 }
340 359
341 struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner { 360 struct Module: VisibilityOwner, NameOwner, AttrsOwner, DocCommentsOwner {
361 ModKw,
342 ItemList, 362 ItemList,
363 Semi
343 } 364 }
344 365
345 struct ItemList: FnDefOwner, ModuleItemOwner { 366 struct ItemList: FnDefOwner, ModuleItemOwner {
367 LCurly,
346 impl_items: [ImplItem], 368 impl_items: [ImplItem],
369 RCurly
347 } 370 }
348 371
349 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { 372 struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
373 DefaultKw,
374 ConstKw,
375 Eq,
350 body: Expr, 376 body: Expr,
377 Semi
351 } 378 }
352 379
353 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner { 380 struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
381 StaticKw,
382 MutKw,
383 Eq,
354 body: Expr, 384 body: Expr,
385 Semi
355 } 386 }
356 387
357 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner { 388 struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
389 DefaultKw,
390 TypeKw,
391 Eq,
358 TypeRef, 392 TypeRef,
393 Semi
359 } 394 }
360 395
361 struct ImplDef: TypeParamsOwner, AttrsOwner { 396 struct ImplDef: TypeParamsOwner, AttrsOwner {
397 DefaultKw,
398 ConstKw,
399 UnsafeKw,
400 ImplKw,
401 Excl,
402 ForKw,
362 ItemList, 403 ItemList,
363 } 404 }
364 405
365 struct ParenType { TypeRef } 406 struct ParenType { LParen, TypeRef, RParen }
366 struct TupleType { fields: [TypeRef] } 407 struct TupleType { LParen, fields: [TypeRef], RParen }
367 struct NeverType { } 408 struct NeverType { Excl }
368 struct PathType { Path } 409 struct PathType { Path }
369 struct PointerType { TypeRef } 410 struct PointerType { Star, ConstKw, TypeRef }
370 struct ArrayType { TypeRef, Expr } 411 struct ArrayType { LBrack, TypeRef, Semi, Expr, RBrack }
371 struct SliceType { TypeRef } 412 struct SliceType { LBrack, TypeRef, RBrack }
372 struct ReferenceType { TypeRef } 413 struct ReferenceType { Amp, Lifetime, MutKw, TypeRef }
373 struct PlaceholderType { } 414 struct PlaceholderType { Underscore }
374 struct FnPointerType { ParamList, RetType } 415 struct FnPointerType { Abi, UnsafeKw, FnKw, ParamList, RetType }
375 struct ForType { TypeRef } 416 struct ForType { ForKw, TypeParamList, TypeRef }
376 struct ImplTraitType: TypeBoundsOwner {} 417 struct ImplTraitType: TypeBoundsOwner { ImplKw }
377 struct DynTraitType: TypeBoundsOwner {} 418 struct DynTraitType: TypeBoundsOwner { DynKw }
378 419
379 struct TupleExpr { exprs: [Expr] } 420 struct TupleExpr: AttrsOwner { LParen, exprs: [Expr], RParen }
380 struct ArrayExpr { exprs: [Expr] } 421 struct ArrayExpr: AttrsOwner { LBrack, exprs: [Expr], Semi, RBrack }
381 struct ParenExpr { Expr } 422 struct ParenExpr: AttrsOwner { LParen, Expr, RParen }
382 struct PathExpr { Path } 423 struct PathExpr { Path }
383 struct LambdaExpr { 424 struct LambdaExpr: AttrsOwner {
425 StaticKw,
426 AsyncKw,
427 MoveKw,
384 ParamList, 428 ParamList,
385 RetType, 429 RetType,
386 body: Expr, 430 body: Expr,
387 } 431 }
388 struct IfExpr { Condition } 432 struct IfExpr: AttrsOwner { IfKw, Condition }
389 struct LoopExpr: LoopBodyOwner { } 433 struct LoopExpr: AttrsOwner, LoopBodyOwner { LoopKw }
390 struct TryBlockExpr { body: BlockExpr } 434 struct TryBlockExpr: AttrsOwner { TryKw, body: BlockExpr }
391 struct ForExpr: LoopBodyOwner { 435 struct ForExpr: AttrsOwner, LoopBodyOwner {
436 ForKw,
392 Pat, 437 Pat,
438 InKw,
393 iterable: Expr, 439 iterable: Expr,
394 } 440 }
395 struct WhileExpr: LoopBodyOwner { Condition } 441 struct WhileExpr: AttrsOwner, LoopBodyOwner { WhileKw, Condition }
396 struct ContinueExpr {} 442 struct ContinueExpr: AttrsOwner { ContinueKw, Lifetime }
397 struct BreakExpr { Expr } 443 struct BreakExpr: AttrsOwner { BreakKw, Lifetime, Expr }
398 struct Label {} 444 struct Label { Lifetime }
399 struct BlockExpr { Block } 445 struct BlockExpr: AttrsOwner { Label, UnsafeKw, Block }
400 struct ReturnExpr { Expr } 446 struct ReturnExpr: AttrsOwner { Expr }
401 struct CallExpr: ArgListOwner { Expr } 447 struct CallExpr: ArgListOwner { Expr }
402 struct MethodCallExpr: ArgListOwner { 448 struct MethodCallExpr: AttrsOwner, ArgListOwner {
403 Expr, NameRef, TypeArgList, 449 Expr, Dot, NameRef, TypeArgList,
404 } 450 }
405 struct IndexExpr {} 451 struct IndexExpr: AttrsOwner { LBrack, RBrack }
406 struct FieldExpr { Expr, NameRef } 452 struct FieldExpr: AttrsOwner { Expr, Dot, NameRef }
407 struct AwaitExpr { Expr } 453 struct AwaitExpr: AttrsOwner { Expr, Dot, AwaitKw }
408 struct TryExpr { Expr } 454 struct TryExpr: AttrsOwner { TryKw, Expr }
409 struct CastExpr { Expr, TypeRef } 455 struct CastExpr: AttrsOwner { Expr, AsKw, TypeRef }
410 struct RefExpr { Expr } 456 struct RefExpr: AttrsOwner { Amp, RawKw, MutKw, Expr }
411 struct PrefixExpr { Expr } 457 struct PrefixExpr: AttrsOwner { PrefixOp, Expr }
412 struct BoxExpr { Expr } 458 struct BoxExpr: AttrsOwner { BoxKw, Expr }
413 struct RangeExpr {} 459 struct RangeExpr: AttrsOwner { RangeOp }
414 struct BinExpr {} 460 struct BinExpr: AttrsOwner { BinOp }
415 struct Literal {} 461 struct Literal { LiteralToken }
416 462
417 struct MatchExpr { Expr, MatchArmList } 463 struct MatchExpr: AttrsOwner { MatchKw, Expr, MatchArmList }
418 struct MatchArmList: AttrsOwner { arms: [MatchArm] } 464 struct MatchArmList: AttrsOwner { LCurly, arms: [MatchArm], RCurly }
419 struct MatchArm: AttrsOwner { 465 struct MatchArm: AttrsOwner {
420 pat: Pat, 466 pat: Pat,
421 guard: MatchGuard, 467 guard: MatchGuard,
468 FatArrow,
422 Expr, 469 Expr,
423 } 470 }
424 struct MatchGuard { Expr } 471 struct MatchGuard { IfKw, Expr }
425 472
426 struct RecordLit { Path, RecordFieldList } 473 struct RecordLit { Path, RecordFieldList}
427 struct RecordFieldList { 474 struct RecordFieldList {
475 LCurly,
428 fields: [RecordField], 476 fields: [RecordField],
477 Dotdot,
429 spread: Expr, 478 spread: Expr,
479 RCurly
430 } 480 }
431 struct RecordField { NameRef, Expr } 481 struct RecordField: AttrsOwner { NameRef, Colon, Expr }
432 482
433 struct OrPat { pats: [Pat] } 483 struct OrPat { pats: [Pat] }
434 struct ParenPat { Pat } 484 struct ParenPat { LParen, Pat, RParen }
435 struct RefPat { Pat } 485 struct RefPat { Amp, MutKw, Pat }
436 struct BoxPat { Pat } 486 struct BoxPat { BoxKw, Pat }
437 struct BindPat: NameOwner { Pat } 487 struct BindPat: AttrsOwner, NameOwner { RefKw, MutKw, Pat }
438 struct PlaceholderPat { } 488 struct PlaceholderPat { Underscore }
439 struct DotDotPat { } 489 struct DotDotPat { Dotdot }
440 struct PathPat { Path } 490 struct PathPat { Path }
441 struct SlicePat { args: [Pat] } 491 struct SlicePat { LBrack, args: [Pat], RBrack }
442 struct RangePat {} 492 struct RangePat { RangeSeparator }
443 struct LiteralPat { Literal } 493 struct LiteralPat { Literal }
444 struct MacroPat { MacroCall } 494 struct MacroPat { MacroCall }
445 495
446 struct RecordPat { RecordFieldPatList, Path } 496 struct RecordPat { RecordFieldPatList, Path }
447 struct RecordFieldPatList { 497 struct RecordFieldPatList {
498 LCurly,
499 pats: [RecordInnerPat],
448 record_field_pats: [RecordFieldPat], 500 record_field_pats: [RecordFieldPat],
449 bind_pats: [BindPat], 501 bind_pats: [BindPat],
502 Dotdot,
503 RCurly
450 } 504 }
451 struct RecordFieldPat: NameOwner { Pat } 505 struct RecordFieldPat: AttrsOwner, NameOwner { Colon, Pat }
452 506
453 struct TupleStructPat { Path, args: [Pat] } 507 struct TupleStructPat { Path, LParen, args: [Pat], RParen }
454 struct TuplePat { args: [Pat] } 508 struct TuplePat { LParen, args: [Pat], RParen }
455 509
456 struct Visibility {} 510 struct Visibility { PubKw, SuperKw, SelfKw, CrateKw }
457 struct Name {} 511 struct Name { Ident }
458 struct NameRef {} 512 struct NameRef { NameRefToken }
459 513
460 struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner { 514 struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner {
461 TokenTree, Path 515 Path, Excl, TokenTree, Semi
462 } 516 }
463 struct Attr { Path, input: AttrInput } 517 struct Attr { Pound, Excl, LBrack, Path, Eq, input: AttrInput, RBrack }
464 struct TokenTree {} 518 struct TokenTree {}
465 struct TypeParamList { 519 struct TypeParamList {
520 LAngle,
521 generic_params: [GenericParam],
466 type_params: [TypeParam], 522 type_params: [TypeParam],
467 lifetime_params: [LifetimeParam], 523 lifetime_params: [LifetimeParam],
524 const_params: [ConstParam],
525 RAngle
468 } 526 }
469 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner { 527 struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
528 Eq,
470 default_type: TypeRef, 529 default_type: TypeRef,
471 } 530 }
472 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner { 531 struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
532 Eq,
473 default_val: Expr, 533 default_val: Expr,
474 } 534 }
475 struct LifetimeParam: AttrsOwner { } 535 struct LifetimeParam: AttrsOwner { Lifetime}
476 struct TypeBound { TypeRef} 536 struct TypeBound { Lifetime, /* Question, */ ConstKw, /* Question, */ TypeRef}
477 struct TypeBoundList { bounds: [TypeBound] } 537 struct TypeBoundList { bounds: [TypeBound] }
478 struct WherePred: TypeBoundsOwner { TypeRef } 538 struct WherePred: TypeBoundsOwner { Lifetime, TypeRef }
479 struct WhereClause { predicates: [WherePred] } 539 struct WhereClause { WhereKw, predicates: [WherePred] }
480 struct ExprStmt { Expr } 540 struct Abi { String }
481 struct LetStmt: TypeAscriptionOwner { 541 struct ExprStmt: AttrsOwner { Expr, Semi }
542 struct LetStmt: AttrsOwner, TypeAscriptionOwner {
543 LetKw,
482 Pat, 544 Pat,
545 Eq,
483 initializer: Expr, 546 initializer: Expr,
484 } 547 }
485 struct Condition { Pat, Expr } 548 struct Condition { LetKw, Pat, Eq, Expr }
486 struct Block: AttrsOwner, ModuleItemOwner { 549 struct Block: AttrsOwner, ModuleItemOwner {
550 LCurly,
487 statements: [Stmt], 551 statements: [Stmt],
488 Expr, 552 Expr,
553 RCurly,
489 } 554 }
490 struct ParamList { 555 struct ParamList {
556 LParen,
491 SelfParam, 557 SelfParam,
492 params: [Param], 558 params: [Param],
559 RParen
493 } 560 }
494 struct SelfParam: TypeAscriptionOwner, AttrsOwner { } 561 struct SelfParam: TypeAscriptionOwner, AttrsOwner { Amp, Lifetime, SelfKw }
495 struct Param: TypeAscriptionOwner, AttrsOwner { 562 struct Param: TypeAscriptionOwner, AttrsOwner {
496 Pat, 563 Pat,
564 Dotdotdot
497 } 565 }
498 struct UseItem: AttrsOwner, VisibilityOwner { 566 struct UseItem: AttrsOwner, VisibilityOwner {
567 UseKw,
499 UseTree, 568 UseTree,
500 } 569 }
501 struct UseTree { 570 struct UseTree {
502 Path, UseTreeList, Alias 571 Path, Star, UseTreeList, Alias
503 } 572 }
504 struct Alias: NameOwner { } 573 struct Alias: NameOwner { AsKw }
505 struct UseTreeList { use_trees: [UseTree] } 574 struct UseTreeList { LCurly, use_trees: [UseTree], RCurly }
506 struct ExternCrateItem: AttrsOwner, VisibilityOwner { 575 struct ExternCrateItem: AttrsOwner, VisibilityOwner {
507 NameRef, Alias, 576 ExternKw, CrateKw, NameRef, Alias,
508 } 577 }
509 struct ArgList { 578 struct ArgList {
579 LParen,
510 args: [Expr], 580 args: [Expr],
581 RParen
511 } 582 }
512 struct Path { 583 struct Path {
513 segment: PathSegment, 584 segment: PathSegment,
514 qualifier: Path, 585 qualifier: Path,
515 } 586 }
516 struct PathSegment { 587 struct PathSegment {
517 NameRef, TypeArgList, ParamList, RetType, PathType, 588 Coloncolon, LAngle, NameRef, TypeArgList, ParamList, RetType, PathType, RAngle
518 } 589 }
519 struct TypeArgList { 590 struct TypeArgList {
591 Coloncolon,
592 LAngle,
593 generic_args: [GenericArg],
520 type_args: [TypeArg], 594 type_args: [TypeArg],
521 lifetime_args: [LifetimeArg], 595 lifetime_args: [LifetimeArg],
522 assoc_type_args: [AssocTypeArg], 596 assoc_type_args: [AssocTypeArg],
523 const_arg: [ConstArg], 597 const_args: [ConstArg],
598 RAngle
524 } 599 }
525 struct TypeArg { TypeRef } 600 struct TypeArg { TypeRef }
526 struct AssocTypeArg { NameRef, TypeRef } 601 struct AssocTypeArg : TypeBoundsOwner { NameRef, Eq, TypeRef }
527 struct LifetimeArg {} 602 struct LifetimeArg { Lifetime }
528 struct ConstArg { Literal, BlockExpr } 603 struct ConstArg { Literal, Eq, BlockExpr }
529 604
530 struct MacroItems: ModuleItemOwner, FnDefOwner { } 605 struct MacroItems: ModuleItemOwner, FnDefOwner { }
531 606
@@ -533,12 +608,44 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
533 statements: [Stmt], 608 statements: [Stmt],
534 Expr, 609 Expr,
535 } 610 }
611
612 struct ExternItemList: FnDefOwner, ModuleItemOwner {
613 LCurly,
614 extern_items: [ExternItem],
615 RCurly
616 }
617
618 struct ExternBlock {
619 Abi,
620 ExternItemList
621 }
622
623 struct MetaItem {
624 Path, Eq, AttrInput, nested_meta_items: [MetaItem]
625 }
626
627 struct MacroDef {
628 Name, TokenTree
629 }
536 }, 630 },
537 enums: &ast_enums! { 631 enums: &ast_enums! {
538 enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner { 632 enum NominalDef: NameOwner, TypeParamsOwner, AttrsOwner {
539 StructDef, EnumDef, UnionDef, 633 StructDef, EnumDef, UnionDef,
540 } 634 }
541 635
636 enum GenericParam {
637 LifetimeParam,
638 TypeParam,
639 ConstParam
640 }
641
642 enum GenericArg {
643 LifetimeArg,
644 TypeArg,
645 ConstArg,
646 AssocTypeArg
647 }
648
542 enum TypeRef { 649 enum TypeRef {
543 ParenType, 650 ParenType,
544 TupleType, 651 TupleType,
@@ -555,7 +662,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
555 DynTraitType, 662 DynTraitType,
556 } 663 }
557 664
558 enum ModuleItem: AttrsOwner, VisibilityOwner { 665 enum ModuleItem: NameOwner, AttrsOwner, VisibilityOwner {
559 StructDef, 666 StructDef,
560 UnionDef, 667 UnionDef,
561 EnumDef, 668 EnumDef,
@@ -569,13 +676,20 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
569 StaticDef, 676 StaticDef,
570 Module, 677 Module,
571 MacroCall, 678 MacroCall,
679 ExternBlock
680 }
681
682 /* impl blocks can also contain MacroCall */
683 enum ImplItem: NameOwner, AttrsOwner {
684 FnDef, TypeAliasDef, ConstDef
572 } 685 }
573 686
574 enum ImplItem: AttrsOwner { 687 /* extern blocks can also contain MacroCall */
575 FnDef, TypeAliasDef, ConstDef, 688 enum ExternItem: NameOwner, AttrsOwner, VisibilityOwner {
689 FnDef, StaticDef
576 } 690 }
577 691
578 enum Expr { 692 enum Expr: AttrsOwner {
579 TupleExpr, 693 TupleExpr,
580 ArrayExpr, 694 ArrayExpr,
581 ParenExpr, 695 ParenExpr,
@@ -627,7 +741,86 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
627 MacroPat, 741 MacroPat,
628 } 742 }
629 743
744 enum RecordInnerPat {
745 RecordFieldPat,
746 BindPat
747 }
748
630 enum AttrInput { Literal, TokenTree } 749 enum AttrInput { Literal, TokenTree }
631 enum Stmt { ExprStmt, LetStmt } 750 enum Stmt {
751 LetStmt,
752 ExprStmt,
753 // macro calls are parsed as expression statements */
754 }
755
756 enum LeftDelimiter { LParen, LBrack, LCurly }
757 enum RightDelimiter { RParen, RBrack, RCurly }
758 enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq}
759
760 enum BinOp {
761 Pipepipe,
762 Ampamp,
763 Eqeq,
764 Neq,
765 Lteq,
766 Gteq,
767 LAngle,
768 RAngle,
769 Plus,
770 Star,
771 Minus,
772 Slash,
773 Percent,
774 Shl,
775 Shr,
776 Caret,
777 Pipe,
778 Amp,
779 Eq,
780 Pluseq,
781 Slasheq,
782 Stareq,
783 Percenteq,
784 Shreq,
785 Shleq,
786 Minuseq,
787 Pipeeq,
788 Ampeq,
789 Careteq,
790 }
791
792 enum PrefixOp {
793 Minus,
794 Excl,
795 Star
796 }
797
798 enum RangeOp {
799 Dotdot,
800 Dotdoteq
801 }
802
803 enum LiteralToken {
804 IntNumber,
805 FloatNumber,
806 String,
807 RawString,
808 TrueKw,
809 FalseKw,
810 ByteString,
811 RawByteString,
812 Char,
813 Byte
814 }
815
816 enum NameRefToken {
817 Ident,
818 IntNumber
819 }
820
821 enum FieldDefList {
822 RecordFieldDefList,
823 TupleFieldDefList,
824 }
632 }, 825 },
633}; 826};
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 2dfb68371..6dae93aa2 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -146,14 +146,23 @@ fn generate_ast(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
146 FieldSrc::Many(_) => { 146 FieldSrc::Many(_) => {
147 quote! { 147 quote! {
148 pub fn #method_name(&self) -> AstChildren<#ty> { 148 pub fn #method_name(&self) -> AstChildren<#ty> {
149 AstChildren::new(&self.syntax) 149 support::children(&self.syntax)
150 } 150 }
151 } 151 }
152 } 152 }
153 FieldSrc::Optional(_) | FieldSrc::Shorthand => { 153 FieldSrc::Optional(_) | FieldSrc::Shorthand => {
154 quote! { 154 let is_token = element_kinds_map[&ty.to_string()].has_tokens;
155 pub fn #method_name(&self) -> Option<#ty> { 155 if is_token {
156 AstChildren::new(&self.syntax).next() 156 quote! {
157 pub fn #method_name(&self) -> Option<#ty> {
158 support::token(&self.syntax)
159 }
160 }
161 } else {
162 quote! {
163 pub fn #method_name(&self) -> Option<#ty> {
164 support::child(&self.syntax)
165 }
157 } 166 }
158 } 167 }
159 } 168 }
@@ -205,6 +214,48 @@ fn generate_ast(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
205 quote!(impl ast::#trait_name for #name {}) 214 quote!(impl ast::#trait_name for #name {})
206 }); 215 });
207 216
217 let element_kinds = &element_kinds_map[&en.name.to_string()];
218 assert!(
219 element_kinds.has_nodes ^ element_kinds.has_tokens,
220 "{}: {:#?}",
221 name,
222 element_kinds
223 );
224 let specific_ast_trait = {
225 let (ast_trait, syntax_type) = if element_kinds.has_tokens {
226 (quote!(AstToken), quote!(SyntaxToken))
227 } else {
228 (quote!(AstNode), quote!(SyntaxNode))
229 };
230
231 quote! {
232 impl #ast_trait for #name {
233 fn can_cast(kind: SyntaxKind) -> bool {
234 match kind {
235 #(#kinds)|* => true,
236 _ => false,
237 }
238 }
239 fn cast(syntax: #syntax_type) -> Option<Self> {
240 let res = match syntax.kind() {
241 #(
242 #kinds => #name::#variants(#variants { syntax }),
243 )*
244 _ => return None,
245 };
246 Some(res)
247 }
248 fn syntax(&self) -> &#syntax_type {
249 match self {
250 #(
251 #name::#variants(it) => &it.syntax,
252 )*
253 }
254 }
255 }
256 }
257 };
258
208 quote! { 259 quote! {
209 #[derive(Debug, Clone, PartialEq, Eq, Hash)] 260 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
210 pub enum #name { 261 pub enum #name {
@@ -225,30 +276,8 @@ fn generate_ast(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
225 } 276 }
226 } 277 }
227 278
228 impl AstNode for #name { 279 #specific_ast_trait
229 fn can_cast(kind: SyntaxKind) -> bool { 280
230 match kind {
231 #(#kinds)|* => true,
232 _ => false,
233 }
234 }
235 fn cast(syntax: SyntaxNode) -> Option<Self> {
236 let res = match syntax.kind() {
237 #(
238 #kinds => #name::#variants(#variants { syntax }),
239 )*
240 _ => return None,
241 };
242 Some(res)
243 }
244 fn syntax(&self) -> &SyntaxNode {
245 match self {
246 #(
247 #name::#variants(it) => &it.syntax,
248 )*
249 }
250 }
251 }
252 #(#traits)* 281 #(#traits)*
253 } 282 }
254 }); 283 });
@@ -268,7 +297,7 @@ fn generate_ast(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
268 #[allow(unused_imports)] 297 #[allow(unused_imports)]
269 use crate::{ 298 use crate::{
270 SyntaxNode, SyntaxToken, SyntaxElement, NodeOrToken, SyntaxKind::{self, *}, 299 SyntaxNode, SyntaxToken, SyntaxElement, NodeOrToken, SyntaxKind::{self, *},
271 ast::{self, AstNode, AstToken, AstChildren}, 300 ast::{self, AstNode, AstToken, AstChildren, support},
272 }; 301 };
273 302
274 #(#tokens)* 303 #(#tokens)*