aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs19
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs32
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs229
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs556
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs2741
-rw-r--r--crates/ra_syntax/src/ast/make.rs3
-rw-r--r--crates/ra_syntax/src/ast/traits.rs41
7 files changed, 471 insertions, 3150 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index d79310995..9e5411ee5 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -6,7 +6,7 @@ use std::{iter, ops::RangeInclusive};
6use arrayvec::ArrayVec; 6use arrayvec::ArrayVec;
7 7
8use crate::{ 8use crate::{
9 algo, 9 algo::{self, neighbor, SyntaxRewriter},
10 ast::{ 10 ast::{
11 self, 11 self,
12 make::{self, tokens}, 12 make::{self, tokens},
@@ -16,7 +16,6 @@ use crate::{
16 SyntaxKind::{ATTR, COMMENT, WHITESPACE}, 16 SyntaxKind::{ATTR, COMMENT, WHITESPACE},
17 SyntaxNode, SyntaxToken, T, 17 SyntaxNode, SyntaxToken, T,
18}; 18};
19use algo::{neighbor, SyntaxRewriter};
20 19
21impl ast::BinExpr { 20impl ast::BinExpr {
22 #[must_use] 21 #[must_use]
@@ -96,10 +95,10 @@ impl ast::ItemList {
96 leading_indent(it.syntax()).unwrap_or_default().to_string(), 95 leading_indent(it.syntax()).unwrap_or_default().to_string(),
97 InsertPosition::After(it.syntax().clone().into()), 96 InsertPosition::After(it.syntax().clone().into()),
98 ), 97 ),
99 None => match self.l_curly() { 98 None => match self.l_curly_token() {
100 Some(it) => ( 99 Some(it) => (
101 " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), 100 " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(),
102 InsertPosition::After(it.syntax().clone().into()), 101 InsertPosition::After(it.into()),
103 ), 102 ),
104 None => return self.clone(), 103 None => return self.clone(),
105 }, 104 },
@@ -142,8 +141,8 @@ impl ast::RecordFieldList {
142 141
143 macro_rules! after_l_curly { 142 macro_rules! after_l_curly {
144 () => {{ 143 () => {{
145 let anchor = match self.l_curly() { 144 let anchor = match self.l_curly_token() {
146 Some(it) => it.syntax().clone().into(), 145 Some(it) => it.into(),
147 None => return self.clone(), 146 None => return self.clone(),
148 }; 147 };
149 InsertPosition::After(anchor) 148 InsertPosition::After(anchor)
@@ -190,15 +189,15 @@ impl ast::RecordFieldList {
190impl ast::TypeParam { 189impl ast::TypeParam {
191 #[must_use] 190 #[must_use]
192 pub fn remove_bounds(&self) -> ast::TypeParam { 191 pub fn remove_bounds(&self) -> ast::TypeParam {
193 let colon = match self.colon() { 192 let colon = match self.colon_token() {
194 Some(it) => it, 193 Some(it) => it,
195 None => return self.clone(), 194 None => return self.clone(),
196 }; 195 };
197 let end = match self.type_bound_list() { 196 let end = match self.type_bound_list() {
198 Some(it) => it.syntax().clone().into(), 197 Some(it) => it.syntax().clone().into(),
199 None => colon.syntax().clone().into(), 198 None => colon.clone().into(),
200 }; 199 };
201 self.replace_children(colon.syntax().clone().into()..=end, iter::empty()) 200 self.replace_children(colon.into()..=end, iter::empty())
202 } 201 }
203} 202}
204 203
@@ -301,7 +300,7 @@ impl ast::UseTree {
301 suffix.clone(), 300 suffix.clone(),
302 self.use_tree_list(), 301 self.use_tree_list(),
303 self.alias(), 302 self.alias(),
304 self.star().is_some(), 303 self.star_token().is_some(),
305 ); 304 );
306 let nested = make::use_tree_list(iter::once(use_tree)); 305 let nested = make::use_tree_list(iter::once(use_tree));
307 return make::use_tree(prefix.clone(), Some(nested), None, false); 306 return make::use_tree(prefix.clone(), Some(nested), None, false);
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 40c8fca3b..93aa3d45f 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -1,7 +1,7 @@
1//! Various extension methods to ast Expr Nodes, which are hard to code-generate. 1//! Various extension methods to ast Expr Nodes, which are hard to code-generate.
2 2
3use crate::{ 3use crate::{
4 ast::{self, child_opt, children, AstChildren, AstNode}, 4 ast::{self, support, AstChildren, AstNode},
5 SmolStr, 5 SmolStr,
6 SyntaxKind::*, 6 SyntaxKind::*,
7 SyntaxToken, T, 7 SyntaxToken, T,
@@ -36,7 +36,7 @@ impl ast::IfExpr {
36 let res = match self.blocks().nth(1) { 36 let res = match self.blocks().nth(1) {
37 Some(block) => ElseBranch::Block(block), 37 Some(block) => ElseBranch::Block(block),
38 None => { 38 None => {
39 let elif: ast::IfExpr = child_opt(self)?; 39 let elif: ast::IfExpr = support::child(self.syntax())?;
40 ElseBranch::IfExpr(elif) 40 ElseBranch::IfExpr(elif)
41 } 41 }
42 }; 42 };
@@ -44,17 +44,7 @@ impl ast::IfExpr {
44 } 44 }
45 45
46 fn blocks(&self) -> AstChildren<ast::BlockExpr> { 46 fn blocks(&self) -> AstChildren<ast::BlockExpr> {
47 children(self) 47 support::children(self.syntax())
48 }
49}
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 } 48 }
59} 49}
60 50
@@ -212,15 +202,15 @@ impl ast::BinExpr {
212 } 202 }
213 203
214 pub fn lhs(&self) -> Option<ast::Expr> { 204 pub fn lhs(&self) -> Option<ast::Expr> {
215 children(self).next() 205 support::children(self.syntax()).next()
216 } 206 }
217 207
218 pub fn rhs(&self) -> Option<ast::Expr> { 208 pub fn rhs(&self) -> Option<ast::Expr> {
219 children(self).nth(1) 209 support::children(self.syntax()).nth(1)
220 } 210 }
221 211
222 pub fn sub_exprs(&self) -> (Option<ast::Expr>, Option<ast::Expr>) { 212 pub fn sub_exprs(&self) -> (Option<ast::Expr>, Option<ast::Expr>) {
223 let mut children = children(self); 213 let mut children = support::children(self.syntax());
224 let first = children.next(); 214 let first = children.next();
225 let second = children.next(); 215 let second = children.next();
226 (first, second) 216 (first, second)
@@ -275,10 +265,10 @@ impl ast::RangeExpr {
275 265
276impl ast::IndexExpr { 266impl ast::IndexExpr {
277 pub fn base(&self) -> Option<ast::Expr> { 267 pub fn base(&self) -> Option<ast::Expr> {
278 children(self).next() 268 support::children(self.syntax()).next()
279 } 269 }
280 pub fn index(&self) -> Option<ast::Expr> { 270 pub fn index(&self) -> Option<ast::Expr> {
281 children(self).nth(1) 271 support::children(self.syntax()).nth(1)
282 } 272 }
283} 273}
284 274
@@ -291,11 +281,11 @@ impl ast::ArrayExpr {
291 pub fn kind(&self) -> ArrayExprKind { 281 pub fn kind(&self) -> ArrayExprKind {
292 if self.is_repeat() { 282 if self.is_repeat() {
293 ArrayExprKind::Repeat { 283 ArrayExprKind::Repeat {
294 initializer: children(self).next(), 284 initializer: support::children(self.syntax()).next(),
295 repeat: children(self).nth(1), 285 repeat: support::children(self.syntax()).nth(1),
296 } 286 }
297 } else { 287 } else {
298 ArrayExprKind::ElementList(children(self)) 288 ArrayExprKind::ElementList(support::children(self.syntax()))
299 } 289 }
300 } 290 }
301 291
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 33fe60762..63e272fbf 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -2,16 +2,12 @@
2//! Extensions for various expressions live in a sibling `expr_extensions` module. 2//! Extensions for various expressions live in a sibling `expr_extensions` module.
3 3
4use itertools::Itertools; 4use itertools::Itertools;
5use ra_parser::SyntaxKind;
5 6
6use crate::{ 7use crate::{
7 ast::{ 8 ast::{self, support, AstNode, AttrInput, NameOwner, SyntaxNode},
8 self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode, 9 SmolStr, SyntaxElement, SyntaxToken, T,
9 },
10 SmolStr, SyntaxElement,
11 SyntaxKind::*,
12 SyntaxToken, T,
13}; 10};
14use ra_parser::SyntaxKind;
15 11
16impl ast::Name { 12impl ast::Name {
17 pub fn text(&self) -> &SmolStr { 13 pub fn text(&self) -> &SmolStr {
@@ -25,13 +21,7 @@ impl ast::NameRef {
25 } 21 }
26 22
27 pub fn as_tuple_field(&self) -> Option<usize> { 23 pub fn as_tuple_field(&self) -> Option<usize> {
28 self.syntax().children_with_tokens().find_map(|c| { 24 self.text().parse().ok()
29 if c.kind() == SyntaxKind::INT_NUMBER {
30 c.as_token().and_then(|tok| tok.text().as_str().parse().ok())
31 } else {
32 None
33 }
34 })
35 } 25 }
36} 26}
37 27
@@ -87,7 +77,7 @@ impl ast::Attr {
87 first_token.and_then(|token| token.next_token()).as_ref().map(SyntaxToken::kind); 77 first_token.and_then(|token| token.next_token()).as_ref().map(SyntaxToken::kind);
88 78
89 match (first_token_kind, second_token_kind) { 79 match (first_token_kind, second_token_kind) {
90 (Some(SyntaxKind::POUND), Some(SyntaxKind::EXCL)) => AttrKind::Inner, 80 (Some(SyntaxKind::POUND), Some(T![!])) => AttrKind::Inner,
91 _ => AttrKind::Outer, 81 _ => AttrKind::Outer,
92 } 82 }
93 } 83 }
@@ -140,15 +130,6 @@ impl ast::Path {
140 } 130 }
141} 131}
142 132
143impl ast::Module {
144 pub fn has_semi(&self) -> bool {
145 match self.syntax().last_child_or_token() {
146 None => false,
147 Some(node) => node.kind() == T![;],
148 }
149 }
150}
151
152impl ast::UseTreeList { 133impl ast::UseTreeList {
153 pub fn parent_use_tree(&self) -> ast::UseTree { 134 pub fn parent_use_tree(&self) -> ast::UseTree {
154 self.syntax() 135 self.syntax()
@@ -174,15 +155,11 @@ impl ast::ImplDef {
174 } 155 }
175 156
176 fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) { 157 fn target(&self) -> (Option<ast::TypeRef>, Option<ast::TypeRef>) {
177 let mut types = children(self); 158 let mut types = support::children(self.syntax());
178 let first = types.next(); 159 let first = types.next();
179 let second = types.next(); 160 let second = types.next();
180 (first, second) 161 (first, second)
181 } 162 }
182
183 pub fn is_negative(&self) -> bool {
184 self.syntax().children_with_tokens().any(|t| t.kind() == T![!])
185 }
186} 163}
187 164
188#[derive(Debug, Clone, PartialEq, Eq)] 165#[derive(Debug, Clone, PartialEq, Eq)]
@@ -194,9 +171,9 @@ pub enum StructKind {
194 171
195impl StructKind { 172impl StructKind {
196 fn from_node<N: AstNode>(node: &N) -> StructKind { 173 fn from_node<N: AstNode>(node: &N) -> StructKind {
197 if let Some(nfdl) = child_opt::<_, ast::RecordFieldDefList>(node) { 174 if let Some(nfdl) = support::child::<ast::RecordFieldDefList>(node.syntax()) {
198 StructKind::Record(nfdl) 175 StructKind::Record(nfdl)
199 } else if let Some(pfl) = child_opt::<_, ast::TupleFieldDefList>(node) { 176 } else if let Some(pfl) = support::child::<ast::TupleFieldDefList>(node.syntax()) {
200 StructKind::Tuple(pfl) 177 StructKind::Tuple(pfl)
201 } else { 178 } else {
202 StructKind::Unit 179 StructKind::Unit
@@ -210,6 +187,36 @@ impl ast::StructDef {
210 } 187 }
211} 188}
212 189
190impl ast::RecordField {
191 pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> {
192 let candidate =
193 field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| {
194 field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast)
195 })?;
196 if candidate.field_name().as_ref() == Some(field_name) {
197 Some(candidate)
198 } else {
199 None
200 }
201 }
202
203 /// Deals with field init shorthand
204 pub fn field_name(&self) -> Option<ast::NameRef> {
205 if let Some(name_ref) = self.name_ref() {
206 return Some(name_ref);
207 }
208 if let Some(ast::Expr::PathExpr(expr)) = self.expr() {
209 let path = expr.path()?;
210 let segment = path.segment()?;
211 let name_ref = segment.name_ref()?;
212 if path.qualifier().is_none() {
213 return Some(name_ref);
214 }
215 }
216 None
217 }
218}
219
213impl ast::EnumVariant { 220impl ast::EnumVariant {
214 pub fn parent_enum(&self) -> ast::EnumDef { 221 pub fn parent_enum(&self) -> ast::EnumDef {
215 self.syntax() 222 self.syntax()
@@ -223,41 +230,6 @@ impl ast::EnumVariant {
223 } 230 }
224} 231}
225 232
226impl ast::FnDef {
227 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
228 self.syntax()
229 .last_child_or_token()
230 .and_then(|it| it.into_token())
231 .filter(|it| it.kind() == T![;])
232 }
233
234 pub fn is_async(&self) -> bool {
235 self.syntax().children_with_tokens().any(|it| it.kind() == T![async])
236 }
237}
238
239impl ast::LetStmt {
240 pub fn has_semi(&self) -> bool {
241 match self.syntax().last_child_or_token() {
242 None => false,
243 Some(node) => node.kind() == T![;],
244 }
245 }
246
247 pub fn eq_token(&self) -> Option<SyntaxToken> {
248 self.syntax().children_with_tokens().find(|t| t.kind() == EQ).and_then(|it| it.into_token())
249 }
250}
251
252impl ast::ExprStmt {
253 pub fn has_semi(&self) -> bool {
254 match self.syntax().last_child_or_token() {
255 None => false,
256 Some(node) => node.kind() == T![;],
257 }
258 }
259}
260
261#[derive(Debug, Clone, PartialEq, Eq)] 233#[derive(Debug, Clone, PartialEq, Eq)]
262pub enum FieldKind { 234pub enum FieldKind {
263 Name(ast::NameRef), 235 Name(ast::NameRef),
@@ -286,25 +258,6 @@ impl ast::FieldExpr {
286 } 258 }
287} 259}
288 260
289impl ast::RefPat {
290 pub fn is_mut(&self) -> bool {
291 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
292 }
293}
294
295impl ast::BindPat {
296 pub fn is_mutable(&self) -> bool {
297 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
298 }
299
300 pub fn is_ref(&self) -> bool {
301 self.syntax().children_with_tokens().any(|n| n.kind() == T![ref])
302 }
303 pub fn has_at(&self) -> bool {
304 self.syntax().children_with_tokens().any(|it| it.kind() == T![@])
305 }
306}
307
308pub struct SlicePatComponents { 261pub struct SlicePatComponents {
309 pub prefix: Vec<ast::Pat>, 262 pub prefix: Vec<ast::Pat>,
310 pub slice: Option<ast::Pat>, 263 pub slice: Option<ast::Pat>,
@@ -339,18 +292,6 @@ impl ast::SlicePat {
339 } 292 }
340} 293}
341 294
342impl ast::PointerType {
343 pub fn is_mut(&self) -> bool {
344 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
345 }
346}
347
348impl ast::ReferenceType {
349 pub fn is_mut(&self) -> bool {
350 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
351 }
352}
353
354#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 295#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
355pub enum SelfParamKind { 296pub enum SelfParamKind {
356 /// self 297 /// self
@@ -363,8 +304,8 @@ pub enum SelfParamKind {
363 304
364impl ast::SelfParam { 305impl ast::SelfParam {
365 pub fn kind(&self) -> SelfParamKind { 306 pub fn kind(&self) -> SelfParamKind {
366 if self.amp().is_some() { 307 if self.amp_token().is_some() {
367 if self.amp_mut_kw().is_some() { 308 if self.mut_token().is_some() {
368 SelfParamKind::MutRef 309 SelfParamKind::MutRef
369 } else { 310 } else {
370 SelfParamKind::Ref 311 SelfParamKind::Ref
@@ -373,24 +314,6 @@ impl ast::SelfParam {
373 SelfParamKind::Owned 314 SelfParamKind::Owned
374 } 315 }
375 } 316 }
376
377 /// the "mut" in "mut self", not the one in "&mut self"
378 pub fn mut_kw(&self) -> Option<ast::MutKw> {
379 self.syntax()
380 .children_with_tokens()
381 .filter_map(|it| it.into_token())
382 .take_while(|it| it.kind() != T![&])
383 .find_map(ast::MutKw::cast)
384 }
385
386 /// the "mut" in "&mut self", not the one in "mut self"
387 pub fn amp_mut_kw(&self) -> Option<ast::MutKw> {
388 self.syntax()
389 .children_with_tokens()
390 .filter_map(|it| it.into_token())
391 .skip_while(|it| it.kind() != T![&])
392 .find_map(ast::MutKw::cast)
393 }
394} 317}
395 318
396#[derive(Clone, Debug, PartialEq, Eq, Hash)] 319#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@@ -400,53 +323,43 @@ pub enum TypeBoundKind {
400 /// for<'a> ... 323 /// for<'a> ...
401 ForType(ast::ForType), 324 ForType(ast::ForType),
402 /// 'a 325 /// 'a
403 Lifetime(ast::Lifetime), 326 Lifetime(SyntaxToken),
404} 327}
405 328
406impl ast::TypeBound { 329impl ast::TypeBound {
407 pub fn kind(&self) -> TypeBoundKind { 330 pub fn kind(&self) -> TypeBoundKind {
408 if let Some(path_type) = children(self).next() { 331 if let Some(path_type) = support::children(self.syntax()).next() {
409 TypeBoundKind::PathType(path_type) 332 TypeBoundKind::PathType(path_type)
410 } else if let Some(for_type) = children(self).next() { 333 } else if let Some(for_type) = support::children(self.syntax()).next() {
411 TypeBoundKind::ForType(for_type) 334 TypeBoundKind::ForType(for_type)
412 } else if let Some(lifetime) = self.lifetime() { 335 } else if let Some(lifetime) = self.lifetime_token() {
413 TypeBoundKind::Lifetime(lifetime) 336 TypeBoundKind::Lifetime(lifetime)
414 } else { 337 } else {
415 unreachable!() 338 unreachable!()
416 } 339 }
417 } 340 }
418 341
419 pub fn has_question_mark(&self) -> bool { 342 pub fn const_question_token(&self) -> Option<SyntaxToken> {
420 self.question().is_some()
421 }
422
423 pub fn const_question(&self) -> Option<ast::Question> {
424 self.syntax() 343 self.syntax()
425 .children_with_tokens() 344 .children_with_tokens()
426 .filter_map(|it| it.into_token()) 345 .filter_map(|it| it.into_token())
427 .take_while(|it| it.kind() != T![const]) 346 .take_while(|it| it.kind() != T![const])
428 .find_map(ast::Question::cast) 347 .find(|it| it.kind() == T![?])
429 } 348 }
430 349
431 pub fn question(&self) -> Option<ast::Question> { 350 pub fn question_token(&self) -> Option<SyntaxToken> {
432 if self.const_kw().is_some() { 351 if self.const_token().is_some() {
433 self.syntax() 352 self.syntax()
434 .children_with_tokens() 353 .children_with_tokens()
435 .filter_map(|it| it.into_token()) 354 .filter_map(|it| it.into_token())
436 .skip_while(|it| it.kind() != T![const]) 355 .skip_while(|it| it.kind() != T![const])
437 .find_map(ast::Question::cast) 356 .find(|it| it.kind() == T![?])
438 } else { 357 } else {
439 support::token(&self.syntax) 358 support::token(&self.syntax, T![?])
440 } 359 }
441 } 360 }
442} 361}
443 362
444impl ast::TraitDef {
445 pub fn is_auto(&self) -> bool {
446 self.syntax().children_with_tokens().any(|t| t.kind() == T![auto])
447 }
448}
449
450pub enum VisibilityKind { 363pub enum VisibilityKind {
451 In(ast::Path), 364 In(ast::Path),
452 PubCrate, 365 PubCrate,
@@ -457,30 +370,18 @@ pub enum VisibilityKind {
457 370
458impl ast::Visibility { 371impl ast::Visibility {
459 pub fn kind(&self) -> VisibilityKind { 372 pub fn kind(&self) -> VisibilityKind {
460 if let Some(path) = children(self).next() { 373 if let Some(path) = support::children(self.syntax()).next() {
461 VisibilityKind::In(path) 374 VisibilityKind::In(path)
462 } else if self.is_pub_crate() { 375 } else if self.crate_token().is_some() {
463 VisibilityKind::PubCrate 376 VisibilityKind::PubCrate
464 } else if self.is_pub_super() { 377 } else if self.super_token().is_some() {
465 VisibilityKind::PubSuper 378 VisibilityKind::PubSuper
466 } else if self.is_pub_self() { 379 } else if self.self_token().is_some() {
467 VisibilityKind::PubSuper 380 VisibilityKind::PubSuper
468 } else { 381 } else {
469 VisibilityKind::Pub 382 VisibilityKind::Pub
470 } 383 }
471 } 384 }
472
473 fn is_pub_crate(&self) -> bool {
474 self.syntax().children_with_tokens().any(|it| it.kind() == T![crate])
475 }
476
477 fn is_pub_super(&self) -> bool {
478 self.syntax().children_with_tokens().any(|it| it.kind() == T![super])
479 }
480
481 fn is_pub_self(&self) -> bool {
482 self.syntax().children_with_tokens().any(|it| it.kind() == T![self])
483 }
484} 385}
485 386
486impl ast::MacroCall { 387impl ast::MacroCall {
@@ -495,12 +396,12 @@ impl ast::MacroCall {
495} 396}
496 397
497impl ast::LifetimeParam { 398impl ast::LifetimeParam {
498 pub fn lifetime_bounds(&self) -> impl Iterator<Item = ast::Lifetime> { 399 pub fn lifetime_bounds(&self) -> impl Iterator<Item = SyntaxToken> {
499 self.syntax() 400 self.syntax()
500 .children_with_tokens() 401 .children_with_tokens()
501 .filter_map(|it| it.into_token()) 402 .filter_map(|it| it.into_token())
502 .skip_while(|x| x.kind() != T![:]) 403 .skip_while(|x| x.kind() != T![:])
503 .filter_map(ast::Lifetime::cast) 404 .filter(|it| it.kind() == T![lifetime])
504 } 405 }
505} 406}
506 407
@@ -508,7 +409,7 @@ impl ast::RangePat {
508 pub fn start(&self) -> Option<ast::Pat> { 409 pub fn start(&self) -> Option<ast::Pat> {
509 self.syntax() 410 self.syntax()
510 .children_with_tokens() 411 .children_with_tokens()
511 .take_while(|it| !ast::RangeSeparator::can_cast(it.kind())) 412 .take_while(|it| !(it.kind() == T![..] || it.kind() == T![..=]))
512 .filter_map(|it| it.into_node()) 413 .filter_map(|it| it.into_node())
513 .find_map(ast::Pat::cast) 414 .find_map(ast::Pat::cast)
514 } 415 }
@@ -516,18 +417,24 @@ impl ast::RangePat {
516 pub fn end(&self) -> Option<ast::Pat> { 417 pub fn end(&self) -> Option<ast::Pat> {
517 self.syntax() 418 self.syntax()
518 .children_with_tokens() 419 .children_with_tokens()
519 .skip_while(|it| !ast::RangeSeparator::can_cast(it.kind())) 420 .skip_while(|it| !(it.kind() == T![..] || it.kind() == T![..=]))
520 .filter_map(|it| it.into_node()) 421 .filter_map(|it| it.into_node())
521 .find_map(ast::Pat::cast) 422 .find_map(ast::Pat::cast)
522 } 423 }
523} 424}
524 425
525impl ast::TokenTree { 426impl ast::TokenTree {
526 pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> { 427 pub fn left_delimiter_token(&self) -> Option<SyntaxToken> {
527 self.syntax().first_child_or_token()?.into_token().and_then(ast::LeftDelimiter::cast) 428 self.syntax().first_child_or_token()?.into_token().filter(|it| match it.kind() {
429 T!['{'] | T!['('] | T!['['] => true,
430 _ => false,
431 })
528 } 432 }
529 433
530 pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> { 434 pub fn right_delimiter_token(&self) -> Option<SyntaxToken> {
531 self.syntax().last_child_or_token()?.into_token().and_then(ast::RightDelimiter::cast) 435 self.syntax().last_child_or_token()?.into_token().filter(|it| match it.kind() {
436 T!['{'] | T!['('] | T!['['] => true,
437 _ => false,
438 })
532 } 439 }
533} 440}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 8b348ad6e..f1098755b 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -1,11 +1,11 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3use super::tokens::*;
4use crate::{ 3use crate::{
5 ast::{self, support, AstChildren, AstNode}, 4 ast::{self, support, AstChildren, AstNode},
6 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
7 SyntaxNode, 6 SyntaxNode, SyntaxToken, T,
8}; 7};
8
9#[derive(Debug, Clone, PartialEq, Eq, Hash)] 9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
10pub struct SourceFile { 10pub struct SourceFile {
11 pub(crate) syntax: SyntaxNode, 11 pub(crate) syntax: SyntaxNode,
@@ -22,11 +22,11 @@ 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) }
29} 28}
29
30#[derive(Debug, Clone, PartialEq, Eq, Hash)] 30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31pub struct FnDef { 31pub struct FnDef {
32 pub(crate) syntax: SyntaxNode, 32 pub(crate) syntax: SyntaxNode,
@@ -49,16 +49,17 @@ impl ast::DocCommentsOwner for FnDef {}
49impl ast::AttrsOwner for FnDef {} 49impl ast::AttrsOwner for FnDef {}
50impl FnDef { 50impl FnDef {
51 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 51 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
52 pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } 52 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
53 pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 53 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
54 pub fn async_kw(&self) -> Option<AsyncKw> { support::token(&self.syntax) } 54 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
55 pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 55 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
56 pub fn fn_kw(&self) -> Option<FnKw> { support::token(&self.syntax) } 56 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
57 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 57 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
58 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 58 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
59 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 59 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
60 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 60 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
61} 61}
62
62#[derive(Debug, Clone, PartialEq, Eq, Hash)] 63#[derive(Debug, Clone, PartialEq, Eq, Hash)]
63pub struct RetType { 64pub struct RetType {
64 pub(crate) syntax: SyntaxNode, 65 pub(crate) syntax: SyntaxNode,
@@ -75,9 +76,10 @@ impl AstNode for RetType {
75 fn syntax(&self) -> &SyntaxNode { &self.syntax } 76 fn syntax(&self) -> &SyntaxNode { &self.syntax }
76} 77}
77impl RetType { 78impl RetType {
78 pub fn thin_arrow(&self) -> Option<ThinArrow> { support::token(&self.syntax) } 79 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
79 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 80 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
80} 81}
82
81#[derive(Debug, Clone, PartialEq, Eq, Hash)] 83#[derive(Debug, Clone, PartialEq, Eq, Hash)]
82pub struct StructDef { 84pub struct StructDef {
83 pub(crate) syntax: SyntaxNode, 85 pub(crate) syntax: SyntaxNode,
@@ -99,10 +101,11 @@ impl ast::TypeParamsOwner for StructDef {}
99impl ast::AttrsOwner for StructDef {} 101impl ast::AttrsOwner for StructDef {}
100impl ast::DocCommentsOwner for StructDef {} 102impl ast::DocCommentsOwner for StructDef {}
101impl StructDef { 103impl StructDef {
102 pub fn struct_kw(&self) -> Option<StructKw> { support::token(&self.syntax) } 104 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
103 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 105 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
104 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 106 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
105} 107}
108
106#[derive(Debug, Clone, PartialEq, Eq, Hash)] 109#[derive(Debug, Clone, PartialEq, Eq, Hash)]
107pub struct UnionDef { 110pub struct UnionDef {
108 pub(crate) syntax: SyntaxNode, 111 pub(crate) syntax: SyntaxNode,
@@ -124,11 +127,12 @@ impl ast::TypeParamsOwner for UnionDef {}
124impl ast::AttrsOwner for UnionDef {} 127impl ast::AttrsOwner for UnionDef {}
125impl ast::DocCommentsOwner for UnionDef {} 128impl ast::DocCommentsOwner for UnionDef {}
126impl UnionDef { 129impl UnionDef {
127 pub fn union_kw(&self) -> Option<UnionKw> { support::token(&self.syntax) } 130 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
128 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 131 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
129 support::child(&self.syntax) 132 support::child(&self.syntax)
130 } 133 }
131} 134}
135
132#[derive(Debug, Clone, PartialEq, Eq, Hash)] 136#[derive(Debug, Clone, PartialEq, Eq, Hash)]
133pub struct RecordFieldDefList { 137pub struct RecordFieldDefList {
134 pub(crate) syntax: SyntaxNode, 138 pub(crate) syntax: SyntaxNode,
@@ -145,10 +149,11 @@ impl AstNode for RecordFieldDefList {
145 fn syntax(&self) -> &SyntaxNode { &self.syntax } 149 fn syntax(&self) -> &SyntaxNode { &self.syntax }
146} 150}
147impl RecordFieldDefList { 151impl RecordFieldDefList {
148 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 152 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
149 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } 153 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) }
150 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 154 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
151} 155}
156
152#[derive(Debug, Clone, PartialEq, Eq, Hash)] 157#[derive(Debug, Clone, PartialEq, Eq, Hash)]
153pub struct RecordFieldDef { 158pub struct RecordFieldDef {
154 pub(crate) syntax: SyntaxNode, 159 pub(crate) syntax: SyntaxNode,
@@ -170,6 +175,7 @@ impl ast::AttrsOwner for RecordFieldDef {}
170impl ast::DocCommentsOwner for RecordFieldDef {} 175impl ast::DocCommentsOwner for RecordFieldDef {}
171impl ast::TypeAscriptionOwner for RecordFieldDef {} 176impl ast::TypeAscriptionOwner for RecordFieldDef {}
172impl RecordFieldDef {} 177impl RecordFieldDef {}
178
173#[derive(Debug, Clone, PartialEq, Eq, Hash)] 179#[derive(Debug, Clone, PartialEq, Eq, Hash)]
174pub struct TupleFieldDefList { 180pub struct TupleFieldDefList {
175 pub(crate) syntax: SyntaxNode, 181 pub(crate) syntax: SyntaxNode,
@@ -186,10 +192,11 @@ impl AstNode for TupleFieldDefList {
186 fn syntax(&self) -> &SyntaxNode { &self.syntax } 192 fn syntax(&self) -> &SyntaxNode { &self.syntax }
187} 193}
188impl TupleFieldDefList { 194impl TupleFieldDefList {
189 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 195 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
190 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } 196 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
191 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 197 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
192} 198}
199
193#[derive(Debug, Clone, PartialEq, Eq, Hash)] 200#[derive(Debug, Clone, PartialEq, Eq, Hash)]
194pub struct TupleFieldDef { 201pub struct TupleFieldDef {
195 pub(crate) syntax: SyntaxNode, 202 pub(crate) syntax: SyntaxNode,
@@ -210,6 +217,7 @@ impl ast::AttrsOwner for TupleFieldDef {}
210impl TupleFieldDef { 217impl TupleFieldDef {
211 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 218 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
212} 219}
220
213#[derive(Debug, Clone, PartialEq, Eq, Hash)] 221#[derive(Debug, Clone, PartialEq, Eq, Hash)]
214pub struct EnumDef { 222pub struct EnumDef {
215 pub(crate) syntax: SyntaxNode, 223 pub(crate) syntax: SyntaxNode,
@@ -231,9 +239,10 @@ impl ast::TypeParamsOwner for EnumDef {}
231impl ast::AttrsOwner for EnumDef {} 239impl ast::AttrsOwner for EnumDef {}
232impl ast::DocCommentsOwner for EnumDef {} 240impl ast::DocCommentsOwner for EnumDef {}
233impl EnumDef { 241impl EnumDef {
234 pub fn enum_kw(&self) -> Option<EnumKw> { support::token(&self.syntax) } 242 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
235 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } 243 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
236} 244}
245
237#[derive(Debug, Clone, PartialEq, Eq, Hash)] 246#[derive(Debug, Clone, PartialEq, Eq, Hash)]
238pub struct EnumVariantList { 247pub struct EnumVariantList {
239 pub(crate) syntax: SyntaxNode, 248 pub(crate) syntax: SyntaxNode,
@@ -250,10 +259,11 @@ impl AstNode for EnumVariantList {
250 fn syntax(&self) -> &SyntaxNode { &self.syntax } 259 fn syntax(&self) -> &SyntaxNode { &self.syntax }
251} 260}
252impl EnumVariantList { 261impl EnumVariantList {
253 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 262 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
254 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 263 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) }
255 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 264 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
256} 265}
266
257#[derive(Debug, Clone, PartialEq, Eq, Hash)] 267#[derive(Debug, Clone, PartialEq, Eq, Hash)]
258pub struct EnumVariant { 268pub struct EnumVariant {
259 pub(crate) syntax: SyntaxNode, 269 pub(crate) syntax: SyntaxNode,
@@ -275,9 +285,10 @@ impl ast::DocCommentsOwner for EnumVariant {}
275impl ast::AttrsOwner for EnumVariant {} 285impl ast::AttrsOwner for EnumVariant {}
276impl EnumVariant { 286impl EnumVariant {
277 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 287 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
278 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 288 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
279 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 289 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
280} 290}
291
281#[derive(Debug, Clone, PartialEq, Eq, Hash)] 292#[derive(Debug, Clone, PartialEq, Eq, Hash)]
282pub struct TraitDef { 293pub struct TraitDef {
283 pub(crate) syntax: SyntaxNode, 294 pub(crate) syntax: SyntaxNode,
@@ -300,11 +311,12 @@ impl ast::DocCommentsOwner for TraitDef {}
300impl ast::TypeParamsOwner for TraitDef {} 311impl ast::TypeParamsOwner for TraitDef {}
301impl ast::TypeBoundsOwner for TraitDef {} 312impl ast::TypeBoundsOwner for TraitDef {}
302impl TraitDef { 313impl TraitDef {
303 pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 314 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
304 pub fn auto_kw(&self) -> Option<AutoKw> { support::token(&self.syntax) } 315 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
305 pub fn trait_kw(&self) -> Option<TraitKw> { support::token(&self.syntax) } 316 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
306 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 317 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
307} 318}
319
308#[derive(Debug, Clone, PartialEq, Eq, Hash)] 320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
309pub struct Module { 321pub struct Module {
310 pub(crate) syntax: SyntaxNode, 322 pub(crate) syntax: SyntaxNode,
@@ -325,10 +337,11 @@ impl ast::NameOwner for Module {}
325impl ast::AttrsOwner for Module {} 337impl ast::AttrsOwner for Module {}
326impl ast::DocCommentsOwner for Module {} 338impl ast::DocCommentsOwner for Module {}
327impl Module { 339impl Module {
328 pub fn mod_kw(&self) -> Option<ModKw> { support::token(&self.syntax) } 340 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
329 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 341 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
330 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 342 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
331} 343}
344
332#[derive(Debug, Clone, PartialEq, Eq, Hash)] 345#[derive(Debug, Clone, PartialEq, Eq, Hash)]
333pub struct ItemList { 346pub struct ItemList {
334 pub(crate) syntax: SyntaxNode, 347 pub(crate) syntax: SyntaxNode,
@@ -344,13 +357,13 @@ impl AstNode for ItemList {
344 } 357 }
345 fn syntax(&self) -> &SyntaxNode { &self.syntax } 358 fn syntax(&self) -> &SyntaxNode { &self.syntax }
346} 359}
347impl ast::FnDefOwner for ItemList {}
348impl ast::ModuleItemOwner for ItemList {} 360impl ast::ModuleItemOwner for ItemList {}
349impl ItemList { 361impl ItemList {
350 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 362 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
351 pub fn impl_items(&self) -> AstChildren<ImplItem> { support::children(&self.syntax) } 363 pub fn impl_items(&self) -> AstChildren<ImplItem> { support::children(&self.syntax) }
352 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 364 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
353} 365}
366
354#[derive(Debug, Clone, PartialEq, Eq, Hash)] 367#[derive(Debug, Clone, PartialEq, Eq, Hash)]
355pub struct ConstDef { 368pub struct ConstDef {
356 pub(crate) syntax: SyntaxNode, 369 pub(crate) syntax: SyntaxNode,
@@ -373,12 +386,13 @@ impl ast::AttrsOwner for ConstDef {}
373impl ast::DocCommentsOwner for ConstDef {} 386impl ast::DocCommentsOwner for ConstDef {}
374impl ast::TypeAscriptionOwner for ConstDef {} 387impl ast::TypeAscriptionOwner for ConstDef {}
375impl ConstDef { 388impl ConstDef {
376 pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 389 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
377 pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } 390 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
378 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 391 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
379 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 392 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
380 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 393 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
381} 394}
395
382#[derive(Debug, Clone, PartialEq, Eq, Hash)] 396#[derive(Debug, Clone, PartialEq, Eq, Hash)]
383pub struct StaticDef { 397pub struct StaticDef {
384 pub(crate) syntax: SyntaxNode, 398 pub(crate) syntax: SyntaxNode,
@@ -401,12 +415,13 @@ impl ast::AttrsOwner for StaticDef {}
401impl ast::DocCommentsOwner for StaticDef {} 415impl ast::DocCommentsOwner for StaticDef {}
402impl ast::TypeAscriptionOwner for StaticDef {} 416impl ast::TypeAscriptionOwner for StaticDef {}
403impl StaticDef { 417impl StaticDef {
404 pub fn static_kw(&self) -> Option<StaticKw> { support::token(&self.syntax) } 418 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
405 pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } 419 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
406 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 420 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
407 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 421 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
408 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 422 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
409} 423}
424
410#[derive(Debug, Clone, PartialEq, Eq, Hash)] 425#[derive(Debug, Clone, PartialEq, Eq, Hash)]
411pub struct TypeAliasDef { 426pub struct TypeAliasDef {
412 pub(crate) syntax: SyntaxNode, 427 pub(crate) syntax: SyntaxNode,
@@ -429,12 +444,13 @@ impl ast::AttrsOwner for TypeAliasDef {}
429impl ast::DocCommentsOwner for TypeAliasDef {} 444impl ast::DocCommentsOwner for TypeAliasDef {}
430impl ast::TypeBoundsOwner for TypeAliasDef {} 445impl ast::TypeBoundsOwner for TypeAliasDef {}
431impl TypeAliasDef { 446impl TypeAliasDef {
432 pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 447 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
433 pub fn type_kw(&self) -> Option<TypeKw> { support::token(&self.syntax) } 448 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
434 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 449 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
435 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 450 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
436 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 451 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
437} 452}
453
438#[derive(Debug, Clone, PartialEq, Eq, Hash)] 454#[derive(Debug, Clone, PartialEq, Eq, Hash)]
439pub struct ImplDef { 455pub struct ImplDef {
440 pub(crate) syntax: SyntaxNode, 456 pub(crate) syntax: SyntaxNode,
@@ -453,14 +469,15 @@ impl AstNode for ImplDef {
453impl ast::TypeParamsOwner for ImplDef {} 469impl ast::TypeParamsOwner for ImplDef {}
454impl ast::AttrsOwner for ImplDef {} 470impl ast::AttrsOwner for ImplDef {}
455impl ImplDef { 471impl ImplDef {
456 pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } 472 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
457 pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } 473 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
458 pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 474 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
459 pub fn impl_kw(&self) -> Option<ImplKw> { support::token(&self.syntax) } 475 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
460 pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } 476 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
461 pub fn for_kw(&self) -> Option<ForKw> { support::token(&self.syntax) } 477 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
462 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 478 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
463} 479}
480
464#[derive(Debug, Clone, PartialEq, Eq, Hash)] 481#[derive(Debug, Clone, PartialEq, Eq, Hash)]
465pub struct ParenType { 482pub struct ParenType {
466 pub(crate) syntax: SyntaxNode, 483 pub(crate) syntax: SyntaxNode,
@@ -477,10 +494,11 @@ impl AstNode for ParenType {
477 fn syntax(&self) -> &SyntaxNode { &self.syntax } 494 fn syntax(&self) -> &SyntaxNode { &self.syntax }
478} 495}
479impl ParenType { 496impl ParenType {
480 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 497 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
481 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 498 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
482 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 499 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
483} 500}
501
484#[derive(Debug, Clone, PartialEq, Eq, Hash)] 502#[derive(Debug, Clone, PartialEq, Eq, Hash)]
485pub struct TupleType { 503pub struct TupleType {
486 pub(crate) syntax: SyntaxNode, 504 pub(crate) syntax: SyntaxNode,
@@ -497,10 +515,11 @@ impl AstNode for TupleType {
497 fn syntax(&self) -> &SyntaxNode { &self.syntax } 515 fn syntax(&self) -> &SyntaxNode { &self.syntax }
498} 516}
499impl TupleType { 517impl TupleType {
500 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 518 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
501 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 519 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
502 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 520 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
503} 521}
522
504#[derive(Debug, Clone, PartialEq, Eq, Hash)] 523#[derive(Debug, Clone, PartialEq, Eq, Hash)]
505pub struct NeverType { 524pub struct NeverType {
506 pub(crate) syntax: SyntaxNode, 525 pub(crate) syntax: SyntaxNode,
@@ -517,8 +536,9 @@ impl AstNode for NeverType {
517 fn syntax(&self) -> &SyntaxNode { &self.syntax } 536 fn syntax(&self) -> &SyntaxNode { &self.syntax }
518} 537}
519impl NeverType { 538impl NeverType {
520 pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } 539 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
521} 540}
541
522#[derive(Debug, Clone, PartialEq, Eq, Hash)] 542#[derive(Debug, Clone, PartialEq, Eq, Hash)]
523pub struct PathType { 543pub struct PathType {
524 pub(crate) syntax: SyntaxNode, 544 pub(crate) syntax: SyntaxNode,
@@ -537,6 +557,7 @@ impl AstNode for PathType {
537impl PathType { 557impl PathType {
538 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 558 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
539} 559}
560
540#[derive(Debug, Clone, PartialEq, Eq, Hash)] 561#[derive(Debug, Clone, PartialEq, Eq, Hash)]
541pub struct PointerType { 562pub struct PointerType {
542 pub(crate) syntax: SyntaxNode, 563 pub(crate) syntax: SyntaxNode,
@@ -553,10 +574,12 @@ impl AstNode for PointerType {
553 fn syntax(&self) -> &SyntaxNode { &self.syntax } 574 fn syntax(&self) -> &SyntaxNode { &self.syntax }
554} 575}
555impl PointerType { 576impl PointerType {
556 pub fn star(&self) -> Option<Star> { support::token(&self.syntax) } 577 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
557 pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } 578 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
579 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
558 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 580 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
559} 581}
582
560#[derive(Debug, Clone, PartialEq, Eq, Hash)] 583#[derive(Debug, Clone, PartialEq, Eq, Hash)]
561pub struct ArrayType { 584pub struct ArrayType {
562 pub(crate) syntax: SyntaxNode, 585 pub(crate) syntax: SyntaxNode,
@@ -573,12 +596,13 @@ impl AstNode for ArrayType {
573 fn syntax(&self) -> &SyntaxNode { &self.syntax } 596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
574} 597}
575impl ArrayType { 598impl ArrayType {
576 pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } 599 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
577 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 600 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
578 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 601 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
579 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 602 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
580 pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } 603 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
581} 604}
605
582#[derive(Debug, Clone, PartialEq, Eq, Hash)] 606#[derive(Debug, Clone, PartialEq, Eq, Hash)]
583pub struct SliceType { 607pub struct SliceType {
584 pub(crate) syntax: SyntaxNode, 608 pub(crate) syntax: SyntaxNode,
@@ -595,10 +619,11 @@ impl AstNode for SliceType {
595 fn syntax(&self) -> &SyntaxNode { &self.syntax } 619 fn syntax(&self) -> &SyntaxNode { &self.syntax }
596} 620}
597impl SliceType { 621impl SliceType {
598 pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } 622 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
599 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 623 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
600 pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } 624 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
601} 625}
626
602#[derive(Debug, Clone, PartialEq, Eq, Hash)] 627#[derive(Debug, Clone, PartialEq, Eq, Hash)]
603pub struct ReferenceType { 628pub struct ReferenceType {
604 pub(crate) syntax: SyntaxNode, 629 pub(crate) syntax: SyntaxNode,
@@ -615,11 +640,14 @@ impl AstNode for ReferenceType {
615 fn syntax(&self) -> &SyntaxNode { &self.syntax } 640 fn syntax(&self) -> &SyntaxNode { &self.syntax }
616} 641}
617impl ReferenceType { 642impl ReferenceType {
618 pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } 643 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
619 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 644 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
620 pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } 645 support::token(&self.syntax, T![lifetime])
646 }
647 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
621 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 648 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
622} 649}
650
623#[derive(Debug, Clone, PartialEq, Eq, Hash)] 651#[derive(Debug, Clone, PartialEq, Eq, Hash)]
624pub struct PlaceholderType { 652pub struct PlaceholderType {
625 pub(crate) syntax: SyntaxNode, 653 pub(crate) syntax: SyntaxNode,
@@ -636,8 +664,9 @@ impl AstNode for PlaceholderType {
636 fn syntax(&self) -> &SyntaxNode { &self.syntax } 664 fn syntax(&self) -> &SyntaxNode { &self.syntax }
637} 665}
638impl PlaceholderType { 666impl PlaceholderType {
639 pub fn underscore(&self) -> Option<Underscore> { support::token(&self.syntax) } 667 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
640} 668}
669
641#[derive(Debug, Clone, PartialEq, Eq, Hash)] 670#[derive(Debug, Clone, PartialEq, Eq, Hash)]
642pub struct FnPointerType { 671pub struct FnPointerType {
643 pub(crate) syntax: SyntaxNode, 672 pub(crate) syntax: SyntaxNode,
@@ -655,11 +684,12 @@ impl AstNode for FnPointerType {
655} 684}
656impl FnPointerType { 685impl FnPointerType {
657 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 686 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
658 pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 687 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
659 pub fn fn_kw(&self) -> Option<FnKw> { support::token(&self.syntax) } 688 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
660 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 689 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
661 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 690 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
662} 691}
692
663#[derive(Debug, Clone, PartialEq, Eq, Hash)] 693#[derive(Debug, Clone, PartialEq, Eq, Hash)]
664pub struct ForType { 694pub struct ForType {
665 pub(crate) syntax: SyntaxNode, 695 pub(crate) syntax: SyntaxNode,
@@ -676,10 +706,11 @@ impl AstNode for ForType {
676 fn syntax(&self) -> &SyntaxNode { &self.syntax } 706 fn syntax(&self) -> &SyntaxNode { &self.syntax }
677} 707}
678impl ForType { 708impl ForType {
679 pub fn for_kw(&self) -> Option<ForKw> { support::token(&self.syntax) } 709 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
680 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 710 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
681 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 711 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
682} 712}
713
683#[derive(Debug, Clone, PartialEq, Eq, Hash)] 714#[derive(Debug, Clone, PartialEq, Eq, Hash)]
684pub struct ImplTraitType { 715pub struct ImplTraitType {
685 pub(crate) syntax: SyntaxNode, 716 pub(crate) syntax: SyntaxNode,
@@ -697,8 +728,9 @@ impl AstNode for ImplTraitType {
697} 728}
698impl ast::TypeBoundsOwner for ImplTraitType {} 729impl ast::TypeBoundsOwner for ImplTraitType {}
699impl ImplTraitType { 730impl ImplTraitType {
700 pub fn impl_kw(&self) -> Option<ImplKw> { support::token(&self.syntax) } 731 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
701} 732}
733
702#[derive(Debug, Clone, PartialEq, Eq, Hash)] 734#[derive(Debug, Clone, PartialEq, Eq, Hash)]
703pub struct DynTraitType { 735pub struct DynTraitType {
704 pub(crate) syntax: SyntaxNode, 736 pub(crate) syntax: SyntaxNode,
@@ -716,8 +748,9 @@ impl AstNode for DynTraitType {
716} 748}
717impl ast::TypeBoundsOwner for DynTraitType {} 749impl ast::TypeBoundsOwner for DynTraitType {}
718impl DynTraitType { 750impl DynTraitType {
719 pub fn dyn_kw(&self) -> Option<DynKw> { support::token(&self.syntax) } 751 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
720} 752}
753
721#[derive(Debug, Clone, PartialEq, Eq, Hash)] 754#[derive(Debug, Clone, PartialEq, Eq, Hash)]
722pub struct TupleExpr { 755pub struct TupleExpr {
723 pub(crate) syntax: SyntaxNode, 756 pub(crate) syntax: SyntaxNode,
@@ -735,10 +768,11 @@ impl AstNode for TupleExpr {
735} 768}
736impl ast::AttrsOwner for TupleExpr {} 769impl ast::AttrsOwner for TupleExpr {}
737impl TupleExpr { 770impl TupleExpr {
738 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 771 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
739 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 772 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
740 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 773 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
741} 774}
775
742#[derive(Debug, Clone, PartialEq, Eq, Hash)] 776#[derive(Debug, Clone, PartialEq, Eq, Hash)]
743pub struct ArrayExpr { 777pub struct ArrayExpr {
744 pub(crate) syntax: SyntaxNode, 778 pub(crate) syntax: SyntaxNode,
@@ -756,11 +790,12 @@ impl AstNode for ArrayExpr {
756} 790}
757impl ast::AttrsOwner for ArrayExpr {} 791impl ast::AttrsOwner for ArrayExpr {}
758impl ArrayExpr { 792impl ArrayExpr {
759 pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } 793 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
760 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 794 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
761 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 795 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
762 pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } 796 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
763} 797}
798
764#[derive(Debug, Clone, PartialEq, Eq, Hash)] 799#[derive(Debug, Clone, PartialEq, Eq, Hash)]
765pub struct ParenExpr { 800pub struct ParenExpr {
766 pub(crate) syntax: SyntaxNode, 801 pub(crate) syntax: SyntaxNode,
@@ -778,10 +813,11 @@ impl AstNode for ParenExpr {
778} 813}
779impl ast::AttrsOwner for ParenExpr {} 814impl ast::AttrsOwner for ParenExpr {}
780impl ParenExpr { 815impl ParenExpr {
781 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 816 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
782 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 817 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
783 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 818 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
784} 819}
820
785#[derive(Debug, Clone, PartialEq, Eq, Hash)] 821#[derive(Debug, Clone, PartialEq, Eq, Hash)]
786pub struct PathExpr { 822pub struct PathExpr {
787 pub(crate) syntax: SyntaxNode, 823 pub(crate) syntax: SyntaxNode,
@@ -800,6 +836,7 @@ impl AstNode for PathExpr {
800impl PathExpr { 836impl PathExpr {
801 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 837 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
802} 838}
839
803#[derive(Debug, Clone, PartialEq, Eq, Hash)] 840#[derive(Debug, Clone, PartialEq, Eq, Hash)]
804pub struct LambdaExpr { 841pub struct LambdaExpr {
805 pub(crate) syntax: SyntaxNode, 842 pub(crate) syntax: SyntaxNode,
@@ -817,13 +854,14 @@ impl AstNode for LambdaExpr {
817} 854}
818impl ast::AttrsOwner for LambdaExpr {} 855impl ast::AttrsOwner for LambdaExpr {}
819impl LambdaExpr { 856impl LambdaExpr {
820 pub fn static_kw(&self) -> Option<StaticKw> { support::token(&self.syntax) } 857 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
821 pub fn async_kw(&self) -> Option<AsyncKw> { support::token(&self.syntax) } 858 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
822 pub fn move_kw(&self) -> Option<MoveKw> { support::token(&self.syntax) } 859 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
823 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 860 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
824 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 861 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
825 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 862 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
826} 863}
864
827#[derive(Debug, Clone, PartialEq, Eq, Hash)] 865#[derive(Debug, Clone, PartialEq, Eq, Hash)]
828pub struct IfExpr { 866pub struct IfExpr {
829 pub(crate) syntax: SyntaxNode, 867 pub(crate) syntax: SyntaxNode,
@@ -841,9 +879,10 @@ impl AstNode for IfExpr {
841} 879}
842impl ast::AttrsOwner for IfExpr {} 880impl ast::AttrsOwner for IfExpr {}
843impl IfExpr { 881impl IfExpr {
844 pub fn if_kw(&self) -> Option<IfKw> { support::token(&self.syntax) } 882 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
845 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 883 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
846} 884}
885
847#[derive(Debug, Clone, PartialEq, Eq, Hash)] 886#[derive(Debug, Clone, PartialEq, Eq, Hash)]
848pub struct LoopExpr { 887pub struct LoopExpr {
849 pub(crate) syntax: SyntaxNode, 888 pub(crate) syntax: SyntaxNode,
@@ -862,8 +901,9 @@ impl AstNode for LoopExpr {
862impl ast::AttrsOwner for LoopExpr {} 901impl ast::AttrsOwner for LoopExpr {}
863impl ast::LoopBodyOwner for LoopExpr {} 902impl ast::LoopBodyOwner for LoopExpr {}
864impl LoopExpr { 903impl LoopExpr {
865 pub fn loop_kw(&self) -> Option<LoopKw> { support::token(&self.syntax) } 904 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
866} 905}
906
867#[derive(Debug, Clone, PartialEq, Eq, Hash)] 907#[derive(Debug, Clone, PartialEq, Eq, Hash)]
868pub struct TryBlockExpr { 908pub struct TryBlockExpr {
869 pub(crate) syntax: SyntaxNode, 909 pub(crate) syntax: SyntaxNode,
@@ -881,9 +921,10 @@ impl AstNode for TryBlockExpr {
881} 921}
882impl ast::AttrsOwner for TryBlockExpr {} 922impl ast::AttrsOwner for TryBlockExpr {}
883impl TryBlockExpr { 923impl TryBlockExpr {
884 pub fn try_kw(&self) -> Option<TryKw> { support::token(&self.syntax) } 924 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
885 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 925 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
886} 926}
927
887#[derive(Debug, Clone, PartialEq, Eq, Hash)] 928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
888pub struct ForExpr { 929pub struct ForExpr {
889 pub(crate) syntax: SyntaxNode, 930 pub(crate) syntax: SyntaxNode,
@@ -902,11 +943,12 @@ impl AstNode for ForExpr {
902impl ast::AttrsOwner for ForExpr {} 943impl ast::AttrsOwner for ForExpr {}
903impl ast::LoopBodyOwner for ForExpr {} 944impl ast::LoopBodyOwner for ForExpr {}
904impl ForExpr { 945impl ForExpr {
905 pub fn for_kw(&self) -> Option<ForKw> { support::token(&self.syntax) } 946 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
906 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 947 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
907 pub fn in_kw(&self) -> Option<InKw> { support::token(&self.syntax) } 948 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
908 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } 949 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
909} 950}
951
910#[derive(Debug, Clone, PartialEq, Eq, Hash)] 952#[derive(Debug, Clone, PartialEq, Eq, Hash)]
911pub struct WhileExpr { 953pub struct WhileExpr {
912 pub(crate) syntax: SyntaxNode, 954 pub(crate) syntax: SyntaxNode,
@@ -925,9 +967,10 @@ impl AstNode for WhileExpr {
925impl ast::AttrsOwner for WhileExpr {} 967impl ast::AttrsOwner for WhileExpr {}
926impl ast::LoopBodyOwner for WhileExpr {} 968impl ast::LoopBodyOwner for WhileExpr {}
927impl WhileExpr { 969impl WhileExpr {
928 pub fn while_kw(&self) -> Option<WhileKw> { support::token(&self.syntax) } 970 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
929 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 971 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
930} 972}
973
931#[derive(Debug, Clone, PartialEq, Eq, Hash)] 974#[derive(Debug, Clone, PartialEq, Eq, Hash)]
932pub struct ContinueExpr { 975pub struct ContinueExpr {
933 pub(crate) syntax: SyntaxNode, 976 pub(crate) syntax: SyntaxNode,
@@ -945,9 +988,14 @@ impl AstNode for ContinueExpr {
945} 988}
946impl ast::AttrsOwner for ContinueExpr {} 989impl ast::AttrsOwner for ContinueExpr {}
947impl ContinueExpr { 990impl ContinueExpr {
948 pub fn continue_kw(&self) -> Option<ContinueKw> { support::token(&self.syntax) } 991 pub fn continue_token(&self) -> Option<SyntaxToken> {
949 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 992 support::token(&self.syntax, T![continue])
993 }
994 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
995 support::token(&self.syntax, T![lifetime])
996 }
950} 997}
998
951#[derive(Debug, Clone, PartialEq, Eq, Hash)] 999#[derive(Debug, Clone, PartialEq, Eq, Hash)]
952pub struct BreakExpr { 1000pub struct BreakExpr {
953 pub(crate) syntax: SyntaxNode, 1001 pub(crate) syntax: SyntaxNode,
@@ -965,10 +1013,13 @@ impl AstNode for BreakExpr {
965} 1013}
966impl ast::AttrsOwner for BreakExpr {} 1014impl ast::AttrsOwner for BreakExpr {}
967impl BreakExpr { 1015impl BreakExpr {
968 pub fn break_kw(&self) -> Option<BreakKw> { support::token(&self.syntax) } 1016 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
969 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 1017 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1018 support::token(&self.syntax, T![lifetime])
1019 }
970 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1020 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
971} 1021}
1022
972#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1023#[derive(Debug, Clone, PartialEq, Eq, Hash)]
973pub struct Label { 1024pub struct Label {
974 pub(crate) syntax: SyntaxNode, 1025 pub(crate) syntax: SyntaxNode,
@@ -985,8 +1036,11 @@ impl AstNode for Label {
985 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1036 fn syntax(&self) -> &SyntaxNode { &self.syntax }
986} 1037}
987impl Label { 1038impl Label {
988 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 1039 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1040 support::token(&self.syntax, T![lifetime])
1041 }
989} 1042}
1043
990#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1044#[derive(Debug, Clone, PartialEq, Eq, Hash)]
991pub struct BlockExpr { 1045pub struct BlockExpr {
992 pub(crate) syntax: SyntaxNode, 1046 pub(crate) syntax: SyntaxNode,
@@ -1005,9 +1059,10 @@ impl AstNode for BlockExpr {
1005impl ast::AttrsOwner for BlockExpr {} 1059impl ast::AttrsOwner for BlockExpr {}
1006impl BlockExpr { 1060impl BlockExpr {
1007 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } 1061 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1008 pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } 1062 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
1009 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) } 1063 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
1010} 1064}
1065
1011#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1066#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1012pub struct ReturnExpr { 1067pub struct ReturnExpr {
1013 pub(crate) syntax: SyntaxNode, 1068 pub(crate) syntax: SyntaxNode,
@@ -1027,6 +1082,7 @@ impl ast::AttrsOwner for ReturnExpr {}
1027impl ReturnExpr { 1082impl ReturnExpr {
1028 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1083 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1029} 1084}
1085
1030#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1086#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1031pub struct CallExpr { 1087pub struct CallExpr {
1032 pub(crate) syntax: SyntaxNode, 1088 pub(crate) syntax: SyntaxNode,
@@ -1046,6 +1102,7 @@ impl ast::ArgListOwner for CallExpr {}
1046impl CallExpr { 1102impl CallExpr {
1047 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1103 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1048} 1104}
1105
1049#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1106#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1050pub struct MethodCallExpr { 1107pub struct MethodCallExpr {
1051 pub(crate) syntax: SyntaxNode, 1108 pub(crate) syntax: SyntaxNode,
@@ -1065,10 +1122,11 @@ impl ast::AttrsOwner for MethodCallExpr {}
1065impl ast::ArgListOwner for MethodCallExpr {} 1122impl ast::ArgListOwner for MethodCallExpr {}
1066impl MethodCallExpr { 1123impl MethodCallExpr {
1067 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1124 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1068 pub fn dot(&self) -> Option<Dot> { support::token(&self.syntax) } 1125 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1069 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1126 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1070 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 1127 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1071} 1128}
1129
1072#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1073pub struct IndexExpr { 1131pub struct IndexExpr {
1074 pub(crate) syntax: SyntaxNode, 1132 pub(crate) syntax: SyntaxNode,
@@ -1086,9 +1144,10 @@ impl AstNode for IndexExpr {
1086} 1144}
1087impl ast::AttrsOwner for IndexExpr {} 1145impl ast::AttrsOwner for IndexExpr {}
1088impl IndexExpr { 1146impl IndexExpr {
1089 pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } 1147 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1090 pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } 1148 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1091} 1149}
1150
1092#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1151#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1093pub struct FieldExpr { 1152pub struct FieldExpr {
1094 pub(crate) syntax: SyntaxNode, 1153 pub(crate) syntax: SyntaxNode,
@@ -1107,9 +1166,10 @@ impl AstNode for FieldExpr {
1107impl ast::AttrsOwner for FieldExpr {} 1166impl ast::AttrsOwner for FieldExpr {}
1108impl FieldExpr { 1167impl FieldExpr {
1109 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1168 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1110 pub fn dot(&self) -> Option<Dot> { support::token(&self.syntax) } 1169 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1111 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1170 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1112} 1171}
1172
1113#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1114pub struct AwaitExpr { 1174pub struct AwaitExpr {
1115 pub(crate) syntax: SyntaxNode, 1175 pub(crate) syntax: SyntaxNode,
@@ -1128,9 +1188,10 @@ impl AstNode for AwaitExpr {
1128impl ast::AttrsOwner for AwaitExpr {} 1188impl ast::AttrsOwner for AwaitExpr {}
1129impl AwaitExpr { 1189impl AwaitExpr {
1130 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1190 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1131 pub fn dot(&self) -> Option<Dot> { support::token(&self.syntax) } 1191 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1132 pub fn await_kw(&self) -> Option<AwaitKw> { support::token(&self.syntax) } 1192 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1133} 1193}
1194
1134#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1195#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1135pub struct TryExpr { 1196pub struct TryExpr {
1136 pub(crate) syntax: SyntaxNode, 1197 pub(crate) syntax: SyntaxNode,
@@ -1148,9 +1209,10 @@ impl AstNode for TryExpr {
1148} 1209}
1149impl ast::AttrsOwner for TryExpr {} 1210impl ast::AttrsOwner for TryExpr {}
1150impl TryExpr { 1211impl TryExpr {
1151 pub fn try_kw(&self) -> Option<TryKw> { support::token(&self.syntax) } 1212 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
1152 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1213 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1153} 1214}
1215
1154#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1216#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1155pub struct CastExpr { 1217pub struct CastExpr {
1156 pub(crate) syntax: SyntaxNode, 1218 pub(crate) syntax: SyntaxNode,
@@ -1169,9 +1231,10 @@ impl AstNode for CastExpr {
1169impl ast::AttrsOwner for CastExpr {} 1231impl ast::AttrsOwner for CastExpr {}
1170impl CastExpr { 1232impl CastExpr {
1171 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1233 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1172 pub fn as_kw(&self) -> Option<AsKw> { support::token(&self.syntax) } 1234 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1173 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1235 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1174} 1236}
1237
1175#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1176pub struct RefExpr { 1239pub struct RefExpr {
1177 pub(crate) syntax: SyntaxNode, 1240 pub(crate) syntax: SyntaxNode,
@@ -1189,11 +1252,12 @@ impl AstNode for RefExpr {
1189} 1252}
1190impl ast::AttrsOwner for RefExpr {} 1253impl ast::AttrsOwner for RefExpr {}
1191impl RefExpr { 1254impl RefExpr {
1192 pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } 1255 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1193 pub fn raw_kw(&self) -> Option<RawKw> { support::token(&self.syntax) } 1256 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) }
1194 pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } 1257 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1195 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1258 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1196} 1259}
1260
1197#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1261#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1198pub struct PrefixExpr { 1262pub struct PrefixExpr {
1199 pub(crate) syntax: SyntaxNode, 1263 pub(crate) syntax: SyntaxNode,
@@ -1211,9 +1275,9 @@ impl AstNode for PrefixExpr {
1211} 1275}
1212impl ast::AttrsOwner for PrefixExpr {} 1276impl ast::AttrsOwner for PrefixExpr {}
1213impl PrefixExpr { 1277impl PrefixExpr {
1214 pub fn prefix_op(&self) -> Option<PrefixOp> { support::token(&self.syntax) }
1215 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1278 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1216} 1279}
1280
1217#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1281#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1218pub struct BoxExpr { 1282pub struct BoxExpr {
1219 pub(crate) syntax: SyntaxNode, 1283 pub(crate) syntax: SyntaxNode,
@@ -1231,9 +1295,10 @@ impl AstNode for BoxExpr {
1231} 1295}
1232impl ast::AttrsOwner for BoxExpr {} 1296impl ast::AttrsOwner for BoxExpr {}
1233impl BoxExpr { 1297impl BoxExpr {
1234 pub fn box_kw(&self) -> Option<BoxKw> { support::token(&self.syntax) } 1298 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1235 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1299 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1236} 1300}
1301
1237#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1302#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1238pub struct RangeExpr { 1303pub struct RangeExpr {
1239 pub(crate) syntax: SyntaxNode, 1304 pub(crate) syntax: SyntaxNode,
@@ -1250,9 +1315,8 @@ impl AstNode for RangeExpr {
1250 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1315 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1251} 1316}
1252impl ast::AttrsOwner for RangeExpr {} 1317impl ast::AttrsOwner for RangeExpr {}
1253impl RangeExpr { 1318impl RangeExpr {}
1254 pub fn range_op(&self) -> Option<RangeOp> { support::token(&self.syntax) } 1319
1255}
1256#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1257pub struct BinExpr { 1321pub struct BinExpr {
1258 pub(crate) syntax: SyntaxNode, 1322 pub(crate) syntax: SyntaxNode,
@@ -1269,9 +1333,8 @@ impl AstNode for BinExpr {
1269 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1333 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1270} 1334}
1271impl ast::AttrsOwner for BinExpr {} 1335impl ast::AttrsOwner for BinExpr {}
1272impl BinExpr { 1336impl BinExpr {}
1273 pub fn bin_op(&self) -> Option<BinOp> { support::token(&self.syntax) } 1337
1274}
1275#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1338#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1276pub struct Literal { 1339pub struct Literal {
1277 pub(crate) syntax: SyntaxNode, 1340 pub(crate) syntax: SyntaxNode,
@@ -1287,9 +1350,8 @@ impl AstNode for Literal {
1287 } 1350 }
1288 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1351 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1289} 1352}
1290impl Literal { 1353impl Literal {}
1291 pub fn literal_token(&self) -> Option<LiteralToken> { support::token(&self.syntax) } 1354
1292}
1293#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1355#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1294pub struct MatchExpr { 1356pub struct MatchExpr {
1295 pub(crate) syntax: SyntaxNode, 1357 pub(crate) syntax: SyntaxNode,
@@ -1307,10 +1369,11 @@ impl AstNode for MatchExpr {
1307} 1369}
1308impl ast::AttrsOwner for MatchExpr {} 1370impl ast::AttrsOwner for MatchExpr {}
1309impl MatchExpr { 1371impl MatchExpr {
1310 pub fn match_kw(&self) -> Option<MatchKw> { support::token(&self.syntax) } 1372 pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) }
1311 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1373 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1312 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } 1374 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1313} 1375}
1376
1314#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1315pub struct MatchArmList { 1378pub struct MatchArmList {
1316 pub(crate) syntax: SyntaxNode, 1379 pub(crate) syntax: SyntaxNode,
@@ -1328,10 +1391,11 @@ impl AstNode for MatchArmList {
1328} 1391}
1329impl ast::AttrsOwner for MatchArmList {} 1392impl ast::AttrsOwner for MatchArmList {}
1330impl MatchArmList { 1393impl MatchArmList {
1331 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 1394 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1332 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } 1395 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1333 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 1396 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1334} 1397}
1398
1335#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1399#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1336pub struct MatchArm { 1400pub struct MatchArm {
1337 pub(crate) syntax: SyntaxNode, 1401 pub(crate) syntax: SyntaxNode,
@@ -1351,9 +1415,10 @@ impl ast::AttrsOwner for MatchArm {}
1351impl MatchArm { 1415impl MatchArm {
1352 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1416 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1353 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) } 1417 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
1354 pub fn fat_arrow(&self) -> Option<FatArrow> { support::token(&self.syntax) } 1418 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1355 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1419 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1356} 1420}
1421
1357#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1358pub struct MatchGuard { 1423pub struct MatchGuard {
1359 pub(crate) syntax: SyntaxNode, 1424 pub(crate) syntax: SyntaxNode,
@@ -1370,9 +1435,10 @@ impl AstNode for MatchGuard {
1370 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1435 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1371} 1436}
1372impl MatchGuard { 1437impl MatchGuard {
1373 pub fn if_kw(&self) -> Option<IfKw> { support::token(&self.syntax) } 1438 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1374 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1439 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1375} 1440}
1441
1376#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1442#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1377pub struct RecordLit { 1443pub struct RecordLit {
1378 pub(crate) syntax: SyntaxNode, 1444 pub(crate) syntax: SyntaxNode,
@@ -1392,6 +1458,7 @@ impl RecordLit {
1392 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1458 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1393 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } 1459 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
1394} 1460}
1461
1395#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1462#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1396pub struct RecordFieldList { 1463pub struct RecordFieldList {
1397 pub(crate) syntax: SyntaxNode, 1464 pub(crate) syntax: SyntaxNode,
@@ -1408,12 +1475,13 @@ impl AstNode for RecordFieldList {
1408 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1475 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1409} 1476}
1410impl RecordFieldList { 1477impl RecordFieldList {
1411 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 1478 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1412 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } 1479 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
1413 pub fn dotdot(&self) -> Option<Dotdot> { support::token(&self.syntax) } 1480 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1414 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } 1481 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1415 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 1482 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1416} 1483}
1484
1417#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1485#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1418pub struct RecordField { 1486pub struct RecordField {
1419 pub(crate) syntax: SyntaxNode, 1487 pub(crate) syntax: SyntaxNode,
@@ -1432,9 +1500,10 @@ impl AstNode for RecordField {
1432impl ast::AttrsOwner for RecordField {} 1500impl ast::AttrsOwner for RecordField {}
1433impl RecordField { 1501impl RecordField {
1434 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1502 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1435 pub fn colon(&self) -> Option<Colon> { support::token(&self.syntax) } 1503 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1436 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1504 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1437} 1505}
1506
1438#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1507#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1439pub struct OrPat { 1508pub struct OrPat {
1440 pub(crate) syntax: SyntaxNode, 1509 pub(crate) syntax: SyntaxNode,
@@ -1453,6 +1522,7 @@ impl AstNode for OrPat {
1453impl OrPat { 1522impl OrPat {
1454 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1523 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1455} 1524}
1525
1456#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1526#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1457pub struct ParenPat { 1527pub struct ParenPat {
1458 pub(crate) syntax: SyntaxNode, 1528 pub(crate) syntax: SyntaxNode,
@@ -1469,10 +1539,11 @@ impl AstNode for ParenPat {
1469 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1470} 1540}
1471impl ParenPat { 1541impl ParenPat {
1472 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 1542 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1473 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1543 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1474 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 1544 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1475} 1545}
1546
1476#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1547#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1477pub struct RefPat { 1548pub struct RefPat {
1478 pub(crate) syntax: SyntaxNode, 1549 pub(crate) syntax: SyntaxNode,
@@ -1489,10 +1560,11 @@ impl AstNode for RefPat {
1489 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1560 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1490} 1561}
1491impl RefPat { 1562impl RefPat {
1492 pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } 1563 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1493 pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } 1564 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1494 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1565 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1495} 1566}
1567
1496#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1497pub struct BoxPat { 1569pub struct BoxPat {
1498 pub(crate) syntax: SyntaxNode, 1570 pub(crate) syntax: SyntaxNode,
@@ -1509,9 +1581,10 @@ impl AstNode for BoxPat {
1509 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1581 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1510} 1582}
1511impl BoxPat { 1583impl BoxPat {
1512 pub fn box_kw(&self) -> Option<BoxKw> { support::token(&self.syntax) } 1584 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1513 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1585 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1514} 1586}
1587
1515#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1516pub struct BindPat { 1589pub struct BindPat {
1517 pub(crate) syntax: SyntaxNode, 1590 pub(crate) syntax: SyntaxNode,
@@ -1530,10 +1603,12 @@ impl AstNode for BindPat {
1530impl ast::AttrsOwner for BindPat {} 1603impl ast::AttrsOwner for BindPat {}
1531impl ast::NameOwner for BindPat {} 1604impl ast::NameOwner for BindPat {}
1532impl BindPat { 1605impl BindPat {
1533 pub fn ref_kw(&self) -> Option<RefKw> { support::token(&self.syntax) } 1606 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1534 pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } 1607 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1608 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1535 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1609 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1536} 1610}
1611
1537#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1612#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1538pub struct PlaceholderPat { 1613pub struct PlaceholderPat {
1539 pub(crate) syntax: SyntaxNode, 1614 pub(crate) syntax: SyntaxNode,
@@ -1550,8 +1625,9 @@ impl AstNode for PlaceholderPat {
1550 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1625 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1551} 1626}
1552impl PlaceholderPat { 1627impl PlaceholderPat {
1553 pub fn underscore(&self) -> Option<Underscore> { support::token(&self.syntax) } 1628 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1554} 1629}
1630
1555#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1556pub struct DotDotPat { 1632pub struct DotDotPat {
1557 pub(crate) syntax: SyntaxNode, 1633 pub(crate) syntax: SyntaxNode,
@@ -1568,8 +1644,9 @@ impl AstNode for DotDotPat {
1568 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1644 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1569} 1645}
1570impl DotDotPat { 1646impl DotDotPat {
1571 pub fn dotdot(&self) -> Option<Dotdot> { support::token(&self.syntax) } 1647 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1572} 1648}
1649
1573#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1650#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1574pub struct PathPat { 1651pub struct PathPat {
1575 pub(crate) syntax: SyntaxNode, 1652 pub(crate) syntax: SyntaxNode,
@@ -1588,6 +1665,7 @@ impl AstNode for PathPat {
1588impl PathPat { 1665impl PathPat {
1589 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1666 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1590} 1667}
1668
1591#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1669#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1592pub struct SlicePat { 1670pub struct SlicePat {
1593 pub(crate) syntax: SyntaxNode, 1671 pub(crate) syntax: SyntaxNode,
@@ -1604,10 +1682,11 @@ impl AstNode for SlicePat {
1604 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1682 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1605} 1683}
1606impl SlicePat { 1684impl SlicePat {
1607 pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } 1685 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1608 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1686 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1609 pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } 1687 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1610} 1688}
1689
1611#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1690#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1612pub struct RangePat { 1691pub struct RangePat {
1613 pub(crate) syntax: SyntaxNode, 1692 pub(crate) syntax: SyntaxNode,
@@ -1623,9 +1702,8 @@ impl AstNode for RangePat {
1623 } 1702 }
1624 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1703 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1625} 1704}
1626impl RangePat { 1705impl RangePat {}
1627 pub fn range_separator(&self) -> Option<RangeSeparator> { support::token(&self.syntax) } 1706
1628}
1629#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1707#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1630pub struct LiteralPat { 1708pub struct LiteralPat {
1631 pub(crate) syntax: SyntaxNode, 1709 pub(crate) syntax: SyntaxNode,
@@ -1644,6 +1722,7 @@ impl AstNode for LiteralPat {
1644impl LiteralPat { 1722impl LiteralPat {
1645 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1723 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1646} 1724}
1725
1647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1726#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1648pub struct MacroPat { 1727pub struct MacroPat {
1649 pub(crate) syntax: SyntaxNode, 1728 pub(crate) syntax: SyntaxNode,
@@ -1662,6 +1741,7 @@ impl AstNode for MacroPat {
1662impl MacroPat { 1741impl MacroPat {
1663 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } 1742 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1664} 1743}
1744
1665#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1745#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1666pub struct RecordPat { 1746pub struct RecordPat {
1667 pub(crate) syntax: SyntaxNode, 1747 pub(crate) syntax: SyntaxNode,
@@ -1683,6 +1763,7 @@ impl RecordPat {
1683 } 1763 }
1684 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1764 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1685} 1765}
1766
1686#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1767#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1687pub struct RecordFieldPatList { 1768pub struct RecordFieldPatList {
1688 pub(crate) syntax: SyntaxNode, 1769 pub(crate) syntax: SyntaxNode,
@@ -1699,15 +1780,16 @@ impl AstNode for RecordFieldPatList {
1699 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1780 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1700} 1781}
1701impl RecordFieldPatList { 1782impl RecordFieldPatList {
1702 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 1783 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1703 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) } 1784 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
1704 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { 1785 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1705 support::children(&self.syntax) 1786 support::children(&self.syntax)
1706 } 1787 }
1707 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) } 1788 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1708 pub fn dotdot(&self) -> Option<Dotdot> { support::token(&self.syntax) } 1789 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1709 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 1790 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1710} 1791}
1792
1711#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1793#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1712pub struct RecordFieldPat { 1794pub struct RecordFieldPat {
1713 pub(crate) syntax: SyntaxNode, 1795 pub(crate) syntax: SyntaxNode,
@@ -1726,9 +1808,10 @@ impl AstNode for RecordFieldPat {
1726impl ast::AttrsOwner for RecordFieldPat {} 1808impl ast::AttrsOwner for RecordFieldPat {}
1727impl ast::NameOwner for RecordFieldPat {} 1809impl ast::NameOwner for RecordFieldPat {}
1728impl RecordFieldPat { 1810impl RecordFieldPat {
1729 pub fn colon(&self) -> Option<Colon> { support::token(&self.syntax) } 1811 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1730 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1812 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1731} 1813}
1814
1732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1815#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1733pub struct TupleStructPat { 1816pub struct TupleStructPat {
1734 pub(crate) syntax: SyntaxNode, 1817 pub(crate) syntax: SyntaxNode,
@@ -1746,10 +1829,11 @@ impl AstNode for TupleStructPat {
1746} 1829}
1747impl TupleStructPat { 1830impl TupleStructPat {
1748 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1831 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1749 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 1832 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1750 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1833 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1751 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 1834 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1752} 1835}
1836
1753#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1837#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1754pub struct TuplePat { 1838pub struct TuplePat {
1755 pub(crate) syntax: SyntaxNode, 1839 pub(crate) syntax: SyntaxNode,
@@ -1766,10 +1850,11 @@ impl AstNode for TuplePat {
1766 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1850 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1767} 1851}
1768impl TuplePat { 1852impl TuplePat {
1769 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 1853 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1770 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1854 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1771 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 1855 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1772} 1856}
1857
1773#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1858#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1774pub struct Visibility { 1859pub struct Visibility {
1775 pub(crate) syntax: SyntaxNode, 1860 pub(crate) syntax: SyntaxNode,
@@ -1786,11 +1871,12 @@ impl AstNode for Visibility {
1786 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1871 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1787} 1872}
1788impl Visibility { 1873impl Visibility {
1789 pub fn pub_kw(&self) -> Option<PubKw> { support::token(&self.syntax) } 1874 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
1790 pub fn super_kw(&self) -> Option<SuperKw> { support::token(&self.syntax) } 1875 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
1791 pub fn self_kw(&self) -> Option<SelfKw> { support::token(&self.syntax) } 1876 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1792 pub fn crate_kw(&self) -> Option<CrateKw> { support::token(&self.syntax) } 1877 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1793} 1878}
1879
1794#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1880#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1795pub struct Name { 1881pub struct Name {
1796 pub(crate) syntax: SyntaxNode, 1882 pub(crate) syntax: SyntaxNode,
@@ -1807,8 +1893,9 @@ impl AstNode for Name {
1807 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1893 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1808} 1894}
1809impl Name { 1895impl Name {
1810 pub fn ident(&self) -> Option<Ident> { support::token(&self.syntax) } 1896 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
1811} 1897}
1898
1812#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1813pub struct NameRef { 1900pub struct NameRef {
1814 pub(crate) syntax: SyntaxNode, 1901 pub(crate) syntax: SyntaxNode,
@@ -1824,9 +1911,8 @@ impl AstNode for NameRef {
1824 } 1911 }
1825 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1912 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1826} 1913}
1827impl NameRef { 1914impl NameRef {}
1828 pub fn name_ref_token(&self) -> Option<NameRefToken> { support::token(&self.syntax) } 1915
1829}
1830#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1916#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1831pub struct MacroCall { 1917pub struct MacroCall {
1832 pub(crate) syntax: SyntaxNode, 1918 pub(crate) syntax: SyntaxNode,
@@ -1847,10 +1933,11 @@ impl ast::AttrsOwner for MacroCall {}
1847impl ast::DocCommentsOwner for MacroCall {} 1933impl ast::DocCommentsOwner for MacroCall {}
1848impl MacroCall { 1934impl MacroCall {
1849 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1935 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1850 pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } 1936 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1851 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 1937 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1852 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 1938 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1853} 1939}
1940
1854#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1941#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1855pub struct Attr { 1942pub struct Attr {
1856 pub(crate) syntax: SyntaxNode, 1943 pub(crate) syntax: SyntaxNode,
@@ -1867,14 +1954,15 @@ impl AstNode for Attr {
1867 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1954 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1868} 1955}
1869impl Attr { 1956impl Attr {
1870 pub fn pound(&self) -> Option<Pound> { support::token(&self.syntax) } 1957 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1871 pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } 1958 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1872 pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } 1959 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1873 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1960 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1874 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 1961 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1875 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } 1962 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1876 pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } 1963 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1877} 1964}
1965
1878#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1966#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1879pub struct TokenTree { 1967pub struct TokenTree {
1880 pub(crate) syntax: SyntaxNode, 1968 pub(crate) syntax: SyntaxNode,
@@ -1891,6 +1979,7 @@ impl AstNode for TokenTree {
1891 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1979 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1892} 1980}
1893impl TokenTree {} 1981impl TokenTree {}
1982
1894#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1983#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1895pub struct TypeParamList { 1984pub struct TypeParamList {
1896 pub(crate) syntax: SyntaxNode, 1985 pub(crate) syntax: SyntaxNode,
@@ -1907,13 +1996,14 @@ impl AstNode for TypeParamList {
1907 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1996 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1908} 1997}
1909impl TypeParamList { 1998impl TypeParamList {
1910 pub fn l_angle(&self) -> Option<LAngle> { support::token(&self.syntax) } 1999 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1911 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) } 2000 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1912 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) } 2001 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1913 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) } 2002 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1914 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) } 2003 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1915 pub fn r_angle(&self) -> Option<RAngle> { support::token(&self.syntax) } 2004 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1916} 2005}
2006
1917#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2007#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1918pub struct TypeParam { 2008pub struct TypeParam {
1919 pub(crate) syntax: SyntaxNode, 2009 pub(crate) syntax: SyntaxNode,
@@ -1933,9 +2023,10 @@ impl ast::NameOwner for TypeParam {}
1933impl ast::AttrsOwner for TypeParam {} 2023impl ast::AttrsOwner for TypeParam {}
1934impl ast::TypeBoundsOwner for TypeParam {} 2024impl ast::TypeBoundsOwner for TypeParam {}
1935impl TypeParam { 2025impl TypeParam {
1936 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2026 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1937 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2027 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1938} 2028}
2029
1939#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1940pub struct ConstParam { 2031pub struct ConstParam {
1941 pub(crate) syntax: SyntaxNode, 2032 pub(crate) syntax: SyntaxNode,
@@ -1955,9 +2046,10 @@ impl ast::NameOwner for ConstParam {}
1955impl ast::AttrsOwner for ConstParam {} 2046impl ast::AttrsOwner for ConstParam {}
1956impl ast::TypeAscriptionOwner for ConstParam {} 2047impl ast::TypeAscriptionOwner for ConstParam {}
1957impl ConstParam { 2048impl ConstParam {
1958 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2049 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1959 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } 2050 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1960} 2051}
2052
1961#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2053#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1962pub struct LifetimeParam { 2054pub struct LifetimeParam {
1963 pub(crate) syntax: SyntaxNode, 2055 pub(crate) syntax: SyntaxNode,
@@ -1975,8 +2067,11 @@ impl AstNode for LifetimeParam {
1975} 2067}
1976impl ast::AttrsOwner for LifetimeParam {} 2068impl ast::AttrsOwner for LifetimeParam {}
1977impl LifetimeParam { 2069impl LifetimeParam {
1978 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2070 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2071 support::token(&self.syntax, T![lifetime])
2072 }
1979} 2073}
2074
1980#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2075#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1981pub struct TypeBound { 2076pub struct TypeBound {
1982 pub(crate) syntax: SyntaxNode, 2077 pub(crate) syntax: SyntaxNode,
@@ -1993,10 +2088,13 @@ impl AstNode for TypeBound {
1993 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2088 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1994} 2089}
1995impl TypeBound { 2090impl TypeBound {
1996 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2091 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1997 pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } 2092 support::token(&self.syntax, T![lifetime])
2093 }
2094 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1998 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2095 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1999} 2096}
2097
2000#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2098#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2001pub struct TypeBoundList { 2099pub struct TypeBoundList {
2002 pub(crate) syntax: SyntaxNode, 2100 pub(crate) syntax: SyntaxNode,
@@ -2015,6 +2113,7 @@ impl AstNode for TypeBoundList {
2015impl TypeBoundList { 2113impl TypeBoundList {
2016 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } 2114 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2017} 2115}
2116
2018#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019pub struct WherePred { 2118pub struct WherePred {
2020 pub(crate) syntax: SyntaxNode, 2119 pub(crate) syntax: SyntaxNode,
@@ -2032,9 +2131,12 @@ impl AstNode for WherePred {
2032} 2131}
2033impl ast::TypeBoundsOwner for WherePred {} 2132impl ast::TypeBoundsOwner for WherePred {}
2034impl WherePred { 2133impl WherePred {
2035 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2134 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2135 support::token(&self.syntax, T![lifetime])
2136 }
2036 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2137 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2037} 2138}
2139
2038#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2140#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2039pub struct WhereClause { 2141pub struct WhereClause {
2040 pub(crate) syntax: SyntaxNode, 2142 pub(crate) syntax: SyntaxNode,
@@ -2051,9 +2153,10 @@ impl AstNode for WhereClause {
2051 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2153 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2052} 2154}
2053impl WhereClause { 2155impl WhereClause {
2054 pub fn where_kw(&self) -> Option<WhereKw> { support::token(&self.syntax) } 2156 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
2055 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } 2157 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2056} 2158}
2159
2057#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2058pub struct Abi { 2161pub struct Abi {
2059 pub(crate) syntax: SyntaxNode, 2162 pub(crate) syntax: SyntaxNode,
@@ -2069,9 +2172,8 @@ impl AstNode for Abi {
2069 } 2172 }
2070 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2173 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2071} 2174}
2072impl Abi { 2175impl Abi {}
2073 pub fn string(&self) -> Option<String> { support::token(&self.syntax) } 2176
2074}
2075#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2177#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2076pub struct ExprStmt { 2178pub struct ExprStmt {
2077 pub(crate) syntax: SyntaxNode, 2179 pub(crate) syntax: SyntaxNode,
@@ -2090,8 +2192,9 @@ impl AstNode for ExprStmt {
2090impl ast::AttrsOwner for ExprStmt {} 2192impl ast::AttrsOwner for ExprStmt {}
2091impl ExprStmt { 2193impl ExprStmt {
2092 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2194 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2093 pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } 2195 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2094} 2196}
2197
2095#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2096pub struct LetStmt { 2199pub struct LetStmt {
2097 pub(crate) syntax: SyntaxNode, 2200 pub(crate) syntax: SyntaxNode,
@@ -2110,11 +2213,13 @@ impl AstNode for LetStmt {
2110impl ast::AttrsOwner for LetStmt {} 2213impl ast::AttrsOwner for LetStmt {}
2111impl ast::TypeAscriptionOwner for LetStmt {} 2214impl ast::TypeAscriptionOwner for LetStmt {}
2112impl LetStmt { 2215impl LetStmt {
2113 pub fn let_kw(&self) -> Option<LetKw> { support::token(&self.syntax) } 2216 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2114 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2217 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2115 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2218 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2116 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 2219 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2220 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2117} 2221}
2222
2118#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2223#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2119pub struct Condition { 2224pub struct Condition {
2120 pub(crate) syntax: SyntaxNode, 2225 pub(crate) syntax: SyntaxNode,
@@ -2131,11 +2236,12 @@ impl AstNode for Condition {
2131 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2236 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2132} 2237}
2133impl Condition { 2238impl Condition {
2134 pub fn let_kw(&self) -> Option<LetKw> { support::token(&self.syntax) } 2239 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2135 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2240 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2136 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2241 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2137 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2242 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2138} 2243}
2244
2139#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2245#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2140pub struct Block { 2246pub struct Block {
2141 pub(crate) syntax: SyntaxNode, 2247 pub(crate) syntax: SyntaxNode,
@@ -2154,11 +2260,12 @@ impl AstNode for Block {
2154impl ast::AttrsOwner for Block {} 2260impl ast::AttrsOwner for Block {}
2155impl ast::ModuleItemOwner for Block {} 2261impl ast::ModuleItemOwner for Block {}
2156impl Block { 2262impl Block {
2157 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 2263 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2158 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } 2264 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2159 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2265 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2160 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 2266 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2161} 2267}
2268
2162#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2269#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2163pub struct ParamList { 2270pub struct ParamList {
2164 pub(crate) syntax: SyntaxNode, 2271 pub(crate) syntax: SyntaxNode,
@@ -2175,11 +2282,12 @@ impl AstNode for ParamList {
2175 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2282 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2176} 2283}
2177impl ParamList { 2284impl ParamList {
2178 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 2285 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2179 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } 2286 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2180 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } 2287 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2181 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 2288 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2182} 2289}
2290
2183#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2291#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2184pub struct SelfParam { 2292pub struct SelfParam {
2185 pub(crate) syntax: SyntaxNode, 2293 pub(crate) syntax: SyntaxNode,
@@ -2198,10 +2306,14 @@ impl AstNode for SelfParam {
2198impl ast::TypeAscriptionOwner for SelfParam {} 2306impl ast::TypeAscriptionOwner for SelfParam {}
2199impl ast::AttrsOwner for SelfParam {} 2307impl ast::AttrsOwner for SelfParam {}
2200impl SelfParam { 2308impl SelfParam {
2201 pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } 2309 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2202 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2310 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2203 pub fn self_kw(&self) -> Option<SelfKw> { support::token(&self.syntax) } 2311 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2312 support::token(&self.syntax, T![lifetime])
2313 }
2314 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2204} 2315}
2316
2205#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2317#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2206pub struct Param { 2318pub struct Param {
2207 pub(crate) syntax: SyntaxNode, 2319 pub(crate) syntax: SyntaxNode,
@@ -2221,8 +2333,9 @@ impl ast::TypeAscriptionOwner for Param {}
2221impl ast::AttrsOwner for Param {} 2333impl ast::AttrsOwner for Param {}
2222impl Param { 2334impl Param {
2223 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 2335 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2224 pub fn dotdotdot(&self) -> Option<Dotdotdot> { support::token(&self.syntax) } 2336 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2225} 2337}
2338
2226#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2339#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2227pub struct UseItem { 2340pub struct UseItem {
2228 pub(crate) syntax: SyntaxNode, 2341 pub(crate) syntax: SyntaxNode,
@@ -2241,9 +2354,10 @@ impl AstNode for UseItem {
2241impl ast::AttrsOwner for UseItem {} 2354impl ast::AttrsOwner for UseItem {}
2242impl ast::VisibilityOwner for UseItem {} 2355impl ast::VisibilityOwner for UseItem {}
2243impl UseItem { 2356impl UseItem {
2244 pub fn use_kw(&self) -> Option<UseKw> { support::token(&self.syntax) } 2357 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2245 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } 2358 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2246} 2359}
2360
2247#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2361#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2248pub struct UseTree { 2362pub struct UseTree {
2249 pub(crate) syntax: SyntaxNode, 2363 pub(crate) syntax: SyntaxNode,
@@ -2261,10 +2375,11 @@ impl AstNode for UseTree {
2261} 2375}
2262impl UseTree { 2376impl UseTree {
2263 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 2377 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2264 pub fn star(&self) -> Option<Star> { support::token(&self.syntax) } 2378 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2265 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } 2379 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2266 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 2380 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2267} 2381}
2382
2268#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2383#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2269pub struct Alias { 2384pub struct Alias {
2270 pub(crate) syntax: SyntaxNode, 2385 pub(crate) syntax: SyntaxNode,
@@ -2282,8 +2397,9 @@ impl AstNode for Alias {
2282} 2397}
2283impl ast::NameOwner for Alias {} 2398impl ast::NameOwner for Alias {}
2284impl Alias { 2399impl Alias {
2285 pub fn as_kw(&self) -> Option<AsKw> { support::token(&self.syntax) } 2400 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2286} 2401}
2402
2287#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2403#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2288pub struct UseTreeList { 2404pub struct UseTreeList {
2289 pub(crate) syntax: SyntaxNode, 2405 pub(crate) syntax: SyntaxNode,
@@ -2300,10 +2416,11 @@ impl AstNode for UseTreeList {
2300 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2416 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2301} 2417}
2302impl UseTreeList { 2418impl UseTreeList {
2303 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 2419 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2304 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) } 2420 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2305 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 2421 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2306} 2422}
2423
2307#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2424#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2308pub struct ExternCrateItem { 2425pub struct ExternCrateItem {
2309 pub(crate) syntax: SyntaxNode, 2426 pub(crate) syntax: SyntaxNode,
@@ -2322,11 +2439,12 @@ impl AstNode for ExternCrateItem {
2322impl ast::AttrsOwner for ExternCrateItem {} 2439impl ast::AttrsOwner for ExternCrateItem {}
2323impl ast::VisibilityOwner for ExternCrateItem {} 2440impl ast::VisibilityOwner for ExternCrateItem {}
2324impl ExternCrateItem { 2441impl ExternCrateItem {
2325 pub fn extern_kw(&self) -> Option<ExternKw> { support::token(&self.syntax) } 2442 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2326 pub fn crate_kw(&self) -> Option<CrateKw> { support::token(&self.syntax) } 2443 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2327 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 2444 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2328 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } 2445 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2329} 2446}
2447
2330#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2448#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2331pub struct ArgList { 2449pub struct ArgList {
2332 pub(crate) syntax: SyntaxNode, 2450 pub(crate) syntax: SyntaxNode,
@@ -2343,10 +2461,11 @@ impl AstNode for ArgList {
2343 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2461 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2344} 2462}
2345impl ArgList { 2463impl ArgList {
2346 pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } 2464 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2347 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 2465 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2348 pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } 2466 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2349} 2467}
2468
2350#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2469#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2351pub struct Path { 2470pub struct Path {
2352 pub(crate) syntax: SyntaxNode, 2471 pub(crate) syntax: SyntaxNode,
@@ -2366,6 +2485,7 @@ impl Path {
2366 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } 2485 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2367 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) } 2486 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2368} 2487}
2488
2369#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2489#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2370pub struct PathSegment { 2490pub struct PathSegment {
2371 pub(crate) syntax: SyntaxNode, 2491 pub(crate) syntax: SyntaxNode,
@@ -2382,15 +2502,16 @@ impl AstNode for PathSegment {
2382 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2502 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2383} 2503}
2384impl PathSegment { 2504impl PathSegment {
2385 pub fn coloncolon(&self) -> Option<Coloncolon> { support::token(&self.syntax) } 2505 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2386 pub fn l_angle(&self) -> Option<LAngle> { support::token(&self.syntax) } 2506 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2387 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 2507 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2388 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 2508 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
2389 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 2509 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
2390 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 2510 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
2391 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } 2511 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2392 pub fn r_angle(&self) -> Option<RAngle> { support::token(&self.syntax) } 2512 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2393} 2513}
2514
2394#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2515#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2395pub struct TypeArgList { 2516pub struct TypeArgList {
2396 pub(crate) syntax: SyntaxNode, 2517 pub(crate) syntax: SyntaxNode,
@@ -2407,15 +2528,16 @@ impl AstNode for TypeArgList {
2407 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2528 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2408} 2529}
2409impl TypeArgList { 2530impl TypeArgList {
2410 pub fn coloncolon(&self) -> Option<Coloncolon> { support::token(&self.syntax) } 2531 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2411 pub fn l_angle(&self) -> Option<LAngle> { support::token(&self.syntax) } 2532 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2412 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) } 2533 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2413 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) } 2534 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2414 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) } 2535 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2415 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) } 2536 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2416 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } 2537 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2417 pub fn r_angle(&self) -> Option<RAngle> { support::token(&self.syntax) } 2538 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2418} 2539}
2540
2419#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2541#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2420pub struct TypeArg { 2542pub struct TypeArg {
2421 pub(crate) syntax: SyntaxNode, 2543 pub(crate) syntax: SyntaxNode,
@@ -2434,6 +2556,7 @@ impl AstNode for TypeArg {
2434impl TypeArg { 2556impl TypeArg {
2435 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2557 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2436} 2558}
2559
2437#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2560#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2438pub struct AssocTypeArg { 2561pub struct AssocTypeArg {
2439 pub(crate) syntax: SyntaxNode, 2562 pub(crate) syntax: SyntaxNode,
@@ -2452,9 +2575,10 @@ impl AstNode for AssocTypeArg {
2452impl ast::TypeBoundsOwner for AssocTypeArg {} 2575impl ast::TypeBoundsOwner for AssocTypeArg {}
2453impl AssocTypeArg { 2576impl AssocTypeArg {
2454 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 2577 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2455 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2578 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2456 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 2579 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2457} 2580}
2581
2458#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2582#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2459pub struct LifetimeArg { 2583pub struct LifetimeArg {
2460 pub(crate) syntax: SyntaxNode, 2584 pub(crate) syntax: SyntaxNode,
@@ -2471,8 +2595,11 @@ impl AstNode for LifetimeArg {
2471 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2595 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2472} 2596}
2473impl LifetimeArg { 2597impl LifetimeArg {
2474 pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } 2598 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2599 support::token(&self.syntax, T![lifetime])
2600 }
2475} 2601}
2602
2476#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2477pub struct ConstArg { 2604pub struct ConstArg {
2478 pub(crate) syntax: SyntaxNode, 2605 pub(crate) syntax: SyntaxNode,
@@ -2490,9 +2617,10 @@ impl AstNode for ConstArg {
2490} 2617}
2491impl ConstArg { 2618impl ConstArg {
2492 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 2619 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2493 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2620 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2494 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 2621 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2495} 2622}
2623
2496#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2624#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2497pub struct MacroItems { 2625pub struct MacroItems {
2498 pub(crate) syntax: SyntaxNode, 2626 pub(crate) syntax: SyntaxNode,
@@ -2509,8 +2637,8 @@ impl AstNode for MacroItems {
2509 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2637 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2510} 2638}
2511impl ast::ModuleItemOwner for MacroItems {} 2639impl ast::ModuleItemOwner for MacroItems {}
2512impl ast::FnDefOwner for MacroItems {}
2513impl MacroItems {} 2640impl MacroItems {}
2641
2514#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2642#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2515pub struct MacroStmts { 2643pub struct MacroStmts {
2516 pub(crate) syntax: SyntaxNode, 2644 pub(crate) syntax: SyntaxNode,
@@ -2530,6 +2658,7 @@ impl MacroStmts {
2530 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } 2658 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2531 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 2659 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2532} 2660}
2661
2533#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2662#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2534pub struct ExternItemList { 2663pub struct ExternItemList {
2535 pub(crate) syntax: SyntaxNode, 2664 pub(crate) syntax: SyntaxNode,
@@ -2545,13 +2674,13 @@ impl AstNode for ExternItemList {
2545 } 2674 }
2546 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2675 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2547} 2676}
2548impl ast::FnDefOwner for ExternItemList {}
2549impl ast::ModuleItemOwner for ExternItemList {} 2677impl ast::ModuleItemOwner for ExternItemList {}
2550impl ExternItemList { 2678impl ExternItemList {
2551 pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } 2679 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2552 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } 2680 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2553 pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } 2681 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2554} 2682}
2683
2555#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2684#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2556pub struct ExternBlock { 2685pub struct ExternBlock {
2557 pub(crate) syntax: SyntaxNode, 2686 pub(crate) syntax: SyntaxNode,
@@ -2571,6 +2700,7 @@ impl ExternBlock {
2571 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 2700 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2572 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } 2701 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2573} 2702}
2703
2574#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2704#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2575pub struct MetaItem { 2705pub struct MetaItem {
2576 pub(crate) syntax: SyntaxNode, 2706 pub(crate) syntax: SyntaxNode,
@@ -2588,10 +2718,11 @@ impl AstNode for MetaItem {
2588} 2718}
2589impl MetaItem { 2719impl MetaItem {
2590 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 2720 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2591 pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } 2721 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2592 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } 2722 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2593 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } 2723 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2594} 2724}
2725
2595#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2726#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2596pub struct MacroDef { 2727pub struct MacroDef {
2597 pub(crate) syntax: SyntaxNode, 2728 pub(crate) syntax: SyntaxNode,
@@ -2611,6 +2742,7 @@ impl MacroDef {
2611 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) } 2742 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2612 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 2743 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2613} 2744}
2745
2614#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2746#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2615pub enum NominalDef { 2747pub enum NominalDef {
2616 StructDef(StructDef), 2748 StructDef(StructDef),
@@ -2653,6 +2785,7 @@ impl AstNode for NominalDef {
2653impl ast::NameOwner for NominalDef {} 2785impl ast::NameOwner for NominalDef {}
2654impl ast::TypeParamsOwner for NominalDef {} 2786impl ast::TypeParamsOwner for NominalDef {}
2655impl ast::AttrsOwner for NominalDef {} 2787impl ast::AttrsOwner for NominalDef {}
2788
2656#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2789#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2657pub enum GenericParam { 2790pub enum GenericParam {
2658 LifetimeParam(LifetimeParam), 2791 LifetimeParam(LifetimeParam),
@@ -2692,6 +2825,7 @@ impl AstNode for GenericParam {
2692 } 2825 }
2693 } 2826 }
2694} 2827}
2828
2695#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2829#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2696pub enum GenericArg { 2830pub enum GenericArg {
2697 LifetimeArg(LifetimeArg), 2831 LifetimeArg(LifetimeArg),
@@ -2737,6 +2871,7 @@ impl AstNode for GenericArg {
2737 } 2871 }
2738 } 2872 }
2739} 2873}
2874
2740#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2875#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2741pub enum TypeRef { 2876pub enum TypeRef {
2742 ParenType(ParenType), 2877 ParenType(ParenType),
@@ -2838,6 +2973,7 @@ impl AstNode for TypeRef {
2838 } 2973 }
2839 } 2974 }
2840} 2975}
2976
2841#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2977#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2842pub enum ModuleItem { 2978pub enum ModuleItem {
2843 StructDef(StructDef), 2979 StructDef(StructDef),
@@ -2948,6 +3084,7 @@ impl AstNode for ModuleItem {
2948impl ast::NameOwner for ModuleItem {} 3084impl ast::NameOwner for ModuleItem {}
2949impl ast::AttrsOwner for ModuleItem {} 3085impl ast::AttrsOwner for ModuleItem {}
2950impl ast::VisibilityOwner for ModuleItem {} 3086impl ast::VisibilityOwner for ModuleItem {}
3087
2951#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3088#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2952pub enum ImplItem { 3089pub enum ImplItem {
2953 FnDef(FnDef), 3090 FnDef(FnDef),
@@ -2989,6 +3126,7 @@ impl AstNode for ImplItem {
2989} 3126}
2990impl ast::NameOwner for ImplItem {} 3127impl ast::NameOwner for ImplItem {}
2991impl ast::AttrsOwner for ImplItem {} 3128impl ast::AttrsOwner for ImplItem {}
3129
2992#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2993pub enum ExternItem { 3131pub enum ExternItem {
2994 FnDef(FnDef), 3132 FnDef(FnDef),
@@ -3025,6 +3163,7 @@ impl AstNode for ExternItem {
3025impl ast::NameOwner for ExternItem {} 3163impl ast::NameOwner for ExternItem {}
3026impl ast::AttrsOwner for ExternItem {} 3164impl ast::AttrsOwner for ExternItem {}
3027impl ast::VisibilityOwner for ExternItem {} 3165impl ast::VisibilityOwner for ExternItem {}
3166
3028#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3167#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3029pub enum Expr { 3168pub enum Expr {
3030 TupleExpr(TupleExpr), 3169 TupleExpr(TupleExpr),
@@ -3238,6 +3377,7 @@ impl AstNode for Expr {
3238 } 3377 }
3239} 3378}
3240impl ast::AttrsOwner for Expr {} 3379impl ast::AttrsOwner for Expr {}
3380
3241#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3242pub enum Pat { 3382pub enum Pat {
3243 OrPat(OrPat), 3383 OrPat(OrPat),
@@ -3351,6 +3491,7 @@ impl AstNode for Pat {
3351 } 3491 }
3352 } 3492 }
3353} 3493}
3494
3354#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3495#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3355pub enum RecordInnerPat { 3496pub enum RecordInnerPat {
3356 RecordFieldPat(RecordFieldPat), 3497 RecordFieldPat(RecordFieldPat),
@@ -3384,6 +3525,7 @@ impl AstNode for RecordInnerPat {
3384 } 3525 }
3385 } 3526 }
3386} 3527}
3528
3387#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3529#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3388pub enum AttrInput { 3530pub enum AttrInput {
3389 Literal(Literal), 3531 Literal(Literal),
@@ -3417,6 +3559,7 @@ impl AstNode for AttrInput {
3417 } 3559 }
3418 } 3560 }
3419} 3561}
3562
3420#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3563#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3421pub enum Stmt { 3564pub enum Stmt {
3422 LetStmt(LetStmt), 3565 LetStmt(LetStmt),
@@ -3450,6 +3593,7 @@ impl AstNode for Stmt {
3450 } 3593 }
3451 } 3594 }
3452} 3595}
3596
3453#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3597#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3454pub enum FieldDefList { 3598pub enum FieldDefList {
3455 RecordFieldDefList(RecordFieldDefList), 3599 RecordFieldDefList(RecordFieldDefList),
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index e64b8bce6..f91befaac 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -5,2146 +5,7 @@ use crate::{
5 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
6 SyntaxToken, 6 SyntaxToken,
7}; 7};
8#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8
9pub struct Semi {
10 pub(crate) syntax: SyntaxToken,
11}
12impl std::fmt::Display for Semi {
13 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
14 std::fmt::Display::fmt(&self.syntax, f)
15 }
16}
17impl AstToken for Semi {
18 fn can_cast(kind: SyntaxKind) -> bool { kind == SEMI }
19 fn cast(syntax: SyntaxToken) -> Option<Self> {
20 if Self::can_cast(syntax.kind()) {
21 Some(Self { syntax })
22 } else {
23 None
24 }
25 }
26 fn syntax(&self) -> &SyntaxToken { &self.syntax }
27}
28#[derive(Debug, Clone, PartialEq, Eq, Hash)]
29pub struct Comma {
30 pub(crate) syntax: SyntaxToken,
31}
32impl std::fmt::Display for Comma {
33 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34 std::fmt::Display::fmt(&self.syntax, f)
35 }
36}
37impl AstToken for Comma {
38 fn can_cast(kind: SyntaxKind) -> bool { kind == COMMA }
39 fn cast(syntax: SyntaxToken) -> Option<Self> {
40 if Self::can_cast(syntax.kind()) {
41 Some(Self { syntax })
42 } else {
43 None
44 }
45 }
46 fn syntax(&self) -> &SyntaxToken { &self.syntax }
47}
48#[derive(Debug, Clone, PartialEq, Eq, Hash)]
49pub struct LParen {
50 pub(crate) syntax: SyntaxToken,
51}
52impl std::fmt::Display for LParen {
53 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
54 std::fmt::Display::fmt(&self.syntax, f)
55 }
56}
57impl AstToken for LParen {
58 fn can_cast(kind: SyntaxKind) -> bool { kind == L_PAREN }
59 fn cast(syntax: SyntaxToken) -> Option<Self> {
60 if Self::can_cast(syntax.kind()) {
61 Some(Self { syntax })
62 } else {
63 None
64 }
65 }
66 fn syntax(&self) -> &SyntaxToken { &self.syntax }
67}
68#[derive(Debug, Clone, PartialEq, Eq, Hash)]
69pub struct RParen {
70 pub(crate) syntax: SyntaxToken,
71}
72impl std::fmt::Display for RParen {
73 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
74 std::fmt::Display::fmt(&self.syntax, f)
75 }
76}
77impl AstToken for RParen {
78 fn can_cast(kind: SyntaxKind) -> bool { kind == R_PAREN }
79 fn cast(syntax: SyntaxToken) -> Option<Self> {
80 if Self::can_cast(syntax.kind()) {
81 Some(Self { syntax })
82 } else {
83 None
84 }
85 }
86 fn syntax(&self) -> &SyntaxToken { &self.syntax }
87}
88#[derive(Debug, Clone, PartialEq, Eq, Hash)]
89pub struct LCurly {
90 pub(crate) syntax: SyntaxToken,
91}
92impl std::fmt::Display for LCurly {
93 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
94 std::fmt::Display::fmt(&self.syntax, f)
95 }
96}
97impl AstToken for LCurly {
98 fn can_cast(kind: SyntaxKind) -> bool { kind == L_CURLY }
99 fn cast(syntax: SyntaxToken) -> Option<Self> {
100 if Self::can_cast(syntax.kind()) {
101 Some(Self { syntax })
102 } else {
103 None
104 }
105 }
106 fn syntax(&self) -> &SyntaxToken { &self.syntax }
107}
108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
109pub struct RCurly {
110 pub(crate) syntax: SyntaxToken,
111}
112impl std::fmt::Display for RCurly {
113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
114 std::fmt::Display::fmt(&self.syntax, f)
115 }
116}
117impl AstToken for RCurly {
118 fn can_cast(kind: SyntaxKind) -> bool { kind == R_CURLY }
119 fn cast(syntax: SyntaxToken) -> Option<Self> {
120 if Self::can_cast(syntax.kind()) {
121 Some(Self { syntax })
122 } else {
123 None
124 }
125 }
126 fn syntax(&self) -> &SyntaxToken { &self.syntax }
127}
128#[derive(Debug, Clone, PartialEq, Eq, Hash)]
129pub struct LBrack {
130 pub(crate) syntax: SyntaxToken,
131}
132impl std::fmt::Display for LBrack {
133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
134 std::fmt::Display::fmt(&self.syntax, f)
135 }
136}
137impl AstToken for LBrack {
138 fn can_cast(kind: SyntaxKind) -> bool { kind == L_BRACK }
139 fn cast(syntax: SyntaxToken) -> Option<Self> {
140 if Self::can_cast(syntax.kind()) {
141 Some(Self { syntax })
142 } else {
143 None
144 }
145 }
146 fn syntax(&self) -> &SyntaxToken { &self.syntax }
147}
148#[derive(Debug, Clone, PartialEq, Eq, Hash)]
149pub struct RBrack {
150 pub(crate) syntax: SyntaxToken,
151}
152impl std::fmt::Display for RBrack {
153 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
154 std::fmt::Display::fmt(&self.syntax, f)
155 }
156}
157impl AstToken for RBrack {
158 fn can_cast(kind: SyntaxKind) -> bool { kind == R_BRACK }
159 fn cast(syntax: SyntaxToken) -> Option<Self> {
160 if Self::can_cast(syntax.kind()) {
161 Some(Self { syntax })
162 } else {
163 None
164 }
165 }
166 fn syntax(&self) -> &SyntaxToken { &self.syntax }
167}
168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
169pub struct LAngle {
170 pub(crate) syntax: SyntaxToken,
171}
172impl std::fmt::Display for LAngle {
173 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
174 std::fmt::Display::fmt(&self.syntax, f)
175 }
176}
177impl AstToken for LAngle {
178 fn can_cast(kind: SyntaxKind) -> bool { kind == L_ANGLE }
179 fn cast(syntax: SyntaxToken) -> Option<Self> {
180 if Self::can_cast(syntax.kind()) {
181 Some(Self { syntax })
182 } else {
183 None
184 }
185 }
186 fn syntax(&self) -> &SyntaxToken { &self.syntax }
187}
188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
189pub struct RAngle {
190 pub(crate) syntax: SyntaxToken,
191}
192impl std::fmt::Display for RAngle {
193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
194 std::fmt::Display::fmt(&self.syntax, f)
195 }
196}
197impl AstToken for RAngle {
198 fn can_cast(kind: SyntaxKind) -> bool { kind == R_ANGLE }
199 fn cast(syntax: SyntaxToken) -> Option<Self> {
200 if Self::can_cast(syntax.kind()) {
201 Some(Self { syntax })
202 } else {
203 None
204 }
205 }
206 fn syntax(&self) -> &SyntaxToken { &self.syntax }
207}
208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
209pub struct At {
210 pub(crate) syntax: SyntaxToken,
211}
212impl std::fmt::Display for At {
213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
214 std::fmt::Display::fmt(&self.syntax, f)
215 }
216}
217impl AstToken for At {
218 fn can_cast(kind: SyntaxKind) -> bool { kind == AT }
219 fn cast(syntax: SyntaxToken) -> Option<Self> {
220 if Self::can_cast(syntax.kind()) {
221 Some(Self { syntax })
222 } else {
223 None
224 }
225 }
226 fn syntax(&self) -> &SyntaxToken { &self.syntax }
227}
228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
229pub struct Pound {
230 pub(crate) syntax: SyntaxToken,
231}
232impl std::fmt::Display for Pound {
233 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
234 std::fmt::Display::fmt(&self.syntax, f)
235 }
236}
237impl AstToken for Pound {
238 fn can_cast(kind: SyntaxKind) -> bool { kind == POUND }
239 fn cast(syntax: SyntaxToken) -> Option<Self> {
240 if Self::can_cast(syntax.kind()) {
241 Some(Self { syntax })
242 } else {
243 None
244 }
245 }
246 fn syntax(&self) -> &SyntaxToken { &self.syntax }
247}
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct Tilde {
250 pub(crate) syntax: SyntaxToken,
251}
252impl std::fmt::Display for Tilde {
253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
254 std::fmt::Display::fmt(&self.syntax, f)
255 }
256}
257impl AstToken for Tilde {
258 fn can_cast(kind: SyntaxKind) -> bool { kind == TILDE }
259 fn cast(syntax: SyntaxToken) -> Option<Self> {
260 if Self::can_cast(syntax.kind()) {
261 Some(Self { syntax })
262 } else {
263 None
264 }
265 }
266 fn syntax(&self) -> &SyntaxToken { &self.syntax }
267}
268#[derive(Debug, Clone, PartialEq, Eq, Hash)]
269pub struct Question {
270 pub(crate) syntax: SyntaxToken,
271}
272impl std::fmt::Display for Question {
273 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
274 std::fmt::Display::fmt(&self.syntax, f)
275 }
276}
277impl AstToken for Question {
278 fn can_cast(kind: SyntaxKind) -> bool { kind == QUESTION }
279 fn cast(syntax: SyntaxToken) -> Option<Self> {
280 if Self::can_cast(syntax.kind()) {
281 Some(Self { syntax })
282 } else {
283 None
284 }
285 }
286 fn syntax(&self) -> &SyntaxToken { &self.syntax }
287}
288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
289pub struct Dollar {
290 pub(crate) syntax: SyntaxToken,
291}
292impl std::fmt::Display for Dollar {
293 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
294 std::fmt::Display::fmt(&self.syntax, f)
295 }
296}
297impl AstToken for Dollar {
298 fn can_cast(kind: SyntaxKind) -> bool { kind == DOLLAR }
299 fn cast(syntax: SyntaxToken) -> Option<Self> {
300 if Self::can_cast(syntax.kind()) {
301 Some(Self { syntax })
302 } else {
303 None
304 }
305 }
306 fn syntax(&self) -> &SyntaxToken { &self.syntax }
307}
308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
309pub struct Amp {
310 pub(crate) syntax: SyntaxToken,
311}
312impl std::fmt::Display for Amp {
313 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
314 std::fmt::Display::fmt(&self.syntax, f)
315 }
316}
317impl AstToken for Amp {
318 fn can_cast(kind: SyntaxKind) -> bool { kind == AMP }
319 fn cast(syntax: SyntaxToken) -> Option<Self> {
320 if Self::can_cast(syntax.kind()) {
321 Some(Self { syntax })
322 } else {
323 None
324 }
325 }
326 fn syntax(&self) -> &SyntaxToken { &self.syntax }
327}
328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
329pub struct Pipe {
330 pub(crate) syntax: SyntaxToken,
331}
332impl std::fmt::Display for Pipe {
333 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
334 std::fmt::Display::fmt(&self.syntax, f)
335 }
336}
337impl AstToken for Pipe {
338 fn can_cast(kind: SyntaxKind) -> bool { kind == PIPE }
339 fn cast(syntax: SyntaxToken) -> Option<Self> {
340 if Self::can_cast(syntax.kind()) {
341 Some(Self { syntax })
342 } else {
343 None
344 }
345 }
346 fn syntax(&self) -> &SyntaxToken { &self.syntax }
347}
348#[derive(Debug, Clone, PartialEq, Eq, Hash)]
349pub struct Plus {
350 pub(crate) syntax: SyntaxToken,
351}
352impl std::fmt::Display for Plus {
353 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
354 std::fmt::Display::fmt(&self.syntax, f)
355 }
356}
357impl AstToken for Plus {
358 fn can_cast(kind: SyntaxKind) -> bool { kind == PLUS }
359 fn cast(syntax: SyntaxToken) -> Option<Self> {
360 if Self::can_cast(syntax.kind()) {
361 Some(Self { syntax })
362 } else {
363 None
364 }
365 }
366 fn syntax(&self) -> &SyntaxToken { &self.syntax }
367}
368#[derive(Debug, Clone, PartialEq, Eq, Hash)]
369pub struct Star {
370 pub(crate) syntax: SyntaxToken,
371}
372impl std::fmt::Display for Star {
373 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
374 std::fmt::Display::fmt(&self.syntax, f)
375 }
376}
377impl AstToken for Star {
378 fn can_cast(kind: SyntaxKind) -> bool { kind == STAR }
379 fn cast(syntax: SyntaxToken) -> Option<Self> {
380 if Self::can_cast(syntax.kind()) {
381 Some(Self { syntax })
382 } else {
383 None
384 }
385 }
386 fn syntax(&self) -> &SyntaxToken { &self.syntax }
387}
388#[derive(Debug, Clone, PartialEq, Eq, Hash)]
389pub struct Slash {
390 pub(crate) syntax: SyntaxToken,
391}
392impl std::fmt::Display for Slash {
393 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
394 std::fmt::Display::fmt(&self.syntax, f)
395 }
396}
397impl AstToken for Slash {
398 fn can_cast(kind: SyntaxKind) -> bool { kind == SLASH }
399 fn cast(syntax: SyntaxToken) -> Option<Self> {
400 if Self::can_cast(syntax.kind()) {
401 Some(Self { syntax })
402 } else {
403 None
404 }
405 }
406 fn syntax(&self) -> &SyntaxToken { &self.syntax }
407}
408#[derive(Debug, Clone, PartialEq, Eq, Hash)]
409pub struct Caret {
410 pub(crate) syntax: SyntaxToken,
411}
412impl std::fmt::Display for Caret {
413 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
414 std::fmt::Display::fmt(&self.syntax, f)
415 }
416}
417impl AstToken for Caret {
418 fn can_cast(kind: SyntaxKind) -> bool { kind == CARET }
419 fn cast(syntax: SyntaxToken) -> Option<Self> {
420 if Self::can_cast(syntax.kind()) {
421 Some(Self { syntax })
422 } else {
423 None
424 }
425 }
426 fn syntax(&self) -> &SyntaxToken { &self.syntax }
427}
428#[derive(Debug, Clone, PartialEq, Eq, Hash)]
429pub struct Percent {
430 pub(crate) syntax: SyntaxToken,
431}
432impl std::fmt::Display for Percent {
433 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
434 std::fmt::Display::fmt(&self.syntax, f)
435 }
436}
437impl AstToken for Percent {
438 fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENT }
439 fn cast(syntax: SyntaxToken) -> Option<Self> {
440 if Self::can_cast(syntax.kind()) {
441 Some(Self { syntax })
442 } else {
443 None
444 }
445 }
446 fn syntax(&self) -> &SyntaxToken { &self.syntax }
447}
448#[derive(Debug, Clone, PartialEq, Eq, Hash)]
449pub struct Underscore {
450 pub(crate) syntax: SyntaxToken,
451}
452impl std::fmt::Display for Underscore {
453 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
454 std::fmt::Display::fmt(&self.syntax, f)
455 }
456}
457impl AstToken for Underscore {
458 fn can_cast(kind: SyntaxKind) -> bool { kind == UNDERSCORE }
459 fn cast(syntax: SyntaxToken) -> Option<Self> {
460 if Self::can_cast(syntax.kind()) {
461 Some(Self { syntax })
462 } else {
463 None
464 }
465 }
466 fn syntax(&self) -> &SyntaxToken { &self.syntax }
467}
468#[derive(Debug, Clone, PartialEq, Eq, Hash)]
469pub struct Dot {
470 pub(crate) syntax: SyntaxToken,
471}
472impl std::fmt::Display for Dot {
473 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
474 std::fmt::Display::fmt(&self.syntax, f)
475 }
476}
477impl AstToken for Dot {
478 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT }
479 fn cast(syntax: SyntaxToken) -> Option<Self> {
480 if Self::can_cast(syntax.kind()) {
481 Some(Self { syntax })
482 } else {
483 None
484 }
485 }
486 fn syntax(&self) -> &SyntaxToken { &self.syntax }
487}
488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
489pub struct Dotdot {
490 pub(crate) syntax: SyntaxToken,
491}
492impl std::fmt::Display for Dotdot {
493 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
494 std::fmt::Display::fmt(&self.syntax, f)
495 }
496}
497impl AstToken for Dotdot {
498 fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOT }
499 fn cast(syntax: SyntaxToken) -> Option<Self> {
500 if Self::can_cast(syntax.kind()) {
501 Some(Self { syntax })
502 } else {
503 None
504 }
505 }
506 fn syntax(&self) -> &SyntaxToken { &self.syntax }
507}
508#[derive(Debug, Clone, PartialEq, Eq, Hash)]
509pub struct Dotdotdot {
510 pub(crate) syntax: SyntaxToken,
511}
512impl std::fmt::Display for Dotdotdot {
513 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
514 std::fmt::Display::fmt(&self.syntax, f)
515 }
516}
517impl AstToken for Dotdotdot {
518 fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTDOT }
519 fn cast(syntax: SyntaxToken) -> Option<Self> {
520 if Self::can_cast(syntax.kind()) {
521 Some(Self { syntax })
522 } else {
523 None
524 }
525 }
526 fn syntax(&self) -> &SyntaxToken { &self.syntax }
527}
528#[derive(Debug, Clone, PartialEq, Eq, Hash)]
529pub struct Dotdoteq {
530 pub(crate) syntax: SyntaxToken,
531}
532impl std::fmt::Display for Dotdoteq {
533 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
534 std::fmt::Display::fmt(&self.syntax, f)
535 }
536}
537impl AstToken for Dotdoteq {
538 fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTEQ }
539 fn cast(syntax: SyntaxToken) -> Option<Self> {
540 if Self::can_cast(syntax.kind()) {
541 Some(Self { syntax })
542 } else {
543 None
544 }
545 }
546 fn syntax(&self) -> &SyntaxToken { &self.syntax }
547}
548#[derive(Debug, Clone, PartialEq, Eq, Hash)]
549pub struct Colon {
550 pub(crate) syntax: SyntaxToken,
551}
552impl std::fmt::Display for Colon {
553 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
554 std::fmt::Display::fmt(&self.syntax, f)
555 }
556}
557impl AstToken for Colon {
558 fn can_cast(kind: SyntaxKind) -> bool { kind == COLON }
559 fn cast(syntax: SyntaxToken) -> Option<Self> {
560 if Self::can_cast(syntax.kind()) {
561 Some(Self { syntax })
562 } else {
563 None
564 }
565 }
566 fn syntax(&self) -> &SyntaxToken { &self.syntax }
567}
568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
569pub struct Coloncolon {
570 pub(crate) syntax: SyntaxToken,
571}
572impl std::fmt::Display for Coloncolon {
573 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
574 std::fmt::Display::fmt(&self.syntax, f)
575 }
576}
577impl AstToken for Coloncolon {
578 fn can_cast(kind: SyntaxKind) -> bool { kind == COLONCOLON }
579 fn cast(syntax: SyntaxToken) -> Option<Self> {
580 if Self::can_cast(syntax.kind()) {
581 Some(Self { syntax })
582 } else {
583 None
584 }
585 }
586 fn syntax(&self) -> &SyntaxToken { &self.syntax }
587}
588#[derive(Debug, Clone, PartialEq, Eq, Hash)]
589pub struct Eq {
590 pub(crate) syntax: SyntaxToken,
591}
592impl std::fmt::Display for Eq {
593 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
594 std::fmt::Display::fmt(&self.syntax, f)
595 }
596}
597impl AstToken for Eq {
598 fn can_cast(kind: SyntaxKind) -> bool { kind == EQ }
599 fn cast(syntax: SyntaxToken) -> Option<Self> {
600 if Self::can_cast(syntax.kind()) {
601 Some(Self { syntax })
602 } else {
603 None
604 }
605 }
606 fn syntax(&self) -> &SyntaxToken { &self.syntax }
607}
608#[derive(Debug, Clone, PartialEq, Eq, Hash)]
609pub struct Eqeq {
610 pub(crate) syntax: SyntaxToken,
611}
612impl std::fmt::Display for Eqeq {
613 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
614 std::fmt::Display::fmt(&self.syntax, f)
615 }
616}
617impl AstToken for Eqeq {
618 fn can_cast(kind: SyntaxKind) -> bool { kind == EQEQ }
619 fn cast(syntax: SyntaxToken) -> Option<Self> {
620 if Self::can_cast(syntax.kind()) {
621 Some(Self { syntax })
622 } else {
623 None
624 }
625 }
626 fn syntax(&self) -> &SyntaxToken { &self.syntax }
627}
628#[derive(Debug, Clone, PartialEq, Eq, Hash)]
629pub struct FatArrow {
630 pub(crate) syntax: SyntaxToken,
631}
632impl std::fmt::Display for FatArrow {
633 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
634 std::fmt::Display::fmt(&self.syntax, f)
635 }
636}
637impl AstToken for FatArrow {
638 fn can_cast(kind: SyntaxKind) -> bool { kind == FAT_ARROW }
639 fn cast(syntax: SyntaxToken) -> Option<Self> {
640 if Self::can_cast(syntax.kind()) {
641 Some(Self { syntax })
642 } else {
643 None
644 }
645 }
646 fn syntax(&self) -> &SyntaxToken { &self.syntax }
647}
648#[derive(Debug, Clone, PartialEq, Eq, Hash)]
649pub struct Excl {
650 pub(crate) syntax: SyntaxToken,
651}
652impl std::fmt::Display for Excl {
653 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
654 std::fmt::Display::fmt(&self.syntax, f)
655 }
656}
657impl AstToken for Excl {
658 fn can_cast(kind: SyntaxKind) -> bool { kind == EXCL }
659 fn cast(syntax: SyntaxToken) -> Option<Self> {
660 if Self::can_cast(syntax.kind()) {
661 Some(Self { syntax })
662 } else {
663 None
664 }
665 }
666 fn syntax(&self) -> &SyntaxToken { &self.syntax }
667}
668#[derive(Debug, Clone, PartialEq, Eq, Hash)]
669pub struct Neq {
670 pub(crate) syntax: SyntaxToken,
671}
672impl std::fmt::Display for Neq {
673 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
674 std::fmt::Display::fmt(&self.syntax, f)
675 }
676}
677impl AstToken for Neq {
678 fn can_cast(kind: SyntaxKind) -> bool { kind == NEQ }
679 fn cast(syntax: SyntaxToken) -> Option<Self> {
680 if Self::can_cast(syntax.kind()) {
681 Some(Self { syntax })
682 } else {
683 None
684 }
685 }
686 fn syntax(&self) -> &SyntaxToken { &self.syntax }
687}
688#[derive(Debug, Clone, PartialEq, Eq, Hash)]
689pub struct Minus {
690 pub(crate) syntax: SyntaxToken,
691}
692impl std::fmt::Display for Minus {
693 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
694 std::fmt::Display::fmt(&self.syntax, f)
695 }
696}
697impl AstToken for Minus {
698 fn can_cast(kind: SyntaxKind) -> bool { kind == MINUS }
699 fn cast(syntax: SyntaxToken) -> Option<Self> {
700 if Self::can_cast(syntax.kind()) {
701 Some(Self { syntax })
702 } else {
703 None
704 }
705 }
706 fn syntax(&self) -> &SyntaxToken { &self.syntax }
707}
708#[derive(Debug, Clone, PartialEq, Eq, Hash)]
709pub struct ThinArrow {
710 pub(crate) syntax: SyntaxToken,
711}
712impl std::fmt::Display for ThinArrow {
713 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
714 std::fmt::Display::fmt(&self.syntax, f)
715 }
716}
717impl AstToken for ThinArrow {
718 fn can_cast(kind: SyntaxKind) -> bool { kind == THIN_ARROW }
719 fn cast(syntax: SyntaxToken) -> Option<Self> {
720 if Self::can_cast(syntax.kind()) {
721 Some(Self { syntax })
722 } else {
723 None
724 }
725 }
726 fn syntax(&self) -> &SyntaxToken { &self.syntax }
727}
728#[derive(Debug, Clone, PartialEq, Eq, Hash)]
729pub struct Lteq {
730 pub(crate) syntax: SyntaxToken,
731}
732impl std::fmt::Display for Lteq {
733 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
734 std::fmt::Display::fmt(&self.syntax, f)
735 }
736}
737impl AstToken for Lteq {
738 fn can_cast(kind: SyntaxKind) -> bool { kind == LTEQ }
739 fn cast(syntax: SyntaxToken) -> Option<Self> {
740 if Self::can_cast(syntax.kind()) {
741 Some(Self { syntax })
742 } else {
743 None
744 }
745 }
746 fn syntax(&self) -> &SyntaxToken { &self.syntax }
747}
748#[derive(Debug, Clone, PartialEq, Eq, Hash)]
749pub struct Gteq {
750 pub(crate) syntax: SyntaxToken,
751}
752impl std::fmt::Display for Gteq {
753 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
754 std::fmt::Display::fmt(&self.syntax, f)
755 }
756}
757impl AstToken for Gteq {
758 fn can_cast(kind: SyntaxKind) -> bool { kind == GTEQ }
759 fn cast(syntax: SyntaxToken) -> Option<Self> {
760 if Self::can_cast(syntax.kind()) {
761 Some(Self { syntax })
762 } else {
763 None
764 }
765 }
766 fn syntax(&self) -> &SyntaxToken { &self.syntax }
767}
768#[derive(Debug, Clone, PartialEq, Eq, Hash)]
769pub struct Pluseq {
770 pub(crate) syntax: SyntaxToken,
771}
772impl std::fmt::Display for Pluseq {
773 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
774 std::fmt::Display::fmt(&self.syntax, f)
775 }
776}
777impl AstToken for Pluseq {
778 fn can_cast(kind: SyntaxKind) -> bool { kind == PLUSEQ }
779 fn cast(syntax: SyntaxToken) -> Option<Self> {
780 if Self::can_cast(syntax.kind()) {
781 Some(Self { syntax })
782 } else {
783 None
784 }
785 }
786 fn syntax(&self) -> &SyntaxToken { &self.syntax }
787}
788#[derive(Debug, Clone, PartialEq, Eq, Hash)]
789pub struct Minuseq {
790 pub(crate) syntax: SyntaxToken,
791}
792impl std::fmt::Display for Minuseq {
793 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
794 std::fmt::Display::fmt(&self.syntax, f)
795 }
796}
797impl AstToken for Minuseq {
798 fn can_cast(kind: SyntaxKind) -> bool { kind == MINUSEQ }
799 fn cast(syntax: SyntaxToken) -> Option<Self> {
800 if Self::can_cast(syntax.kind()) {
801 Some(Self { syntax })
802 } else {
803 None
804 }
805 }
806 fn syntax(&self) -> &SyntaxToken { &self.syntax }
807}
808#[derive(Debug, Clone, PartialEq, Eq, Hash)]
809pub struct Pipeeq {
810 pub(crate) syntax: SyntaxToken,
811}
812impl std::fmt::Display for Pipeeq {
813 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
814 std::fmt::Display::fmt(&self.syntax, f)
815 }
816}
817impl AstToken for Pipeeq {
818 fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEEQ }
819 fn cast(syntax: SyntaxToken) -> Option<Self> {
820 if Self::can_cast(syntax.kind()) {
821 Some(Self { syntax })
822 } else {
823 None
824 }
825 }
826 fn syntax(&self) -> &SyntaxToken { &self.syntax }
827}
828#[derive(Debug, Clone, PartialEq, Eq, Hash)]
829pub struct Ampeq {
830 pub(crate) syntax: SyntaxToken,
831}
832impl std::fmt::Display for Ampeq {
833 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
834 std::fmt::Display::fmt(&self.syntax, f)
835 }
836}
837impl AstToken for Ampeq {
838 fn can_cast(kind: SyntaxKind) -> bool { kind == AMPEQ }
839 fn cast(syntax: SyntaxToken) -> Option<Self> {
840 if Self::can_cast(syntax.kind()) {
841 Some(Self { syntax })
842 } else {
843 None
844 }
845 }
846 fn syntax(&self) -> &SyntaxToken { &self.syntax }
847}
848#[derive(Debug, Clone, PartialEq, Eq, Hash)]
849pub struct Careteq {
850 pub(crate) syntax: SyntaxToken,
851}
852impl std::fmt::Display for Careteq {
853 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
854 std::fmt::Display::fmt(&self.syntax, f)
855 }
856}
857impl AstToken for Careteq {
858 fn can_cast(kind: SyntaxKind) -> bool { kind == CARETEQ }
859 fn cast(syntax: SyntaxToken) -> Option<Self> {
860 if Self::can_cast(syntax.kind()) {
861 Some(Self { syntax })
862 } else {
863 None
864 }
865 }
866 fn syntax(&self) -> &SyntaxToken { &self.syntax }
867}
868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
869pub struct Slasheq {
870 pub(crate) syntax: SyntaxToken,
871}
872impl std::fmt::Display for Slasheq {
873 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
874 std::fmt::Display::fmt(&self.syntax, f)
875 }
876}
877impl AstToken for Slasheq {
878 fn can_cast(kind: SyntaxKind) -> bool { kind == SLASHEQ }
879 fn cast(syntax: SyntaxToken) -> Option<Self> {
880 if Self::can_cast(syntax.kind()) {
881 Some(Self { syntax })
882 } else {
883 None
884 }
885 }
886 fn syntax(&self) -> &SyntaxToken { &self.syntax }
887}
888#[derive(Debug, Clone, PartialEq, Eq, Hash)]
889pub struct Stareq {
890 pub(crate) syntax: SyntaxToken,
891}
892impl std::fmt::Display for Stareq {
893 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
894 std::fmt::Display::fmt(&self.syntax, f)
895 }
896}
897impl AstToken for Stareq {
898 fn can_cast(kind: SyntaxKind) -> bool { kind == STAREQ }
899 fn cast(syntax: SyntaxToken) -> Option<Self> {
900 if Self::can_cast(syntax.kind()) {
901 Some(Self { syntax })
902 } else {
903 None
904 }
905 }
906 fn syntax(&self) -> &SyntaxToken { &self.syntax }
907}
908#[derive(Debug, Clone, PartialEq, Eq, Hash)]
909pub struct Percenteq {
910 pub(crate) syntax: SyntaxToken,
911}
912impl std::fmt::Display for Percenteq {
913 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
914 std::fmt::Display::fmt(&self.syntax, f)
915 }
916}
917impl AstToken for Percenteq {
918 fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENTEQ }
919 fn cast(syntax: SyntaxToken) -> Option<Self> {
920 if Self::can_cast(syntax.kind()) {
921 Some(Self { syntax })
922 } else {
923 None
924 }
925 }
926 fn syntax(&self) -> &SyntaxToken { &self.syntax }
927}
928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929pub struct Ampamp {
930 pub(crate) syntax: SyntaxToken,
931}
932impl std::fmt::Display for Ampamp {
933 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
934 std::fmt::Display::fmt(&self.syntax, f)
935 }
936}
937impl AstToken for Ampamp {
938 fn can_cast(kind: SyntaxKind) -> bool { kind == AMPAMP }
939 fn cast(syntax: SyntaxToken) -> Option<Self> {
940 if Self::can_cast(syntax.kind()) {
941 Some(Self { syntax })
942 } else {
943 None
944 }
945 }
946 fn syntax(&self) -> &SyntaxToken { &self.syntax }
947}
948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
949pub struct Pipepipe {
950 pub(crate) syntax: SyntaxToken,
951}
952impl std::fmt::Display for Pipepipe {
953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
954 std::fmt::Display::fmt(&self.syntax, f)
955 }
956}
957impl AstToken for Pipepipe {
958 fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEPIPE }
959 fn cast(syntax: SyntaxToken) -> Option<Self> {
960 if Self::can_cast(syntax.kind()) {
961 Some(Self { syntax })
962 } else {
963 None
964 }
965 }
966 fn syntax(&self) -> &SyntaxToken { &self.syntax }
967}
968#[derive(Debug, Clone, PartialEq, Eq, Hash)]
969pub struct Shl {
970 pub(crate) syntax: SyntaxToken,
971}
972impl std::fmt::Display for Shl {
973 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
974 std::fmt::Display::fmt(&self.syntax, f)
975 }
976}
977impl AstToken for Shl {
978 fn can_cast(kind: SyntaxKind) -> bool { kind == SHL }
979 fn cast(syntax: SyntaxToken) -> Option<Self> {
980 if Self::can_cast(syntax.kind()) {
981 Some(Self { syntax })
982 } else {
983 None
984 }
985 }
986 fn syntax(&self) -> &SyntaxToken { &self.syntax }
987}
988#[derive(Debug, Clone, PartialEq, Eq, Hash)]
989pub struct Shr {
990 pub(crate) syntax: SyntaxToken,
991}
992impl std::fmt::Display for Shr {
993 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
994 std::fmt::Display::fmt(&self.syntax, f)
995 }
996}
997impl AstToken for Shr {
998 fn can_cast(kind: SyntaxKind) -> bool { kind == SHR }
999 fn cast(syntax: SyntaxToken) -> Option<Self> {
1000 if Self::can_cast(syntax.kind()) {
1001 Some(Self { syntax })
1002 } else {
1003 None
1004 }
1005 }
1006 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1007}
1008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1009pub struct Shleq {
1010 pub(crate) syntax: SyntaxToken,
1011}
1012impl std::fmt::Display for Shleq {
1013 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1014 std::fmt::Display::fmt(&self.syntax, f)
1015 }
1016}
1017impl AstToken for Shleq {
1018 fn can_cast(kind: SyntaxKind) -> bool { kind == SHLEQ }
1019 fn cast(syntax: SyntaxToken) -> Option<Self> {
1020 if Self::can_cast(syntax.kind()) {
1021 Some(Self { syntax })
1022 } else {
1023 None
1024 }
1025 }
1026 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1027}
1028#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1029pub struct Shreq {
1030 pub(crate) syntax: SyntaxToken,
1031}
1032impl std::fmt::Display for Shreq {
1033 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1034 std::fmt::Display::fmt(&self.syntax, f)
1035 }
1036}
1037impl AstToken for Shreq {
1038 fn can_cast(kind: SyntaxKind) -> bool { kind == SHREQ }
1039 fn cast(syntax: SyntaxToken) -> Option<Self> {
1040 if Self::can_cast(syntax.kind()) {
1041 Some(Self { syntax })
1042 } else {
1043 None
1044 }
1045 }
1046 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1047}
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 {
1950 pub(crate) syntax: SyntaxToken,
1951}
1952impl std::fmt::Display for IntNumber {
1953 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1954 std::fmt::Display::fmt(&self.syntax, f)
1955 }
1956}
1957impl AstToken for IntNumber {
1958 fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER }
1959 fn cast(syntax: SyntaxToken) -> Option<Self> {
1960 if Self::can_cast(syntax.kind()) {
1961 Some(Self { syntax })
1962 } else {
1963 None
1964 }
1965 }
1966 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1967}
1968#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1969pub struct FloatNumber {
1970 pub(crate) syntax: SyntaxToken,
1971}
1972impl std::fmt::Display for FloatNumber {
1973 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1974 std::fmt::Display::fmt(&self.syntax, f)
1975 }
1976}
1977impl AstToken for FloatNumber {
1978 fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER }
1979 fn cast(syntax: SyntaxToken) -> Option<Self> {
1980 if Self::can_cast(syntax.kind()) {
1981 Some(Self { syntax })
1982 } else {
1983 None
1984 }
1985 }
1986 fn syntax(&self) -> &SyntaxToken { &self.syntax }
1987}
1988#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1989pub struct Char {
1990 pub(crate) syntax: SyntaxToken,
1991}
1992impl std::fmt::Display for Char {
1993 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1994 std::fmt::Display::fmt(&self.syntax, f)
1995 }
1996}
1997impl AstToken for Char {
1998 fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR }
1999 fn cast(syntax: SyntaxToken) -> Option<Self> {
2000 if Self::can_cast(syntax.kind()) {
2001 Some(Self { syntax })
2002 } else {
2003 None
2004 }
2005 }
2006 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2007}
2008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2009pub struct Byte {
2010 pub(crate) syntax: SyntaxToken,
2011}
2012impl std::fmt::Display for Byte {
2013 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2014 std::fmt::Display::fmt(&self.syntax, f)
2015 }
2016}
2017impl AstToken for Byte {
2018 fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE }
2019 fn cast(syntax: SyntaxToken) -> Option<Self> {
2020 if Self::can_cast(syntax.kind()) {
2021 Some(Self { syntax })
2022 } else {
2023 None
2024 }
2025 }
2026 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2027}
2028#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2029pub struct String {
2030 pub(crate) syntax: SyntaxToken,
2031}
2032impl std::fmt::Display for String {
2033 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2034 std::fmt::Display::fmt(&self.syntax, f)
2035 }
2036}
2037impl AstToken for String {
2038 fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
2039 fn cast(syntax: SyntaxToken) -> Option<Self> {
2040 if Self::can_cast(syntax.kind()) {
2041 Some(Self { syntax })
2042 } else {
2043 None
2044 }
2045 }
2046 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2047}
2048#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2049pub struct RawString {
2050 pub(crate) syntax: SyntaxToken,
2051}
2052impl std::fmt::Display for RawString {
2053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2054 std::fmt::Display::fmt(&self.syntax, f)
2055 }
2056}
2057impl AstToken for RawString {
2058 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING }
2059 fn cast(syntax: SyntaxToken) -> Option<Self> {
2060 if Self::can_cast(syntax.kind()) {
2061 Some(Self { syntax })
2062 } else {
2063 None
2064 }
2065 }
2066 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2067}
2068#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2069pub struct ByteString {
2070 pub(crate) syntax: SyntaxToken,
2071}
2072impl std::fmt::Display for ByteString {
2073 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2074 std::fmt::Display::fmt(&self.syntax, f)
2075 }
2076}
2077impl AstToken for ByteString {
2078 fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING }
2079 fn cast(syntax: SyntaxToken) -> Option<Self> {
2080 if Self::can_cast(syntax.kind()) {
2081 Some(Self { syntax })
2082 } else {
2083 None
2084 }
2085 }
2086 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2087}
2088#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2089pub struct RawByteString {
2090 pub(crate) syntax: SyntaxToken,
2091}
2092impl std::fmt::Display for RawByteString {
2093 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2094 std::fmt::Display::fmt(&self.syntax, f)
2095 }
2096}
2097impl AstToken for RawByteString {
2098 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_BYTE_STRING }
2099 fn cast(syntax: SyntaxToken) -> Option<Self> {
2100 if Self::can_cast(syntax.kind()) {
2101 Some(Self { syntax })
2102 } else {
2103 None
2104 }
2105 }
2106 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2107}
2108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2109pub struct Error {
2110 pub(crate) syntax: SyntaxToken,
2111}
2112impl std::fmt::Display for Error {
2113 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2114 std::fmt::Display::fmt(&self.syntax, f)
2115 }
2116}
2117impl AstToken for Error {
2118 fn can_cast(kind: SyntaxKind) -> bool { kind == ERROR }
2119 fn cast(syntax: SyntaxToken) -> Option<Self> {
2120 if Self::can_cast(syntax.kind()) {
2121 Some(Self { syntax })
2122 } else {
2123 None
2124 }
2125 }
2126 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2127}
2128#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2129pub struct Ident {
2130 pub(crate) syntax: SyntaxToken,
2131}
2132impl std::fmt::Display for Ident {
2133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2134 std::fmt::Display::fmt(&self.syntax, f)
2135 }
2136}
2137impl AstToken for Ident {
2138 fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT }
2139 fn cast(syntax: SyntaxToken) -> Option<Self> {
2140 if Self::can_cast(syntax.kind()) {
2141 Some(Self { syntax })
2142 } else {
2143 None
2144 }
2145 }
2146 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2147}
2148#[derive(Debug, Clone, PartialEq, Eq, Hash)] 9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2149pub struct Whitespace { 10pub struct Whitespace {
2150 pub(crate) syntax: SyntaxToken, 11 pub(crate) syntax: SyntaxToken,
@@ -2165,26 +26,7 @@ impl AstToken for Whitespace {
2165 } 26 }
2166 fn syntax(&self) -> &SyntaxToken { &self.syntax } 27 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2167} 28}
2168#[derive(Debug, Clone, PartialEq, Eq, Hash)] 29
2169pub struct Lifetime {
2170 pub(crate) syntax: SyntaxToken,
2171}
2172impl std::fmt::Display for Lifetime {
2173 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2174 std::fmt::Display::fmt(&self.syntax, f)
2175 }
2176}
2177impl AstToken for Lifetime {
2178 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME }
2179 fn cast(syntax: SyntaxToken) -> Option<Self> {
2180 if Self::can_cast(syntax.kind()) {
2181 Some(Self { syntax })
2182 } else {
2183 None
2184 }
2185 }
2186 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2187}
2188#[derive(Debug, Clone, PartialEq, Eq, Hash)] 30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2189pub struct Comment { 31pub struct Comment {
2190 pub(crate) syntax: SyntaxToken, 32 pub(crate) syntax: SyntaxToken,
@@ -2205,37 +47,18 @@ impl AstToken for Comment {
2205 } 47 }
2206 fn syntax(&self) -> &SyntaxToken { &self.syntax } 48 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2207} 49}
50
2208#[derive(Debug, Clone, PartialEq, Eq, Hash)] 51#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2209pub struct Shebang { 52pub struct String {
2210 pub(crate) syntax: SyntaxToken,
2211}
2212impl std::fmt::Display for Shebang {
2213 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2214 std::fmt::Display::fmt(&self.syntax, f)
2215 }
2216}
2217impl AstToken for Shebang {
2218 fn can_cast(kind: SyntaxKind) -> bool { kind == SHEBANG }
2219 fn cast(syntax: SyntaxToken) -> Option<Self> {
2220 if Self::can_cast(syntax.kind()) {
2221 Some(Self { syntax })
2222 } else {
2223 None
2224 }
2225 }
2226 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2227}
2228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2229pub struct LDollar {
2230 pub(crate) syntax: SyntaxToken, 53 pub(crate) syntax: SyntaxToken,
2231} 54}
2232impl std::fmt::Display for LDollar { 55impl std::fmt::Display for String {
2233 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 56 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2234 std::fmt::Display::fmt(&self.syntax, f) 57 std::fmt::Display::fmt(&self.syntax, f)
2235 } 58 }
2236} 59}
2237impl AstToken for LDollar { 60impl AstToken for String {
2238 fn can_cast(kind: SyntaxKind) -> bool { kind == L_DOLLAR } 61 fn can_cast(kind: SyntaxKind) -> bool { kind == STRING }
2239 fn cast(syntax: SyntaxToken) -> Option<Self> { 62 fn cast(syntax: SyntaxToken) -> Option<Self> {
2240 if Self::can_cast(syntax.kind()) { 63 if Self::can_cast(syntax.kind()) {
2241 Some(Self { syntax }) 64 Some(Self { syntax })
@@ -2245,17 +68,18 @@ impl AstToken for LDollar {
2245 } 68 }
2246 fn syntax(&self) -> &SyntaxToken { &self.syntax } 69 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2247} 70}
71
2248#[derive(Debug, Clone, PartialEq, Eq, Hash)] 72#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2249pub struct RDollar { 73pub struct RawString {
2250 pub(crate) syntax: SyntaxToken, 74 pub(crate) syntax: SyntaxToken,
2251} 75}
2252impl std::fmt::Display for RDollar { 76impl std::fmt::Display for RawString {
2253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 77 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2254 std::fmt::Display::fmt(&self.syntax, f) 78 std::fmt::Display::fmt(&self.syntax, f)
2255 } 79 }
2256} 80}
2257impl AstToken for RDollar { 81impl AstToken for RawString {
2258 fn can_cast(kind: SyntaxKind) -> bool { kind == R_DOLLAR } 82 fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING }
2259 fn cast(syntax: SyntaxToken) -> Option<Self> { 83 fn cast(syntax: SyntaxToken) -> Option<Self> {
2260 if Self::can_cast(syntax.kind()) { 84 if Self::can_cast(syntax.kind()) {
2261 Some(Self { syntax }) 85 Some(Self { syntax })
@@ -2265,544 +89,3 @@ impl AstToken for RDollar {
2265 } 89 }
2266 fn syntax(&self) -> &SyntaxToken { &self.syntax } 90 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2267} 91}
2268#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2269pub enum LeftDelimiter {
2270 LParen(LParen),
2271 LBrack(LBrack),
2272 LCurly(LCurly),
2273}
2274impl From<LParen> for LeftDelimiter {
2275 fn from(node: LParen) -> LeftDelimiter { LeftDelimiter::LParen(node) }
2276}
2277impl From<LBrack> for LeftDelimiter {
2278 fn from(node: LBrack) -> LeftDelimiter { LeftDelimiter::LBrack(node) }
2279}
2280impl From<LCurly> for LeftDelimiter {
2281 fn from(node: LCurly) -> LeftDelimiter { LeftDelimiter::LCurly(node) }
2282}
2283impl std::fmt::Display for LeftDelimiter {
2284 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2285 std::fmt::Display::fmt(self.syntax(), f)
2286 }
2287}
2288impl AstToken for LeftDelimiter {
2289 fn can_cast(kind: SyntaxKind) -> bool {
2290 match kind {
2291 L_PAREN | L_BRACK | L_CURLY => true,
2292 _ => false,
2293 }
2294 }
2295 fn cast(syntax: SyntaxToken) -> Option<Self> {
2296 let res = match syntax.kind() {
2297 L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
2298 L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
2299 L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
2300 _ => return None,
2301 };
2302 Some(res)
2303 }
2304 fn syntax(&self) -> &SyntaxToken {
2305 match self {
2306 LeftDelimiter::LParen(it) => &it.syntax,
2307 LeftDelimiter::LBrack(it) => &it.syntax,
2308 LeftDelimiter::LCurly(it) => &it.syntax,
2309 }
2310 }
2311}
2312#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2313pub enum RightDelimiter {
2314 RParen(RParen),
2315 RBrack(RBrack),
2316 RCurly(RCurly),
2317}
2318impl From<RParen> for RightDelimiter {
2319 fn from(node: RParen) -> RightDelimiter { RightDelimiter::RParen(node) }
2320}
2321impl From<RBrack> for RightDelimiter {
2322 fn from(node: RBrack) -> RightDelimiter { RightDelimiter::RBrack(node) }
2323}
2324impl From<RCurly> for RightDelimiter {
2325 fn from(node: RCurly) -> RightDelimiter { RightDelimiter::RCurly(node) }
2326}
2327impl std::fmt::Display for RightDelimiter {
2328 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2329 std::fmt::Display::fmt(self.syntax(), f)
2330 }
2331}
2332impl AstToken for RightDelimiter {
2333 fn can_cast(kind: SyntaxKind) -> bool {
2334 match kind {
2335 R_PAREN | R_BRACK | R_CURLY => true,
2336 _ => false,
2337 }
2338 }
2339 fn cast(syntax: SyntaxToken) -> Option<Self> {
2340 let res = match syntax.kind() {
2341 R_PAREN => RightDelimiter::RParen(RParen { syntax }),
2342 R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
2343 R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
2344 _ => return None,
2345 };
2346 Some(res)
2347 }
2348 fn syntax(&self) -> &SyntaxToken {
2349 match self {
2350 RightDelimiter::RParen(it) => &it.syntax,
2351 RightDelimiter::RBrack(it) => &it.syntax,
2352 RightDelimiter::RCurly(it) => &it.syntax,
2353 }
2354 }
2355}
2356#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2357pub enum RangeSeparator {
2358 Dotdot(Dotdot),
2359 Dotdotdot(Dotdotdot),
2360 Dotdoteq(Dotdoteq),
2361}
2362impl From<Dotdot> for RangeSeparator {
2363 fn from(node: Dotdot) -> RangeSeparator { RangeSeparator::Dotdot(node) }
2364}
2365impl From<Dotdotdot> for RangeSeparator {
2366 fn from(node: Dotdotdot) -> RangeSeparator { RangeSeparator::Dotdotdot(node) }
2367}
2368impl From<Dotdoteq> for RangeSeparator {
2369 fn from(node: Dotdoteq) -> RangeSeparator { RangeSeparator::Dotdoteq(node) }
2370}
2371impl std::fmt::Display for RangeSeparator {
2372 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2373 std::fmt::Display::fmt(self.syntax(), f)
2374 }
2375}
2376impl AstToken for RangeSeparator {
2377 fn can_cast(kind: SyntaxKind) -> bool {
2378 match kind {
2379 DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
2380 _ => false,
2381 }
2382 }
2383 fn cast(syntax: SyntaxToken) -> Option<Self> {
2384 let res = match syntax.kind() {
2385 DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
2386 DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
2387 DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
2388 _ => return None,
2389 };
2390 Some(res)
2391 }
2392 fn syntax(&self) -> &SyntaxToken {
2393 match self {
2394 RangeSeparator::Dotdot(it) => &it.syntax,
2395 RangeSeparator::Dotdotdot(it) => &it.syntax,
2396 RangeSeparator::Dotdoteq(it) => &it.syntax,
2397 }
2398 }
2399}
2400#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2401pub enum BinOp {
2402 Pipepipe(Pipepipe),
2403 Ampamp(Ampamp),
2404 Eqeq(Eqeq),
2405 Neq(Neq),
2406 Lteq(Lteq),
2407 Gteq(Gteq),
2408 LAngle(LAngle),
2409 RAngle(RAngle),
2410 Plus(Plus),
2411 Star(Star),
2412 Minus(Minus),
2413 Slash(Slash),
2414 Percent(Percent),
2415 Shl(Shl),
2416 Shr(Shr),
2417 Caret(Caret),
2418 Pipe(Pipe),
2419 Amp(Amp),
2420 Eq(Eq),
2421 Pluseq(Pluseq),
2422 Slasheq(Slasheq),
2423 Stareq(Stareq),
2424 Percenteq(Percenteq),
2425 Shreq(Shreq),
2426 Shleq(Shleq),
2427 Minuseq(Minuseq),
2428 Pipeeq(Pipeeq),
2429 Ampeq(Ampeq),
2430 Careteq(Careteq),
2431}
2432impl From<Pipepipe> for BinOp {
2433 fn from(node: Pipepipe) -> BinOp { BinOp::Pipepipe(node) }
2434}
2435impl From<Ampamp> for BinOp {
2436 fn from(node: Ampamp) -> BinOp { BinOp::Ampamp(node) }
2437}
2438impl From<Eqeq> for BinOp {
2439 fn from(node: Eqeq) -> BinOp { BinOp::Eqeq(node) }
2440}
2441impl From<Neq> for BinOp {
2442 fn from(node: Neq) -> BinOp { BinOp::Neq(node) }
2443}
2444impl From<Lteq> for BinOp {
2445 fn from(node: Lteq) -> BinOp { BinOp::Lteq(node) }
2446}
2447impl From<Gteq> for BinOp {
2448 fn from(node: Gteq) -> BinOp { BinOp::Gteq(node) }
2449}
2450impl From<LAngle> for BinOp {
2451 fn from(node: LAngle) -> BinOp { BinOp::LAngle(node) }
2452}
2453impl From<RAngle> for BinOp {
2454 fn from(node: RAngle) -> BinOp { BinOp::RAngle(node) }
2455}
2456impl From<Plus> for BinOp {
2457 fn from(node: Plus) -> BinOp { BinOp::Plus(node) }
2458}
2459impl From<Star> for BinOp {
2460 fn from(node: Star) -> BinOp { BinOp::Star(node) }
2461}
2462impl From<Minus> for BinOp {
2463 fn from(node: Minus) -> BinOp { BinOp::Minus(node) }
2464}
2465impl From<Slash> for BinOp {
2466 fn from(node: Slash) -> BinOp { BinOp::Slash(node) }
2467}
2468impl From<Percent> for BinOp {
2469 fn from(node: Percent) -> BinOp { BinOp::Percent(node) }
2470}
2471impl From<Shl> for BinOp {
2472 fn from(node: Shl) -> BinOp { BinOp::Shl(node) }
2473}
2474impl From<Shr> for BinOp {
2475 fn from(node: Shr) -> BinOp { BinOp::Shr(node) }
2476}
2477impl From<Caret> for BinOp {
2478 fn from(node: Caret) -> BinOp { BinOp::Caret(node) }
2479}
2480impl From<Pipe> for BinOp {
2481 fn from(node: Pipe) -> BinOp { BinOp::Pipe(node) }
2482}
2483impl From<Amp> for BinOp {
2484 fn from(node: Amp) -> BinOp { BinOp::Amp(node) }
2485}
2486impl From<Eq> for BinOp {
2487 fn from(node: Eq) -> BinOp { BinOp::Eq(node) }
2488}
2489impl From<Pluseq> for BinOp {
2490 fn from(node: Pluseq) -> BinOp { BinOp::Pluseq(node) }
2491}
2492impl From<Slasheq> for BinOp {
2493 fn from(node: Slasheq) -> BinOp { BinOp::Slasheq(node) }
2494}
2495impl From<Stareq> for BinOp {
2496 fn from(node: Stareq) -> BinOp { BinOp::Stareq(node) }
2497}
2498impl From<Percenteq> for BinOp {
2499 fn from(node: Percenteq) -> BinOp { BinOp::Percenteq(node) }
2500}
2501impl From<Shreq> for BinOp {
2502 fn from(node: Shreq) -> BinOp { BinOp::Shreq(node) }
2503}
2504impl From<Shleq> for BinOp {
2505 fn from(node: Shleq) -> BinOp { BinOp::Shleq(node) }
2506}
2507impl From<Minuseq> for BinOp {
2508 fn from(node: Minuseq) -> BinOp { BinOp::Minuseq(node) }
2509}
2510impl From<Pipeeq> for BinOp {
2511 fn from(node: Pipeeq) -> BinOp { BinOp::Pipeeq(node) }
2512}
2513impl From<Ampeq> for BinOp {
2514 fn from(node: Ampeq) -> BinOp { BinOp::Ampeq(node) }
2515}
2516impl From<Careteq> for BinOp {
2517 fn from(node: Careteq) -> BinOp { BinOp::Careteq(node) }
2518}
2519impl std::fmt::Display for BinOp {
2520 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2521 std::fmt::Display::fmt(self.syntax(), f)
2522 }
2523}
2524impl AstToken for BinOp {
2525 fn can_cast(kind: SyntaxKind) -> bool {
2526 match kind {
2527 PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
2528 | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
2529 | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
2530 _ => false,
2531 }
2532 }
2533 fn cast(syntax: SyntaxToken) -> Option<Self> {
2534 let res = match syntax.kind() {
2535 PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
2536 AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
2537 EQEQ => BinOp::Eqeq(Eqeq { syntax }),
2538 NEQ => BinOp::Neq(Neq { syntax }),
2539 LTEQ => BinOp::Lteq(Lteq { syntax }),
2540 GTEQ => BinOp::Gteq(Gteq { syntax }),
2541 L_ANGLE => BinOp::LAngle(LAngle { syntax }),
2542 R_ANGLE => BinOp::RAngle(RAngle { syntax }),
2543 PLUS => BinOp::Plus(Plus { syntax }),
2544 STAR => BinOp::Star(Star { syntax }),
2545 MINUS => BinOp::Minus(Minus { syntax }),
2546 SLASH => BinOp::Slash(Slash { syntax }),
2547 PERCENT => BinOp::Percent(Percent { syntax }),
2548 SHL => BinOp::Shl(Shl { syntax }),
2549 SHR => BinOp::Shr(Shr { syntax }),
2550 CARET => BinOp::Caret(Caret { syntax }),
2551 PIPE => BinOp::Pipe(Pipe { syntax }),
2552 AMP => BinOp::Amp(Amp { syntax }),
2553 EQ => BinOp::Eq(Eq { syntax }),
2554 PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
2555 SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
2556 STAREQ => BinOp::Stareq(Stareq { syntax }),
2557 PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
2558 SHREQ => BinOp::Shreq(Shreq { syntax }),
2559 SHLEQ => BinOp::Shleq(Shleq { syntax }),
2560 MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
2561 PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
2562 AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
2563 CARETEQ => BinOp::Careteq(Careteq { syntax }),
2564 _ => return None,
2565 };
2566 Some(res)
2567 }
2568 fn syntax(&self) -> &SyntaxToken {
2569 match self {
2570 BinOp::Pipepipe(it) => &it.syntax,
2571 BinOp::Ampamp(it) => &it.syntax,
2572 BinOp::Eqeq(it) => &it.syntax,
2573 BinOp::Neq(it) => &it.syntax,
2574 BinOp::Lteq(it) => &it.syntax,
2575 BinOp::Gteq(it) => &it.syntax,
2576 BinOp::LAngle(it) => &it.syntax,
2577 BinOp::RAngle(it) => &it.syntax,
2578 BinOp::Plus(it) => &it.syntax,
2579 BinOp::Star(it) => &it.syntax,
2580 BinOp::Minus(it) => &it.syntax,
2581 BinOp::Slash(it) => &it.syntax,
2582 BinOp::Percent(it) => &it.syntax,
2583 BinOp::Shl(it) => &it.syntax,
2584 BinOp::Shr(it) => &it.syntax,
2585 BinOp::Caret(it) => &it.syntax,
2586 BinOp::Pipe(it) => &it.syntax,
2587 BinOp::Amp(it) => &it.syntax,
2588 BinOp::Eq(it) => &it.syntax,
2589 BinOp::Pluseq(it) => &it.syntax,
2590 BinOp::Slasheq(it) => &it.syntax,
2591 BinOp::Stareq(it) => &it.syntax,
2592 BinOp::Percenteq(it) => &it.syntax,
2593 BinOp::Shreq(it) => &it.syntax,
2594 BinOp::Shleq(it) => &it.syntax,
2595 BinOp::Minuseq(it) => &it.syntax,
2596 BinOp::Pipeeq(it) => &it.syntax,
2597 BinOp::Ampeq(it) => &it.syntax,
2598 BinOp::Careteq(it) => &it.syntax,
2599 }
2600 }
2601}
2602#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2603pub enum PrefixOp {
2604 Minus(Minus),
2605 Excl(Excl),
2606 Star(Star),
2607}
2608impl From<Minus> for PrefixOp {
2609 fn from(node: Minus) -> PrefixOp { PrefixOp::Minus(node) }
2610}
2611impl From<Excl> for PrefixOp {
2612 fn from(node: Excl) -> PrefixOp { PrefixOp::Excl(node) }
2613}
2614impl From<Star> for PrefixOp {
2615 fn from(node: Star) -> PrefixOp { PrefixOp::Star(node) }
2616}
2617impl std::fmt::Display for PrefixOp {
2618 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2619 std::fmt::Display::fmt(self.syntax(), f)
2620 }
2621}
2622impl AstToken for PrefixOp {
2623 fn can_cast(kind: SyntaxKind) -> bool {
2624 match kind {
2625 MINUS | EXCL | STAR => true,
2626 _ => false,
2627 }
2628 }
2629 fn cast(syntax: SyntaxToken) -> Option<Self> {
2630 let res = match syntax.kind() {
2631 MINUS => PrefixOp::Minus(Minus { syntax }),
2632 EXCL => PrefixOp::Excl(Excl { syntax }),
2633 STAR => PrefixOp::Star(Star { syntax }),
2634 _ => return None,
2635 };
2636 Some(res)
2637 }
2638 fn syntax(&self) -> &SyntaxToken {
2639 match self {
2640 PrefixOp::Minus(it) => &it.syntax,
2641 PrefixOp::Excl(it) => &it.syntax,
2642 PrefixOp::Star(it) => &it.syntax,
2643 }
2644 }
2645}
2646#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2647pub enum RangeOp {
2648 Dotdot(Dotdot),
2649 Dotdoteq(Dotdoteq),
2650}
2651impl From<Dotdot> for RangeOp {
2652 fn from(node: Dotdot) -> RangeOp { RangeOp::Dotdot(node) }
2653}
2654impl From<Dotdoteq> for RangeOp {
2655 fn from(node: Dotdoteq) -> RangeOp { RangeOp::Dotdoteq(node) }
2656}
2657impl std::fmt::Display for RangeOp {
2658 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2659 std::fmt::Display::fmt(self.syntax(), f)
2660 }
2661}
2662impl AstToken for RangeOp {
2663 fn can_cast(kind: SyntaxKind) -> bool {
2664 match kind {
2665 DOTDOT | DOTDOTEQ => true,
2666 _ => false,
2667 }
2668 }
2669 fn cast(syntax: SyntaxToken) -> Option<Self> {
2670 let res = match syntax.kind() {
2671 DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
2672 DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
2673 _ => return None,
2674 };
2675 Some(res)
2676 }
2677 fn syntax(&self) -> &SyntaxToken {
2678 match self {
2679 RangeOp::Dotdot(it) => &it.syntax,
2680 RangeOp::Dotdoteq(it) => &it.syntax,
2681 }
2682 }
2683}
2684#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2685pub enum LiteralToken {
2686 IntNumber(IntNumber),
2687 FloatNumber(FloatNumber),
2688 String(String),
2689 RawString(RawString),
2690 TrueKw(TrueKw),
2691 FalseKw(FalseKw),
2692 ByteString(ByteString),
2693 RawByteString(RawByteString),
2694 Char(Char),
2695 Byte(Byte),
2696}
2697impl From<IntNumber> for LiteralToken {
2698 fn from(node: IntNumber) -> LiteralToken { LiteralToken::IntNumber(node) }
2699}
2700impl From<FloatNumber> for LiteralToken {
2701 fn from(node: FloatNumber) -> LiteralToken { LiteralToken::FloatNumber(node) }
2702}
2703impl From<String> for LiteralToken {
2704 fn from(node: String) -> LiteralToken { LiteralToken::String(node) }
2705}
2706impl From<RawString> for LiteralToken {
2707 fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) }
2708}
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 {
2716 fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) }
2717}
2718impl From<RawByteString> for LiteralToken {
2719 fn from(node: RawByteString) -> LiteralToken { LiteralToken::RawByteString(node) }
2720}
2721impl From<Char> for LiteralToken {
2722 fn from(node: Char) -> LiteralToken { LiteralToken::Char(node) }
2723}
2724impl From<Byte> for LiteralToken {
2725 fn from(node: Byte) -> LiteralToken { LiteralToken::Byte(node) }
2726}
2727impl std::fmt::Display for LiteralToken {
2728 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2729 std::fmt::Display::fmt(self.syntax(), f)
2730 }
2731}
2732impl AstToken for LiteralToken {
2733 fn can_cast(kind: SyntaxKind) -> bool {
2734 match kind {
2735 INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
2736 | RAW_BYTE_STRING | CHAR | BYTE => true,
2737 _ => false,
2738 }
2739 }
2740 fn cast(syntax: SyntaxToken) -> Option<Self> {
2741 let res = match syntax.kind() {
2742 INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
2743 FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
2744 STRING => LiteralToken::String(String { syntax }),
2745 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 }),
2749 RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
2750 CHAR => LiteralToken::Char(Char { syntax }),
2751 BYTE => LiteralToken::Byte(Byte { syntax }),
2752 _ => return None,
2753 };
2754 Some(res)
2755 }
2756 fn syntax(&self) -> &SyntaxToken {
2757 match self {
2758 LiteralToken::IntNumber(it) => &it.syntax,
2759 LiteralToken::FloatNumber(it) => &it.syntax,
2760 LiteralToken::String(it) => &it.syntax,
2761 LiteralToken::RawString(it) => &it.syntax,
2762 LiteralToken::TrueKw(it) => &it.syntax,
2763 LiteralToken::FalseKw(it) => &it.syntax,
2764 LiteralToken::ByteString(it) => &it.syntax,
2765 LiteralToken::RawByteString(it) => &it.syntax,
2766 LiteralToken::Char(it) => &it.syntax,
2767 LiteralToken::Byte(it) => &it.syntax,
2768 }
2769 }
2770}
2771#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2772pub enum NameRefToken {
2773 Ident(Ident),
2774 IntNumber(IntNumber),
2775}
2776impl From<Ident> for NameRefToken {
2777 fn from(node: Ident) -> NameRefToken { NameRefToken::Ident(node) }
2778}
2779impl From<IntNumber> for NameRefToken {
2780 fn from(node: IntNumber) -> NameRefToken { NameRefToken::IntNumber(node) }
2781}
2782impl std::fmt::Display for NameRefToken {
2783 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2784 std::fmt::Display::fmt(self.syntax(), f)
2785 }
2786}
2787impl AstToken for NameRefToken {
2788 fn can_cast(kind: SyntaxKind) -> bool {
2789 match kind {
2790 IDENT | INT_NUMBER => true,
2791 _ => false,
2792 }
2793 }
2794 fn cast(syntax: SyntaxToken) -> Option<Self> {
2795 let res = match syntax.kind() {
2796 IDENT => NameRefToken::Ident(Ident { syntax }),
2797 INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
2798 _ => return None,
2799 };
2800 Some(res)
2801 }
2802 fn syntax(&self) -> &SyntaxToken {
2803 match self {
2804 NameRefToken::Ident(it) => &it.syntax,
2805 NameRefToken::IntNumber(it) => &it.syntax,
2806 }
2807 }
2808}
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index f39559e9e..0f4a50be4 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -100,6 +100,9 @@ pub fn expr_empty_block() -> ast::Expr {
100pub fn expr_unimplemented() -> ast::Expr { 100pub fn expr_unimplemented() -> ast::Expr {
101 expr_from_text("unimplemented!()") 101 expr_from_text("unimplemented!()")
102} 102}
103pub fn expr_todo() -> ast::Expr {
104 expr_from_text("todo!()")
105}
103pub fn expr_path(path: ast::Path) -> ast::Expr { 106pub fn expr_path(path: ast::Path) -> ast::Expr {
104 expr_from_text(&path.to_string()) 107 expr_from_text(&path.to_string())
105} 108}
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 870e83804..bfc05e08b 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -1,83 +1,77 @@
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, child_opt, children, support, AstChildren, AstNode, AstToken}, 7 ast::{self, support, AstChildren, AstNode, AstToken},
9 syntax_node::SyntaxElementChildren, 8 syntax_node::SyntaxElementChildren,
9 SyntaxToken, T,
10}; 10};
11 11
12pub trait TypeAscriptionOwner: AstNode { 12pub trait TypeAscriptionOwner: AstNode {
13 fn ascribed_type(&self) -> Option<ast::TypeRef> { 13 fn ascribed_type(&self) -> Option<ast::TypeRef> {
14 child_opt(self) 14 support::child(self.syntax())
15 } 15 }
16} 16}
17 17
18pub trait NameOwner: AstNode { 18pub trait NameOwner: AstNode {
19 fn name(&self) -> Option<ast::Name> { 19 fn name(&self) -> Option<ast::Name> {
20 child_opt(self) 20 support::child(self.syntax())
21 } 21 }
22} 22}
23 23
24pub trait VisibilityOwner: AstNode { 24pub trait VisibilityOwner: AstNode {
25 fn visibility(&self) -> Option<ast::Visibility> { 25 fn visibility(&self) -> Option<ast::Visibility> {
26 child_opt(self) 26 support::child(self.syntax())
27 } 27 }
28} 28}
29 29
30pub trait LoopBodyOwner: AstNode { 30pub trait LoopBodyOwner: AstNode {
31 fn loop_body(&self) -> Option<ast::BlockExpr> { 31 fn loop_body(&self) -> Option<ast::BlockExpr> {
32 child_opt(self) 32 support::child(self.syntax())
33 } 33 }
34 34
35 fn label(&self) -> Option<ast::Label> { 35 fn label(&self) -> Option<ast::Label> {
36 child_opt(self) 36 support::child(self.syntax())
37 } 37 }
38} 38}
39 39
40pub trait ArgListOwner: AstNode { 40pub trait ArgListOwner: AstNode {
41 fn arg_list(&self) -> Option<ast::ArgList> { 41 fn arg_list(&self) -> Option<ast::ArgList> {
42 child_opt(self) 42 support::child(self.syntax())
43 }
44}
45
46pub trait FnDefOwner: AstNode {
47 fn functions(&self) -> AstChildren<ast::FnDef> {
48 children(self)
49 } 43 }
50} 44}
51 45
52pub trait ModuleItemOwner: AstNode { 46pub trait ModuleItemOwner: AstNode {
53 fn items(&self) -> AstChildren<ast::ModuleItem> { 47 fn items(&self) -> AstChildren<ast::ModuleItem> {
54 children(self) 48 support::children(self.syntax())
55 } 49 }
56} 50}
57 51
58pub trait TypeParamsOwner: AstNode { 52pub trait TypeParamsOwner: AstNode {
59 fn type_param_list(&self) -> Option<ast::TypeParamList> { 53 fn type_param_list(&self) -> Option<ast::TypeParamList> {
60 child_opt(self) 54 support::child(self.syntax())
61 } 55 }
62 56
63 fn where_clause(&self) -> Option<ast::WhereClause> { 57 fn where_clause(&self) -> Option<ast::WhereClause> {
64 child_opt(self) 58 support::child(self.syntax())
65 } 59 }
66} 60}
67 61
68pub trait TypeBoundsOwner: AstNode { 62pub trait TypeBoundsOwner: AstNode {
69 fn type_bound_list(&self) -> Option<ast::TypeBoundList> { 63 fn type_bound_list(&self) -> Option<ast::TypeBoundList> {
70 child_opt(self) 64 support::child(self.syntax())
71 } 65 }
72 66
73 fn colon(&self) -> Option<ast::Colon> { 67 fn colon_token(&self) -> Option<SyntaxToken> {
74 support::token(self.syntax()) 68 support::token(self.syntax(), T![:])
75 } 69 }
76} 70}
77 71
78pub trait AttrsOwner: AstNode { 72pub trait AttrsOwner: AstNode {
79 fn attrs(&self) -> AstChildren<ast::Attr> { 73 fn attrs(&self) -> AstChildren<ast::Attr> {
80 children(self) 74 support::children(self.syntax())
81 } 75 }
82 fn has_atom_attr(&self, atom: &str) -> bool { 76 fn has_atom_attr(&self, atom: &str) -> bool {
83 self.attrs().filter_map(|x| x.as_simple_atom()).any(|x| x == atom) 77 self.attrs().filter_map(|x| x.as_simple_atom()).any(|x| x == atom)
@@ -122,7 +116,8 @@ pub trait DocCommentsOwner: AstNode {
122 // of a line in markdown. 116 // of a line in markdown.
123 line[pos..end].to_owned() 117 line[pos..end].to_owned()
124 }) 118 })
125 .join("\n"); 119 .sep_by("\n")
120 .to_string();
126 121
127 if has_comments { 122 if has_comments {
128 Some(docs) 123 Some(docs)