aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-09 22:47:34 +0100
committerGitHub <[email protected]>2020-04-09 22:47:34 +0100
commit176f7f61175bc433c56083a758bd7a28a8ae31f8 (patch)
treecca4821454502279317323fbc63dccdb9c68c5b9
parenteb07803e8106a66edfd80d078337dae240e92828 (diff)
parent30084a56a5731343bd4cec727646a6c55900234f (diff)
Merge #3923
3923: Cleanup keyword accessors r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_assists/src/handlers/inline_local_variable.rs2
-rw-r--r--crates/ra_hir_def/src/body/lower.rs10
-rw-r--r--crates/ra_hir_def/src/data.rs4
-rw-r--r--crates/ra_hir_def/src/type_ref.rs4
-rw-r--r--crates/ra_hir_ty/src/tests.rs4
-rw-r--r--crates/ra_ide/src/completion/complete_fn_param.rs30
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs4
-rw-r--r--crates/ra_ide/src/references.rs2
-rw-r--r--crates/ra_syntax/src/ast.rs6
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs10
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs18
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs144
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs916
-rw-r--r--crates/ra_syntax/src/ast/traits.rs12
-rw-r--r--xtask/src/ast_src.rs12
-rw-r--r--xtask/src/codegen/gen_syntax.rs33
16 files changed, 151 insertions, 1060 deletions
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs
index b9eb09676..c4fb425b0 100644
--- a/crates/ra_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ra_assists/src/handlers/inline_local_variable.rs
@@ -29,7 +29,7 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx) -> Option<Assist> {
29 ast::Pat::BindPat(pat) => pat, 29 ast::Pat::BindPat(pat) => pat,
30 _ => return None, 30 _ => return None,
31 }; 31 };
32 if bind_pat.mut_kw_token().is_some() { 32 if bind_pat.mut_token().is_some() {
33 tested_by!(test_not_inline_mut_variable); 33 tested_by!(test_not_inline_mut_variable);
34 return None; 34 return None;
35 } 35 }
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index df560155c..b0d71eb3d 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -372,7 +372,7 @@ impl ExprCollector<'_> {
372 } 372 }
373 ast::Expr::RefExpr(e) => { 373 ast::Expr::RefExpr(e) => {
374 let expr = self.collect_expr_opt(e.expr()); 374 let expr = self.collect_expr_opt(e.expr());
375 let mutability = Mutability::from_mutable(e.is_mut()); 375 let mutability = Mutability::from_mutable(e.mut_token().is_some());
376 self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr) 376 self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr)
377 } 377 }
378 ast::Expr::PrefixExpr(e) => { 378 ast::Expr::PrefixExpr(e) => {
@@ -587,10 +587,8 @@ impl ExprCollector<'_> {
587 let pattern = match &pat { 587 let pattern = match &pat {
588 ast::Pat::BindPat(bp) => { 588 ast::Pat::BindPat(bp) => {
589 let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing); 589 let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
590 let annotation = BindingAnnotation::new( 590 let annotation =
591 bp.mut_kw_token().is_some(), 591 BindingAnnotation::new(bp.mut_token().is_some(), bp.ref_token().is_some());
592 bp.ref_kw_token().is_some(),
593 );
594 let subpat = bp.pat().map(|subpat| self.collect_pat(subpat)); 592 let subpat = bp.pat().map(|subpat| self.collect_pat(subpat));
595 if annotation == BindingAnnotation::Unannotated && subpat.is_none() { 593 if annotation == BindingAnnotation::Unannotated && subpat.is_none() {
596 // This could also be a single-segment path pattern. To 594 // This could also be a single-segment path pattern. To
@@ -631,7 +629,7 @@ impl ExprCollector<'_> {
631 } 629 }
632 ast::Pat::RefPat(p) => { 630 ast::Pat::RefPat(p) => {
633 let pat = self.collect_pat_opt(p.pat()); 631 let pat = self.collect_pat_opt(p.pat());
634 let mutability = Mutability::from_mutable(p.mut_kw_token().is_some()); 632 let mutability = Mutability::from_mutable(p.mut_token().is_some());
635 Pat::Ref { pat, mutability } 633 Pat::Ref { pat, mutability }
636 } 634 }
637 ast::Pat::PathPat(p) => { 635 ast::Pat::PathPat(p) => {
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 419d62c28..b8fbf0ed4 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -74,7 +74,7 @@ impl FunctionData {
74 TypeRef::unit() 74 TypeRef::unit()
75 }; 75 };
76 76
77 let ret_type = if src.value.async_kw_token().is_some() { 77 let ret_type = if src.value.async_token().is_some() {
78 let future_impl = desugar_future_path(ret_type); 78 let future_impl = desugar_future_path(ret_type);
79 let ty_bound = TypeBound::Path(future_impl); 79 let ty_bound = TypeBound::Path(future_impl);
80 TypeRef::ImplTrait(vec![ty_bound]) 80 TypeRef::ImplTrait(vec![ty_bound])
@@ -135,7 +135,7 @@ impl TraitData {
135 pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> { 135 pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> {
136 let src = tr.lookup(db).source(db); 136 let src = tr.lookup(db).source(db);
137 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); 137 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
138 let auto = src.value.auto_kw_token().is_some(); 138 let auto = src.value.auto_token().is_some();
139 let ast_id_map = db.ast_id_map(src.file_id); 139 let ast_id_map = db.ast_id_map(src.file_id);
140 140
141 let container = AssocContainerId::TraitId(tr); 141 let container = AssocContainerId::TraitId(tr);
diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs
index 7a8338937..ea29c4176 100644
--- a/crates/ra_hir_def/src/type_ref.rs
+++ b/crates/ra_hir_def/src/type_ref.rs
@@ -77,7 +77,7 @@ impl TypeRef {
77 } 77 }
78 ast::TypeRef::PointerType(inner) => { 78 ast::TypeRef::PointerType(inner) => {
79 let inner_ty = TypeRef::from_ast_opt(inner.type_ref()); 79 let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
80 let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some()); 80 let mutability = Mutability::from_mutable(inner.mut_token().is_some());
81 TypeRef::RawPtr(Box::new(inner_ty), mutability) 81 TypeRef::RawPtr(Box::new(inner_ty), mutability)
82 } 82 }
83 ast::TypeRef::ArrayType(inner) => { 83 ast::TypeRef::ArrayType(inner) => {
@@ -88,7 +88,7 @@ impl TypeRef {
88 } 88 }
89 ast::TypeRef::ReferenceType(inner) => { 89 ast::TypeRef::ReferenceType(inner) => {
90 let inner_ty = TypeRef::from_ast_opt(inner.type_ref()); 90 let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
91 let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some()); 91 let mutability = Mutability::from_mutable(inner.mut_token().is_some());
92 TypeRef::Reference(Box::new(inner_ty), mutability) 92 TypeRef::Reference(Box::new(inner_ty), mutability)
93 } 93 }
94 ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder, 94 ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder,
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 3b078b8c7..002cffba6 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, AstToken}, 26 ast::{self, AstNode},
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().unwrap().syntax().text_range(), "self".to_string()) 104 (self_param.self_token().unwrap().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_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs
index 62ae5ccb4..f84b559fc 100644
--- a/crates/ra_ide/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide/src/completion/complete_fn_param.rs
@@ -1,6 +1,9 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use ra_syntax::{ast, match_ast, AstNode}; 3use ra_syntax::{
4 ast::{self, ModuleItemOwner},
5 match_ast, AstNode,
6};
4use rustc_hash::FxHashMap; 7use rustc_hash::FxHashMap;
5 8
6use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions}; 9use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions};
@@ -16,11 +19,19 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
16 19
17 let mut params = FxHashMap::default(); 20 let mut params = FxHashMap::default();
18 for node in ctx.token.parent().ancestors() { 21 for node in ctx.token.parent().ancestors() {
19 match_ast! { 22 let items = match_ast! {
20 match node { 23 match node {
21 ast::SourceFile(it) => process(it, &mut params), 24 ast::SourceFile(it) => it.items(),
22 ast::ItemList(it) => process(it, &mut params), 25 ast::ItemList(it) => it.items(),
23 _ => (), 26 _ => continue,
27 }
28 };
29 for item in items {
30 if let ast::ModuleItem::FnDef(func) = item {
31 func.param_list().into_iter().flat_map(|it| it.params()).for_each(|param| {
32 let text = param.syntax().text().to_string();
33 params.entry(text).or_insert((0, param)).0 += 1;
34 })
24 } 35 }
25 } 36 }
26 } 37 }
@@ -39,15 +50,6 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
39 .lookup_by(lookup) 50 .lookup_by(lookup)
40 .add_to(acc) 51 .add_to(acc)
41 }); 52 });
42
43 fn process<N: ast::FnDefOwner>(node: N, params: &mut FxHashMap<String, (u32, ast::Param)>) {
44 node.functions().filter_map(|it| it.param_list()).flat_map(|it| it.params()).for_each(
45 |param| {
46 let text = param.syntax().text().to_string();
47 params.entry(text).or_insert((0, param)).0 += 1;
48 },
49 )
50 }
51} 53}
52 54
53#[cfg(test)] 55#[cfg(test)]
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 0e34d85db..6637afaf7 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -191,8 +191,8 @@ impl<'a> CompletionContext<'a> {
191 if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) { 191 if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) {
192 self.is_pat_binding_or_const = true; 192 self.is_pat_binding_or_const = true;
193 if bind_pat.at_token().is_some() 193 if bind_pat.at_token().is_some()
194 || bind_pat.ref_kw_token().is_some() 194 || bind_pat.ref_token().is_some()
195 || bind_pat.mut_kw_token().is_some() 195 || bind_pat.mut_token().is_some()
196 { 196 {
197 self.is_pat_binding_or_const = false; 197 self.is_pat_binding_or_const = false;
198 } 198 }
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index ad6fd50aa..7d0544ff4 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -152,7 +152,7 @@ fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Optio
152 if stmt.initializer().is_some() { 152 if stmt.initializer().is_some() {
153 let pat = stmt.pat()?; 153 let pat = stmt.pat()?;
154 if let ast::Pat::BindPat(it) = pat { 154 if let ast::Pat::BindPat(it) = pat {
155 if it.mut_kw_token().is_some() { 155 if it.mut_token().is_some() {
156 return Some(ReferenceAccess::Write); 156 return Some(ReferenceAccess::Write);
157 } 157 }
158 } 158 }
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index cb701f7f6..1ee60e74c 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -80,7 +80,7 @@ impl<N: AstNode> Iterator for AstChildren<N> {
80} 80}
81 81
82mod support { 82mod support {
83 use super::{AstChildren, AstNode, AstToken, SyntaxNode}; 83 use super::{AstChildren, AstNode, AstToken, SyntaxKind, SyntaxNode, SyntaxToken};
84 84
85 pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> { 85 pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
86 parent.children().find_map(N::cast) 86 parent.children().find_map(N::cast)
@@ -93,6 +93,10 @@ mod support {
93 pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> { 93 pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
94 parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast) 94 parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
95 } 95 }
96
97 pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
98 parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
99 }
96} 100}
97 101
98#[test] 102#[test]
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 003ee00b3..93aa3d45f 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -48,16 +48,6 @@ impl ast::IfExpr {
48 } 48 }
49} 49}
50 50
51impl ast::RefExpr {
52 pub fn is_mut(&self) -> bool {
53 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
54 }
55
56 pub fn raw_token(&self) -> Option<SyntaxToken> {
57 None // FIXME: implement &raw
58 }
59}
60
61#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 51#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
62pub enum PrefixOp { 52pub enum PrefixOp {
63 /// The `*` operator for dereferencing 53 /// The `*` operator for dereferencing
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index fc252e79c..11ec70bc0 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -279,7 +279,7 @@ pub enum SelfParamKind {
279impl ast::SelfParam { 279impl ast::SelfParam {
280 pub fn kind(&self) -> SelfParamKind { 280 pub fn kind(&self) -> SelfParamKind {
281 if self.amp_token().is_some() { 281 if self.amp_token().is_some() {
282 if self.amp_mut_kw_token().is_some() { 282 if self.amp_mut_token().is_some() {
283 SelfParamKind::MutRef 283 SelfParamKind::MutRef
284 } else { 284 } else {
285 SelfParamKind::Ref 285 SelfParamKind::Ref
@@ -290,21 +290,21 @@ impl ast::SelfParam {
290 } 290 }
291 291
292 /// the "mut" in "mut self", not the one in "&mut self" 292 /// the "mut" in "mut self", not the one in "&mut self"
293 pub fn mut_kw_token(&self) -> Option<ast::MutKw> { 293 pub fn mut_token(&self) -> Option<SyntaxToken> {
294 self.syntax() 294 self.syntax()
295 .children_with_tokens() 295 .children_with_tokens()
296 .filter_map(|it| it.into_token()) 296 .filter_map(|it| it.into_token())
297 .take_while(|it| it.kind() != T![&]) 297 .take_while(|it| it.kind() != T![&])
298 .find_map(ast::MutKw::cast) 298 .find(|it| it.kind() == T![mut])
299 } 299 }
300 300
301 /// the "mut" in "&mut self", not the one in "mut self" 301 /// the "mut" in "&mut self", not the one in "mut self"
302 pub fn amp_mut_kw_token(&self) -> Option<ast::MutKw> { 302 pub fn amp_mut_token(&self) -> Option<SyntaxToken> {
303 self.syntax() 303 self.syntax()
304 .children_with_tokens() 304 .children_with_tokens()
305 .filter_map(|it| it.into_token()) 305 .filter_map(|it| it.into_token())
306 .skip_while(|it| it.kind() != T![&]) 306 .skip_while(|it| it.kind() != T![&])
307 .find_map(ast::MutKw::cast) 307 .find(|it| it.kind() == T![mut])
308 } 308 }
309} 309}
310 310
@@ -340,7 +340,7 @@ impl ast::TypeBound {
340 } 340 }
341 341
342 pub fn question_token(&self) -> Option<ast::Question> { 342 pub fn question_token(&self) -> Option<ast::Question> {
343 if self.const_kw_token().is_some() { 343 if self.const_token().is_some() {
344 self.syntax() 344 self.syntax()
345 .children_with_tokens() 345 .children_with_tokens()
346 .filter_map(|it| it.into_token()) 346 .filter_map(|it| it.into_token())
@@ -364,11 +364,11 @@ impl ast::Visibility {
364 pub fn kind(&self) -> VisibilityKind { 364 pub fn kind(&self) -> VisibilityKind {
365 if let Some(path) = support::children(self.syntax()).next() { 365 if let Some(path) = support::children(self.syntax()).next() {
366 VisibilityKind::In(path) 366 VisibilityKind::In(path)
367 } else if self.crate_kw_token().is_some() { 367 } else if self.crate_token().is_some() {
368 VisibilityKind::PubCrate 368 VisibilityKind::PubCrate
369 } else if self.super_kw_token().is_some() { 369 } else if self.super_token().is_some() {
370 VisibilityKind::PubSuper 370 VisibilityKind::PubSuper
371 } else if self.self_kw_token().is_some() { 371 } else if self.self_token().is_some() {
372 VisibilityKind::PubSuper 372 VisibilityKind::PubSuper
373 } else { 373 } else {
374 VisibilityKind::Pub 374 VisibilityKind::Pub
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index bcbfd1129..20f663046 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -4,7 +4,7 @@ use super::tokens::*;
4use crate::{ 4use crate::{
5 ast::{self, support, AstChildren, AstNode}, 5 ast::{self, support, AstChildren, AstNode},
6 SyntaxKind::{self, *}, 6 SyntaxKind::{self, *},
7 SyntaxNode, 7 SyntaxNode, SyntaxToken,
8}; 8};
9#[derive(Debug, Clone, PartialEq, Eq, Hash)] 9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
10pub struct SourceFile { 10pub struct SourceFile {
@@ -22,7 +22,6 @@ impl AstNode for SourceFile {
22 fn syntax(&self) -> &SyntaxNode { &self.syntax } 22 fn syntax(&self) -> &SyntaxNode { &self.syntax }
23} 23}
24impl ast::ModuleItemOwner for SourceFile {} 24impl ast::ModuleItemOwner for SourceFile {}
25impl ast::FnDefOwner for SourceFile {}
26impl ast::AttrsOwner for SourceFile {} 25impl ast::AttrsOwner for SourceFile {}
27impl SourceFile { 26impl SourceFile {
28 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } 27 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) }
@@ -49,11 +48,11 @@ impl ast::DocCommentsOwner for FnDef {}
49impl ast::AttrsOwner for FnDef {} 48impl ast::AttrsOwner for FnDef {}
50impl FnDef { 49impl FnDef {
51 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 50 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
52 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } 51 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
53 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 52 pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
54 pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) } 53 pub fn async_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ASYNC_KW) }
55 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 54 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
56 pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) } 55 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FN_KW) }
57 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 56 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
58 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 57 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
59 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 58 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
@@ -99,7 +98,7 @@ impl ast::TypeParamsOwner for StructDef {}
99impl ast::AttrsOwner for StructDef {} 98impl ast::AttrsOwner for StructDef {}
100impl ast::DocCommentsOwner for StructDef {} 99impl ast::DocCommentsOwner for StructDef {}
101impl StructDef { 100impl StructDef {
102 pub fn struct_kw_token(&self) -> Option<StructKw> { support::token(&self.syntax) } 101 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STRUCT_KW) }
103 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 102 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
104 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 103 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
105} 104}
@@ -124,7 +123,7 @@ impl ast::TypeParamsOwner for UnionDef {}
124impl ast::AttrsOwner for UnionDef {} 123impl ast::AttrsOwner for UnionDef {}
125impl ast::DocCommentsOwner for UnionDef {} 124impl ast::DocCommentsOwner for UnionDef {}
126impl UnionDef { 125impl UnionDef {
127 pub fn union_kw_token(&self) -> Option<UnionKw> { support::token(&self.syntax) } 126 pub fn union_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNION_KW) }
128 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 127 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
129 support::child(&self.syntax) 128 support::child(&self.syntax)
130 } 129 }
@@ -231,7 +230,7 @@ impl ast::TypeParamsOwner for EnumDef {}
231impl ast::AttrsOwner for EnumDef {} 230impl ast::AttrsOwner for EnumDef {}
232impl ast::DocCommentsOwner for EnumDef {} 231impl ast::DocCommentsOwner for EnumDef {}
233impl EnumDef { 232impl EnumDef {
234 pub fn enum_kw_token(&self) -> Option<EnumKw> { support::token(&self.syntax) } 233 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ENUM_KW) }
235 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } 234 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
236} 235}
237#[derive(Debug, Clone, PartialEq, Eq, Hash)] 236#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -300,9 +299,9 @@ impl ast::DocCommentsOwner for TraitDef {}
300impl ast::TypeParamsOwner for TraitDef {} 299impl ast::TypeParamsOwner for TraitDef {}
301impl ast::TypeBoundsOwner for TraitDef {} 300impl ast::TypeBoundsOwner for TraitDef {}
302impl TraitDef { 301impl TraitDef {
303 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 302 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
304 pub fn auto_kw_token(&self) -> Option<AutoKw> { support::token(&self.syntax) } 303 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AUTO_KW) }
305 pub fn trait_kw_token(&self) -> Option<TraitKw> { support::token(&self.syntax) } 304 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRAIT_KW) }
306 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 305 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
307} 306}
308#[derive(Debug, Clone, PartialEq, Eq, Hash)] 307#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -325,7 +324,7 @@ impl ast::NameOwner for Module {}
325impl ast::AttrsOwner for Module {} 324impl ast::AttrsOwner for Module {}
326impl ast::DocCommentsOwner for Module {} 325impl ast::DocCommentsOwner for Module {}
327impl Module { 326impl Module {
328 pub fn mod_kw_token(&self) -> Option<ModKw> { support::token(&self.syntax) } 327 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MOD_KW) }
329 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 328 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
330 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 329 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
331} 330}
@@ -344,7 +343,6 @@ impl AstNode for ItemList {
344 } 343 }
345 fn syntax(&self) -> &SyntaxNode { &self.syntax } 344 fn syntax(&self) -> &SyntaxNode { &self.syntax }
346} 345}
347impl ast::FnDefOwner for ItemList {}
348impl ast::ModuleItemOwner for ItemList {} 346impl ast::ModuleItemOwner for ItemList {}
349impl ItemList { 347impl ItemList {
350 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) } 348 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
@@ -373,8 +371,8 @@ impl ast::AttrsOwner for ConstDef {}
373impl ast::DocCommentsOwner for ConstDef {} 371impl ast::DocCommentsOwner for ConstDef {}
374impl ast::TypeAscriptionOwner for ConstDef {} 372impl ast::TypeAscriptionOwner for ConstDef {}
375impl ConstDef { 373impl ConstDef {
376 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 374 pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
377 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } 375 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
378 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 376 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
379 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 377 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
380 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 378 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
@@ -401,8 +399,8 @@ impl ast::AttrsOwner for StaticDef {}
401impl ast::DocCommentsOwner for StaticDef {} 399impl ast::DocCommentsOwner for StaticDef {}
402impl ast::TypeAscriptionOwner for StaticDef {} 400impl ast::TypeAscriptionOwner for StaticDef {}
403impl StaticDef { 401impl StaticDef {
404 pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) } 402 pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STATIC_KW) }
405 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } 403 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
406 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 404 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
407 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 405 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
408 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 406 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
@@ -429,8 +427,8 @@ impl ast::AttrsOwner for TypeAliasDef {}
429impl ast::DocCommentsOwner for TypeAliasDef {} 427impl ast::DocCommentsOwner for TypeAliasDef {}
430impl ast::TypeBoundsOwner for TypeAliasDef {} 428impl ast::TypeBoundsOwner for TypeAliasDef {}
431impl TypeAliasDef { 429impl TypeAliasDef {
432 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 430 pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
433 pub fn type_kw_token(&self) -> Option<TypeKw> { support::token(&self.syntax) } 431 pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TYPE_KW) }
434 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 432 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
435 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 433 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
436 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } 434 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
@@ -453,12 +451,12 @@ impl AstNode for ImplDef {
453impl ast::TypeParamsOwner for ImplDef {} 451impl ast::TypeParamsOwner for ImplDef {}
454impl ast::AttrsOwner for ImplDef {} 452impl ast::AttrsOwner for ImplDef {}
455impl ImplDef { 453impl ImplDef {
456 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 454 pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
457 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } 455 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
458 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 456 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
459 pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) } 457 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IMPL_KW) }
460 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } 458 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
461 pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) } 459 pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) }
462 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 460 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
463} 461}
464#[derive(Debug, Clone, PartialEq, Eq, Hash)] 462#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -554,8 +552,8 @@ impl AstNode for PointerType {
554} 552}
555impl PointerType { 553impl PointerType {
556 pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) } 554 pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) }
557 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } 555 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
558 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } 556 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
559 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 557 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
560} 558}
561#[derive(Debug, Clone, PartialEq, Eq, Hash)] 559#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -618,7 +616,7 @@ impl AstNode for ReferenceType {
618impl ReferenceType { 616impl ReferenceType {
619 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 617 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
620 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 618 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
621 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } 619 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
622 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 620 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
623} 621}
624#[derive(Debug, Clone, PartialEq, Eq, Hash)] 622#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -656,8 +654,8 @@ impl AstNode for FnPointerType {
656} 654}
657impl FnPointerType { 655impl FnPointerType {
658 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 656 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
659 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 657 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
660 pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) } 658 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FN_KW) }
661 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 659 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
662 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 660 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
663} 661}
@@ -677,7 +675,7 @@ impl AstNode for ForType {
677 fn syntax(&self) -> &SyntaxNode { &self.syntax } 675 fn syntax(&self) -> &SyntaxNode { &self.syntax }
678} 676}
679impl ForType { 677impl ForType {
680 pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) } 678 pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) }
681 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 679 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
682 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 680 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
683} 681}
@@ -698,7 +696,7 @@ impl AstNode for ImplTraitType {
698} 696}
699impl ast::TypeBoundsOwner for ImplTraitType {} 697impl ast::TypeBoundsOwner for ImplTraitType {}
700impl ImplTraitType { 698impl ImplTraitType {
701 pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) } 699 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IMPL_KW) }
702} 700}
703#[derive(Debug, Clone, PartialEq, Eq, Hash)] 701#[derive(Debug, Clone, PartialEq, Eq, Hash)]
704pub struct DynTraitType { 702pub struct DynTraitType {
@@ -717,7 +715,7 @@ impl AstNode for DynTraitType {
717} 715}
718impl ast::TypeBoundsOwner for DynTraitType {} 716impl ast::TypeBoundsOwner for DynTraitType {}
719impl DynTraitType { 717impl DynTraitType {
720 pub fn dyn_kw_token(&self) -> Option<DynKw> { support::token(&self.syntax) } 718 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DYN_KW) }
721} 719}
722#[derive(Debug, Clone, PartialEq, Eq, Hash)] 720#[derive(Debug, Clone, PartialEq, Eq, Hash)]
723pub struct TupleExpr { 721pub struct TupleExpr {
@@ -818,9 +816,9 @@ impl AstNode for LambdaExpr {
818} 816}
819impl ast::AttrsOwner for LambdaExpr {} 817impl ast::AttrsOwner for LambdaExpr {}
820impl LambdaExpr { 818impl LambdaExpr {
821 pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) } 819 pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STATIC_KW) }
822 pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) } 820 pub fn async_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ASYNC_KW) }
823 pub fn move_kw_token(&self) -> Option<MoveKw> { support::token(&self.syntax) } 821 pub fn move_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MOVE_KW) }
824 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 822 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
825 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 823 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
826 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 824 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -842,7 +840,7 @@ impl AstNode for IfExpr {
842} 840}
843impl ast::AttrsOwner for IfExpr {} 841impl ast::AttrsOwner for IfExpr {}
844impl IfExpr { 842impl IfExpr {
845 pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) } 843 pub fn if_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IF_KW) }
846 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 844 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
847} 845}
848#[derive(Debug, Clone, PartialEq, Eq, Hash)] 846#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -863,7 +861,7 @@ impl AstNode for LoopExpr {
863impl ast::AttrsOwner for LoopExpr {} 861impl ast::AttrsOwner for LoopExpr {}
864impl ast::LoopBodyOwner for LoopExpr {} 862impl ast::LoopBodyOwner for LoopExpr {}
865impl LoopExpr { 863impl LoopExpr {
866 pub fn loop_kw_token(&self) -> Option<LoopKw> { support::token(&self.syntax) } 864 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LOOP_KW) }
867} 865}
868#[derive(Debug, Clone, PartialEq, Eq, Hash)] 866#[derive(Debug, Clone, PartialEq, Eq, Hash)]
869pub struct TryBlockExpr { 867pub struct TryBlockExpr {
@@ -882,7 +880,7 @@ impl AstNode for TryBlockExpr {
882} 880}
883impl ast::AttrsOwner for TryBlockExpr {} 881impl ast::AttrsOwner for TryBlockExpr {}
884impl TryBlockExpr { 882impl TryBlockExpr {
885 pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) } 883 pub fn try_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRY_KW) }
886 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 884 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
887} 885}
888#[derive(Debug, Clone, PartialEq, Eq, Hash)] 886#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -903,9 +901,9 @@ impl AstNode for ForExpr {
903impl ast::AttrsOwner for ForExpr {} 901impl ast::AttrsOwner for ForExpr {}
904impl ast::LoopBodyOwner for ForExpr {} 902impl ast::LoopBodyOwner for ForExpr {}
905impl ForExpr { 903impl ForExpr {
906 pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) } 904 pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) }
907 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 905 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
908 pub fn in_kw_token(&self) -> Option<InKw> { support::token(&self.syntax) } 906 pub fn in_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IN_KW) }
909 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } 907 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
910} 908}
911#[derive(Debug, Clone, PartialEq, Eq, Hash)] 909#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -926,7 +924,7 @@ impl AstNode for WhileExpr {
926impl ast::AttrsOwner for WhileExpr {} 924impl ast::AttrsOwner for WhileExpr {}
927impl ast::LoopBodyOwner for WhileExpr {} 925impl ast::LoopBodyOwner for WhileExpr {}
928impl WhileExpr { 926impl WhileExpr {
929 pub fn while_kw_token(&self) -> Option<WhileKw> { support::token(&self.syntax) } 927 pub fn while_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, WHILE_KW) }
930 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 928 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
931} 929}
932#[derive(Debug, Clone, PartialEq, Eq, Hash)] 930#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -946,7 +944,9 @@ impl AstNode for ContinueExpr {
946} 944}
947impl ast::AttrsOwner for ContinueExpr {} 945impl ast::AttrsOwner for ContinueExpr {}
948impl ContinueExpr { 946impl ContinueExpr {
949 pub fn continue_kw_token(&self) -> Option<ContinueKw> { support::token(&self.syntax) } 947 pub fn continue_token(&self) -> Option<SyntaxToken> {
948 support::token2(&self.syntax, CONTINUE_KW)
949 }
950 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 950 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
951} 951}
952#[derive(Debug, Clone, PartialEq, Eq, Hash)] 952#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -966,7 +966,7 @@ impl AstNode for BreakExpr {
966} 966}
967impl ast::AttrsOwner for BreakExpr {} 967impl ast::AttrsOwner for BreakExpr {}
968impl BreakExpr { 968impl BreakExpr {
969 pub fn break_kw_token(&self) -> Option<BreakKw> { support::token(&self.syntax) } 969 pub fn break_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BREAK_KW) }
970 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 970 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
971 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 971 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
972} 972}
@@ -1006,7 +1006,7 @@ impl AstNode for BlockExpr {
1006impl ast::AttrsOwner for BlockExpr {} 1006impl ast::AttrsOwner for BlockExpr {}
1007impl BlockExpr { 1007impl BlockExpr {
1008 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } 1008 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1009 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 1009 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
1010 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) } 1010 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
1011} 1011}
1012#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1012#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1130,7 +1130,7 @@ impl ast::AttrsOwner for AwaitExpr {}
1130impl AwaitExpr { 1130impl AwaitExpr {
1131 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1131 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1132 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) } 1132 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) }
1133 pub fn await_kw_token(&self) -> Option<AwaitKw> { support::token(&self.syntax) } 1133 pub fn await_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AWAIT_KW) }
1134} 1134}
1135#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1135#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1136pub struct TryExpr { 1136pub struct TryExpr {
@@ -1149,7 +1149,7 @@ impl AstNode for TryExpr {
1149} 1149}
1150impl ast::AttrsOwner for TryExpr {} 1150impl ast::AttrsOwner for TryExpr {}
1151impl TryExpr { 1151impl TryExpr {
1152 pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) } 1152 pub fn try_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRY_KW) }
1153 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1153 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1154} 1154}
1155#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1155#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1170,7 +1170,7 @@ impl AstNode for CastExpr {
1170impl ast::AttrsOwner for CastExpr {} 1170impl ast::AttrsOwner for CastExpr {}
1171impl CastExpr { 1171impl CastExpr {
1172 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1172 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1173 pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) } 1173 pub fn as_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AS_KW) }
1174 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1174 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1175} 1175}
1176#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1176#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1191,8 +1191,8 @@ impl AstNode for RefExpr {
1191impl ast::AttrsOwner for RefExpr {} 1191impl ast::AttrsOwner for RefExpr {}
1192impl RefExpr { 1192impl RefExpr {
1193 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 1193 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
1194 pub fn raw_kw_token(&self) -> Option<RawKw> { support::token(&self.syntax) } 1194 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, RAW_KW) }
1195 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } 1195 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
1196 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1196 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1197} 1197}
1198#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1232,7 +1232,7 @@ impl AstNode for BoxExpr {
1232} 1232}
1233impl ast::AttrsOwner for BoxExpr {} 1233impl ast::AttrsOwner for BoxExpr {}
1234impl BoxExpr { 1234impl BoxExpr {
1235 pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) } 1235 pub fn box_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BOX_KW) }
1236 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1236 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1237} 1237}
1238#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1308,7 +1308,7 @@ impl AstNode for MatchExpr {
1308} 1308}
1309impl ast::AttrsOwner for MatchExpr {} 1309impl ast::AttrsOwner for MatchExpr {}
1310impl MatchExpr { 1310impl MatchExpr {
1311 pub fn match_kw_token(&self) -> Option<MatchKw> { support::token(&self.syntax) } 1311 pub fn match_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MATCH_KW) }
1312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1313 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } 1313 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1314} 1314}
@@ -1371,7 +1371,7 @@ impl AstNode for MatchGuard {
1371 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1371 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1372} 1372}
1373impl MatchGuard { 1373impl MatchGuard {
1374 pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) } 1374 pub fn if_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IF_KW) }
1375 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1375 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1376} 1376}
1377#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1491,7 +1491,7 @@ impl AstNode for RefPat {
1491} 1491}
1492impl RefPat { 1492impl RefPat {
1493 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 1493 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
1494 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } 1494 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
1495 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1495 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1496} 1496}
1497#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1497#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1510,7 +1510,7 @@ impl AstNode for BoxPat {
1510 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1510 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1511} 1511}
1512impl BoxPat { 1512impl BoxPat {
1513 pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) } 1513 pub fn box_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BOX_KW) }
1514 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1514 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1515} 1515}
1516#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1516#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1531,8 +1531,8 @@ impl AstNode for BindPat {
1531impl ast::AttrsOwner for BindPat {} 1531impl ast::AttrsOwner for BindPat {}
1532impl ast::NameOwner for BindPat {} 1532impl ast::NameOwner for BindPat {}
1533impl BindPat { 1533impl BindPat {
1534 pub fn ref_kw_token(&self) -> Option<RefKw> { support::token(&self.syntax) } 1534 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, REF_KW) }
1535 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } 1535 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
1536 pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) } 1536 pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) }
1537 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1537 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1538} 1538}
@@ -1788,10 +1788,10 @@ impl AstNode for Visibility {
1788 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1788 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1789} 1789}
1790impl Visibility { 1790impl Visibility {
1791 pub fn pub_kw_token(&self) -> Option<PubKw> { support::token(&self.syntax) } 1791 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, PUB_KW) }
1792 pub fn super_kw_token(&self) -> Option<SuperKw> { support::token(&self.syntax) } 1792 pub fn super_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SUPER_KW) }
1793 pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) } 1793 pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SELF_KW) }
1794 pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) } 1794 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CRATE_KW) }
1795} 1795}
1796#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1796#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1797pub struct Name { 1797pub struct Name {
@@ -1996,7 +1996,7 @@ impl AstNode for TypeBound {
1996} 1996}
1997impl TypeBound { 1997impl TypeBound {
1998 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 1998 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
1999 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } 1999 pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
2000 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2000 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2001} 2001}
2002#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2002#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2053,7 +2053,7 @@ impl AstNode for WhereClause {
2053 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2053 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2054} 2054}
2055impl WhereClause { 2055impl WhereClause {
2056 pub fn where_kw_token(&self) -> Option<WhereKw> { support::token(&self.syntax) } 2056 pub fn where_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, WHERE_KW) }
2057 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } 2057 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2058} 2058}
2059#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2059#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2112,7 +2112,7 @@ impl AstNode for LetStmt {
2112impl ast::AttrsOwner for LetStmt {} 2112impl ast::AttrsOwner for LetStmt {}
2113impl ast::TypeAscriptionOwner for LetStmt {} 2113impl ast::TypeAscriptionOwner for LetStmt {}
2114impl LetStmt { 2114impl LetStmt {
2115 pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) } 2115 pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LET_KW) }
2116 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2116 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2117 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2117 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2118 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 2118 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -2134,7 +2134,7 @@ impl AstNode for Condition {
2134 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2134 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2135} 2135}
2136impl Condition { 2136impl Condition {
2137 pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) } 2137 pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LET_KW) }
2138 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2138 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2139 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } 2139 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2140 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2140 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
@@ -2203,7 +2203,7 @@ impl ast::AttrsOwner for SelfParam {}
2203impl SelfParam { 2203impl SelfParam {
2204 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } 2204 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
2205 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2205 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
2206 pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) } 2206 pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SELF_KW) }
2207} 2207}
2208#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2209pub struct Param { 2209pub struct Param {
@@ -2244,7 +2244,7 @@ impl AstNode for UseItem {
2244impl ast::AttrsOwner for UseItem {} 2244impl ast::AttrsOwner for UseItem {}
2245impl ast::VisibilityOwner for UseItem {} 2245impl ast::VisibilityOwner for UseItem {}
2246impl UseItem { 2246impl UseItem {
2247 pub fn use_kw_token(&self) -> Option<UseKw> { support::token(&self.syntax) } 2247 pub fn use_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, USE_KW) }
2248 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } 2248 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2249} 2249}
2250#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2250#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -2285,7 +2285,7 @@ impl AstNode for Alias {
2285} 2285}
2286impl ast::NameOwner for Alias {} 2286impl ast::NameOwner for Alias {}
2287impl Alias { 2287impl Alias {
2288 pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) } 2288 pub fn as_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AS_KW) }
2289} 2289}
2290#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2290#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2291pub struct UseTreeList { 2291pub struct UseTreeList {
@@ -2325,8 +2325,8 @@ impl AstNode for ExternCrateItem {
2325impl ast::AttrsOwner for ExternCrateItem {} 2325impl ast::AttrsOwner for ExternCrateItem {}
2326impl ast::VisibilityOwner for ExternCrateItem {} 2326impl ast::VisibilityOwner for ExternCrateItem {}
2327impl ExternCrateItem { 2327impl ExternCrateItem {
2328 pub fn extern_kw_token(&self) -> Option<ExternKw> { support::token(&self.syntax) } 2328 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, EXTERN_KW) }
2329 pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) } 2329 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CRATE_KW) }
2330 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 2330 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2331 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 2331 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2332} 2332}
@@ -2512,7 +2512,6 @@ impl AstNode for MacroItems {
2512 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2512 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2513} 2513}
2514impl ast::ModuleItemOwner for MacroItems {} 2514impl ast::ModuleItemOwner for MacroItems {}
2515impl ast::FnDefOwner for MacroItems {}
2516impl MacroItems {} 2515impl MacroItems {}
2517#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2516#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2518pub struct MacroStmts { 2517pub struct MacroStmts {
@@ -2548,7 +2547,6 @@ impl AstNode for ExternItemList {
2548 } 2547 }
2549 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2548 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2550} 2549}
2551impl ast::FnDefOwner for ExternItemList {}
2552impl ast::ModuleItemOwner for ExternItemList {} 2550impl ast::ModuleItemOwner for ExternItemList {}
2553impl ExternItemList { 2551impl ExternItemList {
2554 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) } 2552 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index e64b8bce6..7344b0e49 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -1046,906 +1046,6 @@ impl AstToken for Shreq {
1046 fn syntax(&self) -> &SyntaxToken { &self.syntax } 1046 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1047} 1047}
1048#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1048#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1049pub struct AsKw {
1050 pub(crate) syntax: SyntaxToken,
1051}
1052impl std::fmt::Display for AsKw {
1053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1054 std::fmt::Display::fmt(&self.syntax, f)
1055 }
1056}
1057impl AstToken for AsKw {
1058 fn can_cast(kind: SyntaxKind) -> bool { kind == AS_KW }
1059 fn cast(syntax: SyntaxToken) -> Option<Self> {
1060 if Self::can_cast(syntax.kind()) {
1061 Some(Self { syntax })
1062 } else {
1063 None
1064 }
1065 }
1066 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1067}
1068#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1069pub struct AsyncKw {
1070 pub(crate) syntax: SyntaxToken,
1071}
1072impl std::fmt::Display for AsyncKw {
1073 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1074 std::fmt::Display::fmt(&self.syntax, f)
1075 }
1076}
1077impl AstToken for AsyncKw {
1078 fn can_cast(kind: SyntaxKind) -> bool { kind == ASYNC_KW }
1079 fn cast(syntax: SyntaxToken) -> Option<Self> {
1080 if Self::can_cast(syntax.kind()) {
1081 Some(Self { syntax })
1082 } else {
1083 None
1084 }
1085 }
1086 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1087}
1088#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1089pub struct AwaitKw {
1090 pub(crate) syntax: SyntaxToken,
1091}
1092impl std::fmt::Display for AwaitKw {
1093 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1094 std::fmt::Display::fmt(&self.syntax, f)
1095 }
1096}
1097impl AstToken for AwaitKw {
1098 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_KW }
1099 fn cast(syntax: SyntaxToken) -> Option<Self> {
1100 if Self::can_cast(syntax.kind()) {
1101 Some(Self { syntax })
1102 } else {
1103 None
1104 }
1105 }
1106 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1107}
1108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1109pub struct BoxKw {
1110 pub(crate) syntax: SyntaxToken,
1111}
1112impl std::fmt::Display for BoxKw {
1113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1114 std::fmt::Display::fmt(&self.syntax, f)
1115 }
1116}
1117impl AstToken for BoxKw {
1118 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_KW }
1119 fn cast(syntax: SyntaxToken) -> Option<Self> {
1120 if Self::can_cast(syntax.kind()) {
1121 Some(Self { syntax })
1122 } else {
1123 None
1124 }
1125 }
1126 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1127}
1128#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1129pub struct BreakKw {
1130 pub(crate) syntax: SyntaxToken,
1131}
1132impl std::fmt::Display for BreakKw {
1133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1134 std::fmt::Display::fmt(&self.syntax, f)
1135 }
1136}
1137impl AstToken for BreakKw {
1138 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_KW }
1139 fn cast(syntax: SyntaxToken) -> Option<Self> {
1140 if Self::can_cast(syntax.kind()) {
1141 Some(Self { syntax })
1142 } else {
1143 None
1144 }
1145 }
1146 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1147}
1148#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1149pub struct ConstKw {
1150 pub(crate) syntax: SyntaxToken,
1151}
1152impl std::fmt::Display for ConstKw {
1153 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1154 std::fmt::Display::fmt(&self.syntax, f)
1155 }
1156}
1157impl AstToken for ConstKw {
1158 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_KW }
1159 fn cast(syntax: SyntaxToken) -> Option<Self> {
1160 if Self::can_cast(syntax.kind()) {
1161 Some(Self { syntax })
1162 } else {
1163 None
1164 }
1165 }
1166 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1167}
1168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1169pub struct ContinueKw {
1170 pub(crate) syntax: SyntaxToken,
1171}
1172impl std::fmt::Display for ContinueKw {
1173 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1174 std::fmt::Display::fmt(&self.syntax, f)
1175 }
1176}
1177impl AstToken for ContinueKw {
1178 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_KW }
1179 fn cast(syntax: SyntaxToken) -> Option<Self> {
1180 if Self::can_cast(syntax.kind()) {
1181 Some(Self { syntax })
1182 } else {
1183 None
1184 }
1185 }
1186 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1187}
1188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1189pub struct CrateKw {
1190 pub(crate) syntax: SyntaxToken,
1191}
1192impl std::fmt::Display for CrateKw {
1193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1194 std::fmt::Display::fmt(&self.syntax, f)
1195 }
1196}
1197impl AstToken for CrateKw {
1198 fn can_cast(kind: SyntaxKind) -> bool { kind == CRATE_KW }
1199 fn cast(syntax: SyntaxToken) -> Option<Self> {
1200 if Self::can_cast(syntax.kind()) {
1201 Some(Self { syntax })
1202 } else {
1203 None
1204 }
1205 }
1206 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1207}
1208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1209pub struct DynKw {
1210 pub(crate) syntax: SyntaxToken,
1211}
1212impl std::fmt::Display for DynKw {
1213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1214 std::fmt::Display::fmt(&self.syntax, f)
1215 }
1216}
1217impl AstToken for DynKw {
1218 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_KW }
1219 fn cast(syntax: SyntaxToken) -> Option<Self> {
1220 if Self::can_cast(syntax.kind()) {
1221 Some(Self { syntax })
1222 } else {
1223 None
1224 }
1225 }
1226 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1227}
1228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1229pub struct ElseKw {
1230 pub(crate) syntax: SyntaxToken,
1231}
1232impl std::fmt::Display for ElseKw {
1233 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1234 std::fmt::Display::fmt(&self.syntax, f)
1235 }
1236}
1237impl AstToken for ElseKw {
1238 fn can_cast(kind: SyntaxKind) -> bool { kind == ELSE_KW }
1239 fn cast(syntax: SyntaxToken) -> Option<Self> {
1240 if Self::can_cast(syntax.kind()) {
1241 Some(Self { syntax })
1242 } else {
1243 None
1244 }
1245 }
1246 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1247}
1248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1249pub struct EnumKw {
1250 pub(crate) syntax: SyntaxToken,
1251}
1252impl std::fmt::Display for EnumKw {
1253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1254 std::fmt::Display::fmt(&self.syntax, f)
1255 }
1256}
1257impl AstToken for EnumKw {
1258 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_KW }
1259 fn cast(syntax: SyntaxToken) -> Option<Self> {
1260 if Self::can_cast(syntax.kind()) {
1261 Some(Self { syntax })
1262 } else {
1263 None
1264 }
1265 }
1266 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1267}
1268#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1269pub struct ExternKw {
1270 pub(crate) syntax: SyntaxToken,
1271}
1272impl std::fmt::Display for ExternKw {
1273 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1274 std::fmt::Display::fmt(&self.syntax, f)
1275 }
1276}
1277impl AstToken for ExternKw {
1278 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_KW }
1279 fn cast(syntax: SyntaxToken) -> Option<Self> {
1280 if Self::can_cast(syntax.kind()) {
1281 Some(Self { syntax })
1282 } else {
1283 None
1284 }
1285 }
1286 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1287}
1288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1289pub struct FalseKw {
1290 pub(crate) syntax: SyntaxToken,
1291}
1292impl std::fmt::Display for FalseKw {
1293 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1294 std::fmt::Display::fmt(&self.syntax, f)
1295 }
1296}
1297impl AstToken for FalseKw {
1298 fn can_cast(kind: SyntaxKind) -> bool { kind == FALSE_KW }
1299 fn cast(syntax: SyntaxToken) -> Option<Self> {
1300 if Self::can_cast(syntax.kind()) {
1301 Some(Self { syntax })
1302 } else {
1303 None
1304 }
1305 }
1306 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1307}
1308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1309pub struct FnKw {
1310 pub(crate) syntax: SyntaxToken,
1311}
1312impl std::fmt::Display for FnKw {
1313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1314 std::fmt::Display::fmt(&self.syntax, f)
1315 }
1316}
1317impl AstToken for FnKw {
1318 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_KW }
1319 fn cast(syntax: SyntaxToken) -> Option<Self> {
1320 if Self::can_cast(syntax.kind()) {
1321 Some(Self { syntax })
1322 } else {
1323 None
1324 }
1325 }
1326 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1327}
1328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1329pub struct ForKw {
1330 pub(crate) syntax: SyntaxToken,
1331}
1332impl std::fmt::Display for ForKw {
1333 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1334 std::fmt::Display::fmt(&self.syntax, f)
1335 }
1336}
1337impl AstToken for ForKw {
1338 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_KW }
1339 fn cast(syntax: SyntaxToken) -> Option<Self> {
1340 if Self::can_cast(syntax.kind()) {
1341 Some(Self { syntax })
1342 } else {
1343 None
1344 }
1345 }
1346 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1347}
1348#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1349pub struct IfKw {
1350 pub(crate) syntax: SyntaxToken,
1351}
1352impl std::fmt::Display for IfKw {
1353 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1354 std::fmt::Display::fmt(&self.syntax, f)
1355 }
1356}
1357impl AstToken for IfKw {
1358 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_KW }
1359 fn cast(syntax: SyntaxToken) -> Option<Self> {
1360 if Self::can_cast(syntax.kind()) {
1361 Some(Self { syntax })
1362 } else {
1363 None
1364 }
1365 }
1366 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1367}
1368#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1369pub struct ImplKw {
1370 pub(crate) syntax: SyntaxToken,
1371}
1372impl std::fmt::Display for ImplKw {
1373 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1374 std::fmt::Display::fmt(&self.syntax, f)
1375 }
1376}
1377impl AstToken for ImplKw {
1378 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_KW }
1379 fn cast(syntax: SyntaxToken) -> Option<Self> {
1380 if Self::can_cast(syntax.kind()) {
1381 Some(Self { syntax })
1382 } else {
1383 None
1384 }
1385 }
1386 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1387}
1388#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1389pub struct InKw {
1390 pub(crate) syntax: SyntaxToken,
1391}
1392impl std::fmt::Display for InKw {
1393 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1394 std::fmt::Display::fmt(&self.syntax, f)
1395 }
1396}
1397impl AstToken for InKw {
1398 fn can_cast(kind: SyntaxKind) -> bool { kind == IN_KW }
1399 fn cast(syntax: SyntaxToken) -> Option<Self> {
1400 if Self::can_cast(syntax.kind()) {
1401 Some(Self { syntax })
1402 } else {
1403 None
1404 }
1405 }
1406 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1407}
1408#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1409pub struct LetKw {
1410 pub(crate) syntax: SyntaxToken,
1411}
1412impl std::fmt::Display for LetKw {
1413 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1414 std::fmt::Display::fmt(&self.syntax, f)
1415 }
1416}
1417impl AstToken for LetKw {
1418 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_KW }
1419 fn cast(syntax: SyntaxToken) -> Option<Self> {
1420 if Self::can_cast(syntax.kind()) {
1421 Some(Self { syntax })
1422 } else {
1423 None
1424 }
1425 }
1426 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1427}
1428#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1429pub struct LoopKw {
1430 pub(crate) syntax: SyntaxToken,
1431}
1432impl std::fmt::Display for LoopKw {
1433 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1434 std::fmt::Display::fmt(&self.syntax, f)
1435 }
1436}
1437impl AstToken for LoopKw {
1438 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_KW }
1439 fn cast(syntax: SyntaxToken) -> Option<Self> {
1440 if Self::can_cast(syntax.kind()) {
1441 Some(Self { syntax })
1442 } else {
1443 None
1444 }
1445 }
1446 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1447}
1448#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1449pub struct MacroKw {
1450 pub(crate) syntax: SyntaxToken,
1451}
1452impl std::fmt::Display for MacroKw {
1453 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1454 std::fmt::Display::fmt(&self.syntax, f)
1455 }
1456}
1457impl AstToken for MacroKw {
1458 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_KW }
1459 fn cast(syntax: SyntaxToken) -> Option<Self> {
1460 if Self::can_cast(syntax.kind()) {
1461 Some(Self { syntax })
1462 } else {
1463 None
1464 }
1465 }
1466 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1467}
1468#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1469pub struct MatchKw {
1470 pub(crate) syntax: SyntaxToken,
1471}
1472impl std::fmt::Display for MatchKw {
1473 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1474 std::fmt::Display::fmt(&self.syntax, f)
1475 }
1476}
1477impl AstToken for MatchKw {
1478 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_KW }
1479 fn cast(syntax: SyntaxToken) -> Option<Self> {
1480 if Self::can_cast(syntax.kind()) {
1481 Some(Self { syntax })
1482 } else {
1483 None
1484 }
1485 }
1486 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1487}
1488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1489pub struct ModKw {
1490 pub(crate) syntax: SyntaxToken,
1491}
1492impl std::fmt::Display for ModKw {
1493 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1494 std::fmt::Display::fmt(&self.syntax, f)
1495 }
1496}
1497impl AstToken for ModKw {
1498 fn can_cast(kind: SyntaxKind) -> bool { kind == MOD_KW }
1499 fn cast(syntax: SyntaxToken) -> Option<Self> {
1500 if Self::can_cast(syntax.kind()) {
1501 Some(Self { syntax })
1502 } else {
1503 None
1504 }
1505 }
1506 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1507}
1508#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1509pub struct MoveKw {
1510 pub(crate) syntax: SyntaxToken,
1511}
1512impl std::fmt::Display for MoveKw {
1513 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1514 std::fmt::Display::fmt(&self.syntax, f)
1515 }
1516}
1517impl AstToken for MoveKw {
1518 fn can_cast(kind: SyntaxKind) -> bool { kind == MOVE_KW }
1519 fn cast(syntax: SyntaxToken) -> Option<Self> {
1520 if Self::can_cast(syntax.kind()) {
1521 Some(Self { syntax })
1522 } else {
1523 None
1524 }
1525 }
1526 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1527}
1528#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1529pub struct MutKw {
1530 pub(crate) syntax: SyntaxToken,
1531}
1532impl std::fmt::Display for MutKw {
1533 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1534 std::fmt::Display::fmt(&self.syntax, f)
1535 }
1536}
1537impl AstToken for MutKw {
1538 fn can_cast(kind: SyntaxKind) -> bool { kind == MUT_KW }
1539 fn cast(syntax: SyntaxToken) -> Option<Self> {
1540 if Self::can_cast(syntax.kind()) {
1541 Some(Self { syntax })
1542 } else {
1543 None
1544 }
1545 }
1546 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1547}
1548#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1549pub struct PubKw {
1550 pub(crate) syntax: SyntaxToken,
1551}
1552impl std::fmt::Display for PubKw {
1553 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1554 std::fmt::Display::fmt(&self.syntax, f)
1555 }
1556}
1557impl AstToken for PubKw {
1558 fn can_cast(kind: SyntaxKind) -> bool { kind == PUB_KW }
1559 fn cast(syntax: SyntaxToken) -> Option<Self> {
1560 if Self::can_cast(syntax.kind()) {
1561 Some(Self { syntax })
1562 } else {
1563 None
1564 }
1565 }
1566 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1567}
1568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1569pub struct RefKw {
1570 pub(crate) syntax: SyntaxToken,
1571}
1572impl std::fmt::Display for RefKw {
1573 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1574 std::fmt::Display::fmt(&self.syntax, f)
1575 }
1576}
1577impl AstToken for RefKw {
1578 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_KW }
1579 fn cast(syntax: SyntaxToken) -> Option<Self> {
1580 if Self::can_cast(syntax.kind()) {
1581 Some(Self { syntax })
1582 } else {
1583 None
1584 }
1585 }
1586 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1587}
1588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1589pub struct ReturnKw {
1590 pub(crate) syntax: SyntaxToken,
1591}
1592impl std::fmt::Display for ReturnKw {
1593 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1594 std::fmt::Display::fmt(&self.syntax, f)
1595 }
1596}
1597impl AstToken for ReturnKw {
1598 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_KW }
1599 fn cast(syntax: SyntaxToken) -> Option<Self> {
1600 if Self::can_cast(syntax.kind()) {
1601 Some(Self { syntax })
1602 } else {
1603 None
1604 }
1605 }
1606 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1607}
1608#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1609pub struct SelfKw {
1610 pub(crate) syntax: SyntaxToken,
1611}
1612impl std::fmt::Display for SelfKw {
1613 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1614 std::fmt::Display::fmt(&self.syntax, f)
1615 }
1616}
1617impl AstToken for SelfKw {
1618 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_KW }
1619 fn cast(syntax: SyntaxToken) -> Option<Self> {
1620 if Self::can_cast(syntax.kind()) {
1621 Some(Self { syntax })
1622 } else {
1623 None
1624 }
1625 }
1626 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1627}
1628#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1629pub struct StaticKw {
1630 pub(crate) syntax: SyntaxToken,
1631}
1632impl std::fmt::Display for StaticKw {
1633 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1634 std::fmt::Display::fmt(&self.syntax, f)
1635 }
1636}
1637impl AstToken for StaticKw {
1638 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_KW }
1639 fn cast(syntax: SyntaxToken) -> Option<Self> {
1640 if Self::can_cast(syntax.kind()) {
1641 Some(Self { syntax })
1642 } else {
1643 None
1644 }
1645 }
1646 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1647}
1648#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1649pub struct StructKw {
1650 pub(crate) syntax: SyntaxToken,
1651}
1652impl std::fmt::Display for StructKw {
1653 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1654 std::fmt::Display::fmt(&self.syntax, f)
1655 }
1656}
1657impl AstToken for StructKw {
1658 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_KW }
1659 fn cast(syntax: SyntaxToken) -> Option<Self> {
1660 if Self::can_cast(syntax.kind()) {
1661 Some(Self { syntax })
1662 } else {
1663 None
1664 }
1665 }
1666 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1667}
1668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1669pub struct SuperKw {
1670 pub(crate) syntax: SyntaxToken,
1671}
1672impl std::fmt::Display for SuperKw {
1673 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1674 std::fmt::Display::fmt(&self.syntax, f)
1675 }
1676}
1677impl AstToken for SuperKw {
1678 fn can_cast(kind: SyntaxKind) -> bool { kind == SUPER_KW }
1679 fn cast(syntax: SyntaxToken) -> Option<Self> {
1680 if Self::can_cast(syntax.kind()) {
1681 Some(Self { syntax })
1682 } else {
1683 None
1684 }
1685 }
1686 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1687}
1688#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1689pub struct TraitKw {
1690 pub(crate) syntax: SyntaxToken,
1691}
1692impl std::fmt::Display for TraitKw {
1693 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1694 std::fmt::Display::fmt(&self.syntax, f)
1695 }
1696}
1697impl AstToken for TraitKw {
1698 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_KW }
1699 fn cast(syntax: SyntaxToken) -> Option<Self> {
1700 if Self::can_cast(syntax.kind()) {
1701 Some(Self { syntax })
1702 } else {
1703 None
1704 }
1705 }
1706 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1707}
1708#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1709pub struct TrueKw {
1710 pub(crate) syntax: SyntaxToken,
1711}
1712impl std::fmt::Display for TrueKw {
1713 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1714 std::fmt::Display::fmt(&self.syntax, f)
1715 }
1716}
1717impl AstToken for TrueKw {
1718 fn can_cast(kind: SyntaxKind) -> bool { kind == TRUE_KW }
1719 fn cast(syntax: SyntaxToken) -> Option<Self> {
1720 if Self::can_cast(syntax.kind()) {
1721 Some(Self { syntax })
1722 } else {
1723 None
1724 }
1725 }
1726 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1727}
1728#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1729pub struct TryKw {
1730 pub(crate) syntax: SyntaxToken,
1731}
1732impl std::fmt::Display for TryKw {
1733 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1734 std::fmt::Display::fmt(&self.syntax, f)
1735 }
1736}
1737impl AstToken for TryKw {
1738 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_KW }
1739 fn cast(syntax: SyntaxToken) -> Option<Self> {
1740 if Self::can_cast(syntax.kind()) {
1741 Some(Self { syntax })
1742 } else {
1743 None
1744 }
1745 }
1746 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1747}
1748#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1749pub struct TypeKw {
1750 pub(crate) syntax: SyntaxToken,
1751}
1752impl std::fmt::Display for TypeKw {
1753 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1754 std::fmt::Display::fmt(&self.syntax, f)
1755 }
1756}
1757impl AstToken for TypeKw {
1758 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_KW }
1759 fn cast(syntax: SyntaxToken) -> Option<Self> {
1760 if Self::can_cast(syntax.kind()) {
1761 Some(Self { syntax })
1762 } else {
1763 None
1764 }
1765 }
1766 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1767}
1768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1769pub struct UnsafeKw {
1770 pub(crate) syntax: SyntaxToken,
1771}
1772impl std::fmt::Display for UnsafeKw {
1773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1774 std::fmt::Display::fmt(&self.syntax, f)
1775 }
1776}
1777impl AstToken for UnsafeKw {
1778 fn can_cast(kind: SyntaxKind) -> bool { kind == UNSAFE_KW }
1779 fn cast(syntax: SyntaxToken) -> Option<Self> {
1780 if Self::can_cast(syntax.kind()) {
1781 Some(Self { syntax })
1782 } else {
1783 None
1784 }
1785 }
1786 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1787}
1788#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1789pub struct UseKw {
1790 pub(crate) syntax: SyntaxToken,
1791}
1792impl std::fmt::Display for UseKw {
1793 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1794 std::fmt::Display::fmt(&self.syntax, f)
1795 }
1796}
1797impl AstToken for UseKw {
1798 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_KW }
1799 fn cast(syntax: SyntaxToken) -> Option<Self> {
1800 if Self::can_cast(syntax.kind()) {
1801 Some(Self { syntax })
1802 } else {
1803 None
1804 }
1805 }
1806 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1807}
1808#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1809pub struct WhereKw {
1810 pub(crate) syntax: SyntaxToken,
1811}
1812impl std::fmt::Display for WhereKw {
1813 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1814 std::fmt::Display::fmt(&self.syntax, f)
1815 }
1816}
1817impl AstToken for WhereKw {
1818 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_KW }
1819 fn cast(syntax: SyntaxToken) -> Option<Self> {
1820 if Self::can_cast(syntax.kind()) {
1821 Some(Self { syntax })
1822 } else {
1823 None
1824 }
1825 }
1826 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1827}
1828#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1829pub struct WhileKw {
1830 pub(crate) syntax: SyntaxToken,
1831}
1832impl std::fmt::Display for WhileKw {
1833 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1834 std::fmt::Display::fmt(&self.syntax, f)
1835 }
1836}
1837impl AstToken for WhileKw {
1838 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_KW }
1839 fn cast(syntax: SyntaxToken) -> Option<Self> {
1840 if Self::can_cast(syntax.kind()) {
1841 Some(Self { syntax })
1842 } else {
1843 None
1844 }
1845 }
1846 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1847}
1848#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1849pub struct AutoKw {
1850 pub(crate) syntax: SyntaxToken,
1851}
1852impl std::fmt::Display for AutoKw {
1853 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1854 std::fmt::Display::fmt(&self.syntax, f)
1855 }
1856}
1857impl AstToken for AutoKw {
1858 fn can_cast(kind: SyntaxKind) -> bool { kind == AUTO_KW }
1859 fn cast(syntax: SyntaxToken) -> Option<Self> {
1860 if Self::can_cast(syntax.kind()) {
1861 Some(Self { syntax })
1862 } else {
1863 None
1864 }
1865 }
1866 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1867}
1868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1869pub struct DefaultKw {
1870 pub(crate) syntax: SyntaxToken,
1871}
1872impl std::fmt::Display for DefaultKw {
1873 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1874 std::fmt::Display::fmt(&self.syntax, f)
1875 }
1876}
1877impl AstToken for DefaultKw {
1878 fn can_cast(kind: SyntaxKind) -> bool { kind == DEFAULT_KW }
1879 fn cast(syntax: SyntaxToken) -> Option<Self> {
1880 if Self::can_cast(syntax.kind()) {
1881 Some(Self { syntax })
1882 } else {
1883 None
1884 }
1885 }
1886 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1887}
1888#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1889pub struct ExistentialKw {
1890 pub(crate) syntax: SyntaxToken,
1891}
1892impl std::fmt::Display for ExistentialKw {
1893 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1894 std::fmt::Display::fmt(&self.syntax, f)
1895 }
1896}
1897impl AstToken for ExistentialKw {
1898 fn can_cast(kind: SyntaxKind) -> bool { kind == EXISTENTIAL_KW }
1899 fn cast(syntax: SyntaxToken) -> Option<Self> {
1900 if Self::can_cast(syntax.kind()) {
1901 Some(Self { syntax })
1902 } else {
1903 None
1904 }
1905 }
1906 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1907}
1908#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1909pub struct UnionKw {
1910 pub(crate) syntax: SyntaxToken,
1911}
1912impl std::fmt::Display for UnionKw {
1913 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1914 std::fmt::Display::fmt(&self.syntax, f)
1915 }
1916}
1917impl AstToken for UnionKw {
1918 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_KW }
1919 fn cast(syntax: SyntaxToken) -> Option<Self> {
1920 if Self::can_cast(syntax.kind()) {
1921 Some(Self { syntax })
1922 } else {
1923 None
1924 }
1925 }
1926 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1927}
1928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1929pub struct RawKw {
1930 pub(crate) syntax: SyntaxToken,
1931}
1932impl std::fmt::Display for RawKw {
1933 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1934 std::fmt::Display::fmt(&self.syntax, f)
1935 }
1936}
1937impl AstToken for RawKw {
1938 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_KW }
1939 fn cast(syntax: SyntaxToken) -> Option<Self> {
1940 if Self::can_cast(syntax.kind()) {
1941 Some(Self { syntax })
1942 } else {
1943 None
1944 }
1945 }
1946 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1947}
1948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1949pub struct IntNumber { 1049pub struct IntNumber {
1950 pub(crate) syntax: SyntaxToken, 1050 pub(crate) syntax: SyntaxToken,
1951} 1051}
@@ -2687,8 +1787,6 @@ pub enum LiteralToken {
2687 FloatNumber(FloatNumber), 1787 FloatNumber(FloatNumber),
2688 String(String), 1788 String(String),
2689 RawString(RawString), 1789 RawString(RawString),
2690 TrueKw(TrueKw),
2691 FalseKw(FalseKw),
2692 ByteString(ByteString), 1790 ByteString(ByteString),
2693 RawByteString(RawByteString), 1791 RawByteString(RawByteString),
2694 Char(Char), 1792 Char(Char),
@@ -2706,12 +1804,6 @@ impl From<String> for LiteralToken {
2706impl From<RawString> for LiteralToken { 1804impl From<RawString> for LiteralToken {
2707 fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) } 1805 fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) }
2708} 1806}
2709impl From<TrueKw> for LiteralToken {
2710 fn from(node: TrueKw) -> LiteralToken { LiteralToken::TrueKw(node) }
2711}
2712impl From<FalseKw> for LiteralToken {
2713 fn from(node: FalseKw) -> LiteralToken { LiteralToken::FalseKw(node) }
2714}
2715impl From<ByteString> for LiteralToken { 1807impl From<ByteString> for LiteralToken {
2716 fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) } 1808 fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) }
2717} 1809}
@@ -2732,8 +1824,8 @@ impl std::fmt::Display for LiteralToken {
2732impl AstToken for LiteralToken { 1824impl AstToken for LiteralToken {
2733 fn can_cast(kind: SyntaxKind) -> bool { 1825 fn can_cast(kind: SyntaxKind) -> bool {
2734 match kind { 1826 match kind {
2735 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING 1827 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING
2736 | RAW_BYTE_STRING | CHAR | BYTE => true, 1828 | CHAR | BYTE => true,
2737 _ => false, 1829 _ => false,
2738 } 1830 }
2739 } 1831 }
@@ -2743,8 +1835,6 @@ impl AstToken for LiteralToken {
2743 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }), 1835 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
2744 STRING => LiteralToken::String(String { syntax }), 1836 STRING => LiteralToken::String(String { syntax }),
2745 RAW_STRING => LiteralToken::RawString(RawString { syntax }), 1837 RAW_STRING => LiteralToken::RawString(RawString { syntax }),
2746 TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
2747 FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
2748 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }), 1838 BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
2749 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }), 1839 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
2750 CHAR => LiteralToken::Char(Char { syntax }), 1840 CHAR => LiteralToken::Char(Char { syntax }),
@@ -2759,8 +1849,6 @@ impl AstToken for LiteralToken {
2759 LiteralToken::FloatNumber(it) => &it.syntax, 1849 LiteralToken::FloatNumber(it) => &it.syntax,
2760 LiteralToken::String(it) => &it.syntax, 1850 LiteralToken::String(it) => &it.syntax,
2761 LiteralToken::RawString(it) => &it.syntax, 1851 LiteralToken::RawString(it) => &it.syntax,
2762 LiteralToken::TrueKw(it) => &it.syntax,
2763 LiteralToken::FalseKw(it) => &it.syntax,
2764 LiteralToken::ByteString(it) => &it.syntax, 1852 LiteralToken::ByteString(it) => &it.syntax,
2765 LiteralToken::RawByteString(it) => &it.syntax, 1853 LiteralToken::RawByteString(it) => &it.syntax,
2766 LiteralToken::Char(it) => &it.syntax, 1854 LiteralToken::Char(it) => &it.syntax,
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index f6c786e44..4ed7cf73b 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -1,8 +1,7 @@
1//! Various traits that are implemented by ast nodes. 1//! Various traits that are implemented by ast nodes.
2//! 2//!
3//! The implementations are usually trivial, and live in generated.rs 3//! The implementations are usually trivial, and live in generated.rs
4 4use stdx::SepBy;
5use itertools::Itertools;
6 5
7use crate::{ 6use crate::{
8 ast::{self, support, AstChildren, AstNode, AstToken}, 7 ast::{self, support, AstChildren, AstNode, AstToken},
@@ -43,12 +42,6 @@ pub trait ArgListOwner: AstNode {
43 } 42 }
44} 43}
45 44
46pub trait FnDefOwner: AstNode {
47 fn functions(&self) -> AstChildren<ast::FnDef> {
48 support::children(self.syntax())
49 }
50}
51
52pub trait ModuleItemOwner: AstNode { 45pub trait ModuleItemOwner: AstNode {
53 fn items(&self) -> AstChildren<ast::ModuleItem> { 46 fn items(&self) -> AstChildren<ast::ModuleItem> {
54 support::children(self.syntax()) 47 support::children(self.syntax())
@@ -122,7 +115,8 @@ pub trait DocCommentsOwner: AstNode {
122 // of a line in markdown. 115 // of a line in markdown.
123 line[pos..end].to_owned() 116 line[pos..end].to_owned()
124 }) 117 })
125 .join("\n"); 118 .sep_by("\n")
119 .to_string();
126 120
127 if has_comments { 121 if has_comments {
128 Some(docs) 122 Some(docs)
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs
index 74a87e900..bb97b13fe 100644
--- a/xtask/src/ast_src.rs
+++ b/xtask/src/ast_src.rs
@@ -298,7 +298,7 @@ macro_rules! ast_enums {
298 298
299pub(crate) const AST_SRC: AstSrc = AstSrc { 299pub(crate) const AST_SRC: AstSrc = AstSrc {
300 nodes: &ast_nodes! { 300 nodes: &ast_nodes! {
301 struct SourceFile: ModuleItemOwner, FnDefOwner, AttrsOwner { 301 struct SourceFile: ModuleItemOwner, AttrsOwner {
302 modules: [Module], 302 modules: [Module],
303 } 303 }
304 304
@@ -364,7 +364,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
364 Semi 364 Semi
365 } 365 }
366 366
367 struct ItemList: FnDefOwner, ModuleItemOwner { 367 struct ItemList: ModuleItemOwner {
368 LCurly, 368 LCurly,
369 impl_items: [ImplItem], 369 impl_items: [ImplItem],
370 RCurly 370 RCurly
@@ -604,14 +604,14 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
604 struct LifetimeArg { Lifetime } 604 struct LifetimeArg { Lifetime }
605 struct ConstArg { Literal, Eq, BlockExpr } 605 struct ConstArg { Literal, Eq, BlockExpr }
606 606
607 struct MacroItems: ModuleItemOwner, FnDefOwner { } 607 struct MacroItems: ModuleItemOwner{ }
608 608
609 struct MacroStmts { 609 struct MacroStmts {
610 statements: [Stmt], 610 statements: [Stmt],
611 Expr, 611 Expr,
612 } 612 }
613 613
614 struct ExternItemList: FnDefOwner, ModuleItemOwner { 614 struct ExternItemList: ModuleItemOwner {
615 LCurly, 615 LCurly,
616 extern_items: [ExternItem], 616 extern_items: [ExternItem],
617 RCurly 617 RCurly
@@ -814,8 +814,8 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
814 FloatNumber, 814 FloatNumber,
815 String, 815 String,
816 RawString, 816 RawString,
817 TrueKw, 817 // TrueKw,
818 FalseKw, 818 // FalseKw,
819 ByteString, 819 ByteString,
820 RawByteString, 820 RawByteString,
821 Char, 821 Char,
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index b5594e3a9..cc98802f6 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -58,11 +58,14 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
58 .chain(kinds.tokens.into_iter().copied().map(|x| x.into())) 58 .chain(kinds.tokens.into_iter().copied().map(|x| x.into()))
59 .collect(); 59 .collect();
60 60
61 let tokens = all_token_kinds.iter().map(|kind_str| { 61 let tokens = all_token_kinds.iter().filter_map(|kind_str| {
62 if kind_str.ends_with("_KW") {
63 return None;
64 }
62 let kind_str = &**kind_str; 65 let kind_str = &**kind_str;
63 let kind = format_ident!("{}", kind_str); 66 let kind = format_ident!("{}", kind_str);
64 let name = format_ident!("{}", to_pascal_case(kind_str)); 67 let name = format_ident!("{}", to_pascal_case(kind_str));
65 quote! { 68 let res = quote! {
66 #[derive(Debug, Clone, PartialEq, Eq, Hash)] 69 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
67 pub struct #name { 70 pub struct #name {
68 pub(crate) syntax: SyntaxToken, 71 pub(crate) syntax: SyntaxToken,
@@ -81,7 +84,8 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
81 } 84 }
82 fn syntax(&self) -> &SyntaxToken { &self.syntax } 85 fn syntax(&self) -> &SyntaxToken { &self.syntax }
83 } 86 }
84 } 87 };
88 Some(res)
85 }); 89 });
86 90
87 let enums = grammar.token_enums.iter().map(|en| { 91 let enums = grammar.token_enums.iter().map(|en| {
@@ -186,8 +190,12 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
186 }); 190 });
187 191
188 let methods = node.fields.iter().map(|(name, field)| { 192 let methods = node.fields.iter().map(|(name, field)| {
193 let is_kw = name.ends_with("Kw");
189 let method_name = match field { 194 let method_name = match field {
190 FieldSrc::Shorthand => format_ident!("{}", to_lower_snake_case(&name)), 195 FieldSrc::Shorthand => {
196 let name = if is_kw { &name[..name.len() - 2] } else { &name };
197 format_ident!("{}", to_lower_snake_case(name))
198 }
191 _ => format_ident!("{}", name), 199 _ => format_ident!("{}", name),
192 }; 200 };
193 let ty = match field { 201 let ty = match field {
@@ -209,9 +217,18 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
209 let is_token = token_kinds.contains(&ty.to_string()); 217 let is_token = token_kinds.contains(&ty.to_string());
210 if is_token { 218 if is_token {
211 let method_name = format_ident!("{}_token", method_name); 219 let method_name = format_ident!("{}_token", method_name);
212 quote! { 220 if is_kw {
213 pub fn #method_name(&self) -> Option<#ty> { 221 let token_kind = format_ident!("{}", to_upper_snake_case(name));
214 support::token(&self.syntax) 222 quote! {
223 pub fn #method_name(&self) -> Option<SyntaxToken> {
224 support::token2(&self.syntax, #token_kind)
225 }
226 }
227 } else {
228 quote! {
229 pub fn #method_name(&self) -> Option<#ty> {
230 support::token(&self.syntax)
231 }
215 } 232 }
216 } 233 }
217 } else { 234 } else {
@@ -332,7 +349,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
332 349
333 let ast = quote! { 350 let ast = quote! {
334 use crate::{ 351 use crate::{
335 SyntaxNode, SyntaxKind::{self, *}, 352 SyntaxNode, SyntaxToken, SyntaxKind::{self, *},
336 ast::{self, AstNode, AstChildren, support}, 353 ast::{self, AstNode, AstChildren, support},
337 }; 354 };
338 355