aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/algo.rs16
-rw-r--r--crates/ra_syntax/src/ast.rs28
-rw-r--r--crates/ra_syntax/src/ast/edit.rs34
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs4
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs258
-rw-r--r--crates/ra_syntax/src/ast/generated.rs4854
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs4180
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs2808
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs62
-rw-r--r--crates/ra_syntax/src/ast/traits.rs10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast61
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs1
12 files changed, 7201 insertions, 5115 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index 8d1098036..7f87f4212 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -7,7 +7,7 @@ use std::{
7 7
8use itertools::Itertools; 8use itertools::Itertools;
9use ra_text_edit::TextEditBuilder; 9use ra_text_edit::TextEditBuilder;
10use rustc_hash::{FxHashMap, FxHashSet}; 10use rustc_hash::FxHashMap;
11 11
12use crate::{ 12use crate::{
13 AstNode, Direction, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxNodePtr, SyntaxToken, 13 AstNode, Direction, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxNodePtr, SyntaxToken,
@@ -72,8 +72,18 @@ pub fn find_covering_element(root: &SyntaxNode, range: TextRange) -> SyntaxEleme
72} 72}
73 73
74pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option<SyntaxNode> { 74pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option<SyntaxNode> {
75 let u_ancestors = u.ancestors().collect::<FxHashSet<SyntaxNode>>(); 75 if u == v {
76 v.ancestors().find(|it| u_ancestors.contains(it)) 76 return Some(u.clone());
77 }
78
79 let u_depth = u.ancestors().count();
80 let v_depth = v.ancestors().count();
81 let keep = u_depth.min(v_depth);
82
83 let u_candidates = u.ancestors().skip(u_depth - keep);
84 let v_canidates = v.ancestors().skip(v_depth - keep);
85 let (res, _) = u_candidates.zip(v_canidates).find(|(x, y)| x == y)?;
86 Some(res)
77} 87}
78 88
79pub fn neighbor<T: AstNode>(me: &T, direction: Direction) -> Option<T> { 89pub fn neighbor<T: AstNode>(me: &T, direction: Direction) -> Option<T> {
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 26fafb469..15a8279f3 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -21,7 +21,7 @@ pub use self::{
21 AttrKind, FieldKind, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind, 21 AttrKind, FieldKind, PathSegmentKind, SelfParamKind, SlicePatComponents, StructKind,
22 TypeBoundKind, VisibilityKind, 22 TypeBoundKind, VisibilityKind,
23 }, 23 },
24 generated::*, 24 generated::{nodes::*, tokens::*},
25 tokens::*, 25 tokens::*,
26 traits::*, 26 traits::*,
27}; 27};
@@ -30,7 +30,7 @@ pub use self::{
30/// conversion itself has zero runtime cost: ast and syntax nodes have exactly 30/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
31/// the same representation: a pointer to the tree root and a pointer to the 31/// the same representation: a pointer to the tree root and a pointer to the
32/// node itself. 32/// node itself.
33pub trait AstNode: std::fmt::Display { 33pub trait AstNode {
34 fn can_cast(kind: SyntaxKind) -> bool 34 fn can_cast(kind: SyntaxKind) -> bool
35 where 35 where
36 Self: Sized; 36 Self: Sized;
@@ -49,15 +49,37 @@ fn assert_ast_is_object_safe() {
49 49
50/// Like `AstNode`, but wraps tokens rather than interior nodes. 50/// Like `AstNode`, but wraps tokens rather than interior nodes.
51pub trait AstToken { 51pub trait AstToken {
52 fn cast(token: SyntaxToken) -> Option<Self> 52 fn can_cast(token: SyntaxKind) -> bool
53 where 53 where
54 Self: Sized; 54 Self: Sized;
55
56 fn cast(syntax: SyntaxToken) -> Option<Self>
57 where
58 Self: Sized;
59
55 fn syntax(&self) -> &SyntaxToken; 60 fn syntax(&self) -> &SyntaxToken;
61
56 fn text(&self) -> &SmolStr { 62 fn text(&self) -> &SmolStr {
57 self.syntax().text() 63 self.syntax().text()
58 } 64 }
59} 65}
60 66
67mod support {
68 use super::{AstChildren, AstNode, AstToken, SyntaxNode};
69
70 pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
71 parent.children().find_map(N::cast)
72 }
73
74 pub(super) fn children<N: AstNode>(parent: &SyntaxNode) -> AstChildren<N> {
75 AstChildren::new(parent)
76 }
77
78 pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
79 parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
80 }
81}
82
61/// An iterator over `SyntaxNode` children of a particular AST type. 83/// An iterator over `SyntaxNode` children of a particular AST type.
62#[derive(Debug, Clone)] 84#[derive(Debug, Clone)]
63pub struct AstChildren<N> { 85pub struct AstChildren<N> {
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index b69cae234..069c6ee82 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -33,9 +33,9 @@ impl ast::FnDef {
33 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); 33 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
34 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { 34 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
35 old_body.syntax().clone().into() 35 old_body.syntax().clone().into()
36 } else if let Some(semi) = self.semicolon_token() { 36 } else if let Some(semi) = self.semi_token() {
37 to_insert.push(make::tokens::single_space().into()); 37 to_insert.push(make::tokens::single_space().into());
38 semi.into() 38 semi.syntax.clone().into()
39 } else { 39 } else {
40 to_insert.push(make::tokens::single_space().into()); 40 to_insert.push(make::tokens::single_space().into());
41 to_insert.push(body.syntax().clone().into()); 41 to_insert.push(body.syntax().clone().into());
@@ -96,10 +96,10 @@ impl ast::ItemList {
96 leading_indent(it.syntax()).unwrap_or_default().to_string(), 96 leading_indent(it.syntax()).unwrap_or_default().to_string(),
97 InsertPosition::After(it.syntax().clone().into()), 97 InsertPosition::After(it.syntax().clone().into()),
98 ), 98 ),
99 None => match self.l_curly() { 99 None => match self.l_curly_token() {
100 Some(it) => ( 100 Some(it) => (
101 " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), 101 " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(),
102 InsertPosition::After(it), 102 InsertPosition::After(it.syntax().clone().into()),
103 ), 103 ),
104 None => return self.clone(), 104 None => return self.clone(),
105 }, 105 },
@@ -109,10 +109,6 @@ impl ast::ItemList {
109 [ws.ws().into(), item.syntax().clone().into()].into(); 109 [ws.ws().into(), item.syntax().clone().into()].into();
110 self.insert_children(position, to_insert) 110 self.insert_children(position, to_insert)
111 } 111 }
112
113 fn l_curly(&self) -> Option<SyntaxElement> {
114 self.syntax().children_with_tokens().find(|it| it.kind() == T!['{'])
115 }
116} 112}
117 113
118impl ast::RecordFieldList { 114impl ast::RecordFieldList {
@@ -146,8 +142,8 @@ impl ast::RecordFieldList {
146 142
147 macro_rules! after_l_curly { 143 macro_rules! after_l_curly {
148 () => {{ 144 () => {{
149 let anchor = match self.l_curly() { 145 let anchor = match self.l_curly_token() {
150 Some(it) => it, 146 Some(it) => it.syntax().clone().into(),
151 None => return self.clone(), 147 None => return self.clone(),
152 }; 148 };
153 InsertPosition::After(anchor) 149 InsertPosition::After(anchor)
@@ -189,24 +185,20 @@ impl ast::RecordFieldList {
189 185
190 self.insert_children(position, to_insert) 186 self.insert_children(position, to_insert)
191 } 187 }
192
193 fn l_curly(&self) -> Option<SyntaxElement> {
194 self.syntax().children_with_tokens().find(|it| it.kind() == T!['{'])
195 }
196} 188}
197 189
198impl ast::TypeParam { 190impl ast::TypeParam {
199 #[must_use] 191 #[must_use]
200 pub fn remove_bounds(&self) -> ast::TypeParam { 192 pub fn remove_bounds(&self) -> ast::TypeParam {
201 let colon = match self.colon_token() { 193 let colon = match self.colon() {
202 Some(it) => it, 194 Some(it) => it,
203 None => return self.clone(), 195 None => return self.clone(),
204 }; 196 };
205 let end = match self.type_bound_list() { 197 let end = match self.type_bound_list() {
206 Some(it) => it.syntax().clone().into(), 198 Some(it) => it.syntax().clone().into(),
207 None => colon.clone().into(), 199 None => colon.syntax().clone().into(),
208 }; 200 };
209 self.replace_children(colon.into()..=end, iter::empty()) 201 self.replace_children(colon.syntax().clone().into()..=end, iter::empty())
210 } 202 }
211} 203}
212 204
@@ -305,8 +297,12 @@ impl ast::UseTree {
305 Some(it) => it, 297 Some(it) => it,
306 None => return self.clone(), 298 None => return self.clone(),
307 }; 299 };
308 let use_tree = 300 let use_tree = make::use_tree(
309 make::use_tree(suffix.clone(), self.use_tree_list(), self.alias(), self.has_star()); 301 suffix.clone(),
302 self.use_tree_list(),
303 self.alias(),
304 self.star_token().is_some(),
305 );
310 let nested = make::use_tree_list(iter::once(use_tree)); 306 let nested = make::use_tree_list(iter::once(use_tree));
311 return make::use_tree(prefix.clone(), Some(nested), None, false); 307 return make::use_tree(prefix.clone(), Some(nested), None, false);
312 308
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 8bbd946c0..40c8fca3b 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -52,6 +52,10 @@ impl ast::RefExpr {
52 pub fn is_mut(&self) -> bool { 52 pub fn is_mut(&self) -> bool {
53 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut]) 53 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
54 } 54 }
55
56 pub fn raw_token(&self) -> Option<SyntaxToken> {
57 None // FIXME: implement &raw
58 }
55} 59}
56 60
57#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 61#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index bf7d137be..b50a89864 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -2,14 +2,14 @@
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::{self, child_opt, children, AstNode, AttrInput, NameOwner, SyntaxNode}, 8 ast::{
8 SmolStr, SyntaxElement, 9 self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode,
9 SyntaxKind::*, 10 },
10 SyntaxToken, T, 11 SmolStr, SyntaxElement, SyntaxToken, T,
11}; 12};
12use ra_parser::SyntaxKind;
13 13
14impl ast::Name { 14impl ast::Name {
15 pub fn text(&self) -> &SmolStr { 15 pub fn text(&self) -> &SmolStr {
@@ -23,13 +23,11 @@ impl ast::NameRef {
23 } 23 }
24 24
25 pub fn as_tuple_field(&self) -> Option<usize> { 25 pub fn as_tuple_field(&self) -> Option<usize> {
26 self.syntax().children_with_tokens().find_map(|c| { 26 if let Some(ast::NameRefToken::IntNumber(token)) = self.name_ref_token_token() {
27 if c.kind() == SyntaxKind::INT_NUMBER { 27 token.text().as_str().parse().ok()
28 c.as_token().and_then(|tok| tok.text().as_str().parse().ok()) 28 } else {
29 } else { 29 None
30 None 30 }
31 }
32 })
33 } 31 }
34} 32}
35 33
@@ -130,13 +128,6 @@ impl ast::PathSegment {
130 }; 128 };
131 Some(res) 129 Some(res)
132 } 130 }
133
134 pub fn has_colon_colon(&self) -> bool {
135 match self.syntax.first_child_or_token().map(|s| s.kind()) {
136 Some(T![::]) => true,
137 _ => false,
138 }
139 }
140} 131}
141 132
142impl ast::Path { 133impl ast::Path {
@@ -145,21 +136,6 @@ impl ast::Path {
145 } 136 }
146} 137}
147 138
148impl ast::Module {
149 pub fn has_semi(&self) -> bool {
150 match self.syntax().last_child_or_token() {
151 None => false,
152 Some(node) => node.kind() == T![;],
153 }
154 }
155}
156
157impl ast::UseTree {
158 pub fn has_star(&self) -> bool {
159 self.syntax().children_with_tokens().any(|it| it.kind() == T![*])
160 }
161}
162
163impl ast::UseTreeList { 139impl ast::UseTreeList {
164 pub fn parent_use_tree(&self) -> ast::UseTree { 140 pub fn parent_use_tree(&self) -> ast::UseTree {
165 self.syntax() 141 self.syntax()
@@ -167,20 +143,6 @@ impl ast::UseTreeList {
167 .and_then(ast::UseTree::cast) 143 .and_then(ast::UseTree::cast)
168 .expect("UseTreeLists are always nested in UseTrees") 144 .expect("UseTreeLists are always nested in UseTrees")
169 } 145 }
170 pub fn l_curly(&self) -> Option<SyntaxToken> {
171 self.token(T!['{'])
172 }
173
174 pub fn r_curly(&self) -> Option<SyntaxToken> {
175 self.token(T!['}'])
176 }
177
178 fn token(&self, kind: SyntaxKind) -> Option<SyntaxToken> {
179 self.syntax()
180 .children_with_tokens()
181 .filter_map(|it| it.into_token())
182 .find(|it| it.kind() == kind)
183 }
184} 146}
185 147
186impl ast::ImplDef { 148impl ast::ImplDef {
@@ -204,10 +166,6 @@ impl ast::ImplDef {
204 let second = types.next(); 166 let second = types.next();
205 (first, second) 167 (first, second)
206 } 168 }
207
208 pub fn is_negative(&self) -> bool {
209 self.syntax().children_with_tokens().any(|t| t.kind() == T![!])
210 }
211} 169}
212 170
213#[derive(Debug, Clone, PartialEq, Eq)] 171#[derive(Debug, Clone, PartialEq, Eq)]
@@ -248,41 +206,6 @@ impl ast::EnumVariant {
248 } 206 }
249} 207}
250 208
251impl ast::FnDef {
252 pub fn semicolon_token(&self) -> Option<SyntaxToken> {
253 self.syntax()
254 .last_child_or_token()
255 .and_then(|it| it.into_token())
256 .filter(|it| it.kind() == T![;])
257 }
258
259 pub fn is_async(&self) -> bool {
260 self.syntax().children_with_tokens().any(|it| it.kind() == T![async])
261 }
262}
263
264impl ast::LetStmt {
265 pub fn has_semi(&self) -> bool {
266 match self.syntax().last_child_or_token() {
267 None => false,
268 Some(node) => node.kind() == T![;],
269 }
270 }
271
272 pub fn eq_token(&self) -> Option<SyntaxToken> {
273 self.syntax().children_with_tokens().find(|t| t.kind() == EQ).and_then(|it| it.into_token())
274 }
275}
276
277impl ast::ExprStmt {
278 pub fn has_semi(&self) -> bool {
279 match self.syntax().last_child_or_token() {
280 None => false,
281 Some(node) => node.kind() == T![;],
282 }
283 }
284}
285
286#[derive(Debug, Clone, PartialEq, Eq)] 209#[derive(Debug, Clone, PartialEq, Eq)]
287pub enum FieldKind { 210pub enum FieldKind {
288 Name(ast::NameRef), 211 Name(ast::NameRef),
@@ -311,25 +234,6 @@ impl ast::FieldExpr {
311 } 234 }
312} 235}
313 236
314impl ast::RefPat {
315 pub fn is_mut(&self) -> bool {
316 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
317 }
318}
319
320impl ast::BindPat {
321 pub fn is_mutable(&self) -> bool {
322 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
323 }
324
325 pub fn is_ref(&self) -> bool {
326 self.syntax().children_with_tokens().any(|n| n.kind() == T![ref])
327 }
328 pub fn has_at(&self) -> bool {
329 self.syntax().children_with_tokens().any(|it| it.kind() == T![@])
330 }
331}
332
333pub struct SlicePatComponents { 237pub struct SlicePatComponents {
334 pub prefix: Vec<ast::Pat>, 238 pub prefix: Vec<ast::Pat>,
335 pub slice: Option<ast::Pat>, 239 pub slice: Option<ast::Pat>,
@@ -364,18 +268,6 @@ impl ast::SlicePat {
364 } 268 }
365} 269}
366 270
367impl ast::PointerType {
368 pub fn is_mut(&self) -> bool {
369 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
370 }
371}
372
373impl ast::ReferenceType {
374 pub fn is_mut(&self) -> bool {
375 self.syntax().children_with_tokens().any(|n| n.kind() == T![mut])
376 }
377}
378
379#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 271#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
380pub enum SelfParamKind { 272pub enum SelfParamKind {
381 /// self 273 /// self
@@ -387,24 +279,9 @@ pub enum SelfParamKind {
387} 279}
388 280
389impl ast::SelfParam { 281impl ast::SelfParam {
390 pub fn self_kw_token(&self) -> SyntaxToken {
391 self.syntax()
392 .children_with_tokens()
393 .filter_map(|it| it.into_token())
394 .find(|it| it.kind() == T![self])
395 .expect("invalid tree: self param must have self")
396 }
397
398 pub fn kind(&self) -> SelfParamKind { 282 pub fn kind(&self) -> SelfParamKind {
399 let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == T![&]); 283 if self.amp_token().is_some() {
400 if borrowed { 284 if self.amp_mut_kw_token().is_some() {
401 // check for a `mut` coming after the & -- `mut &self` != `&mut self`
402 if self
403 .syntax()
404 .children_with_tokens()
405 .skip_while(|n| n.kind() != T![&])
406 .any(|n| n.kind() == T![mut])
407 {
408 SelfParamKind::MutRef 285 SelfParamKind::MutRef
409 } else { 286 } else {
410 SelfParamKind::Ref 287 SelfParamKind::Ref
@@ -413,32 +290,23 @@ impl ast::SelfParam {
413 SelfParamKind::Owned 290 SelfParamKind::Owned
414 } 291 }
415 } 292 }
416}
417 293
418impl ast::LifetimeParam { 294 /// the "mut" in "mut self", not the one in "&mut self"
419 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 295 pub fn mut_kw_token(&self) -> Option<ast::MutKw> {
420 self.syntax() 296 self.syntax()
421 .children_with_tokens() 297 .children_with_tokens()
422 .filter_map(|it| it.into_token()) 298 .filter_map(|it| it.into_token())
423 .find(|it| it.kind() == LIFETIME) 299 .take_while(|it| it.kind() != T![&])
300 .find_map(ast::MutKw::cast)
424 } 301 }
425}
426 302
427impl ast::TypeParam { 303 /// the "mut" in "&mut self", not the one in "mut self"
428 pub fn colon_token(&self) -> Option<SyntaxToken> { 304 pub fn amp_mut_kw_token(&self) -> Option<ast::MutKw> {
429 self.syntax() 305 self.syntax()
430 .children_with_tokens() 306 .children_with_tokens()
431 .filter_map(|it| it.into_token()) 307 .filter_map(|it| it.into_token())
432 .find(|it| it.kind() == T![:]) 308 .skip_while(|it| it.kind() != T![&])
433 } 309 .find_map(ast::MutKw::cast)
434}
435
436impl ast::WherePred {
437 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
438 self.syntax()
439 .children_with_tokens()
440 .filter_map(|it| it.into_token())
441 .find(|it| it.kind() == LIFETIME)
442 } 310 }
443} 311}
444 312
@@ -449,7 +317,7 @@ pub enum TypeBoundKind {
449 /// for<'a> ... 317 /// for<'a> ...
450 ForType(ast::ForType), 318 ForType(ast::ForType),
451 /// 'a 319 /// 'a
452 Lifetime(ast::SyntaxToken), 320 Lifetime(ast::Lifetime),
453} 321}
454 322
455impl ast::TypeBound { 323impl ast::TypeBound {
@@ -458,34 +326,31 @@ impl ast::TypeBound {
458 TypeBoundKind::PathType(path_type) 326 TypeBoundKind::PathType(path_type)
459 } else if let Some(for_type) = children(self).next() { 327 } else if let Some(for_type) = children(self).next() {
460 TypeBoundKind::ForType(for_type) 328 TypeBoundKind::ForType(for_type)
461 } else if let Some(lifetime) = self.lifetime() { 329 } else if let Some(lifetime) = self.lifetime_token() {
462 TypeBoundKind::Lifetime(lifetime) 330 TypeBoundKind::Lifetime(lifetime)
463 } else { 331 } else {
464 unreachable!() 332 unreachable!()
465 } 333 }
466 } 334 }
467 335
468 fn lifetime(&self) -> Option<SyntaxToken> { 336 pub fn const_question_token(&self) -> Option<ast::Question> {
469 self.syntax() 337 self.syntax()
470 .children_with_tokens() 338 .children_with_tokens()
471 .filter_map(|it| it.into_token()) 339 .filter_map(|it| it.into_token())
472 .find(|it| it.kind() == LIFETIME) 340 .take_while(|it| it.kind() != T![const])
341 .find_map(ast::Question::cast)
473 } 342 }
474 343
475 pub fn question_mark_token(&self) -> Option<SyntaxToken> { 344 pub fn question_token(&self) -> Option<ast::Question> {
476 self.syntax() 345 if self.const_kw_token().is_some() {
477 .children_with_tokens() 346 self.syntax()
478 .filter_map(|it| it.into_token()) 347 .children_with_tokens()
479 .find(|it| it.kind() == T![?]) 348 .filter_map(|it| it.into_token())
480 } 349 .skip_while(|it| it.kind() != T![const])
481 pub fn has_question_mark(&self) -> bool { 350 .find_map(ast::Question::cast)
482 self.question_mark_token().is_some() 351 } else {
483 } 352 support::token(&self.syntax)
484} 353 }
485
486impl ast::TraitDef {
487 pub fn is_auto(&self) -> bool {
488 self.syntax().children_with_tokens().any(|t| t.kind() == T![auto])
489 } 354 }
490} 355}
491 356
@@ -493,6 +358,7 @@ pub enum VisibilityKind {
493 In(ast::Path), 358 In(ast::Path),
494 PubCrate, 359 PubCrate,
495 PubSuper, 360 PubSuper,
361 PubSelf,
496 Pub, 362 Pub,
497} 363}
498 364
@@ -500,22 +366,16 @@ impl ast::Visibility {
500 pub fn kind(&self) -> VisibilityKind { 366 pub fn kind(&self) -> VisibilityKind {
501 if let Some(path) = children(self).next() { 367 if let Some(path) = children(self).next() {
502 VisibilityKind::In(path) 368 VisibilityKind::In(path)
503 } else if self.is_pub_crate() { 369 } else if self.crate_kw_token().is_some() {
504 VisibilityKind::PubCrate 370 VisibilityKind::PubCrate
505 } else if self.is_pub_super() { 371 } else if self.super_kw_token().is_some() {
372 VisibilityKind::PubSuper
373 } else if self.self_kw_token().is_some() {
506 VisibilityKind::PubSuper 374 VisibilityKind::PubSuper
507 } else { 375 } else {
508 VisibilityKind::Pub 376 VisibilityKind::Pub
509 } 377 }
510 } 378 }
511
512 fn is_pub_crate(&self) -> bool {
513 self.syntax().children_with_tokens().any(|it| it.kind() == T![crate])
514 }
515
516 fn is_pub_super(&self) -> bool {
517 self.syntax().children_with_tokens().any(|it| it.kind() == T![super])
518 }
519} 379}
520 380
521impl ast::MacroCall { 381impl ast::MacroCall {
@@ -528,3 +388,41 @@ impl ast::MacroCall {
528 } 388 }
529 } 389 }
530} 390}
391
392impl ast::LifetimeParam {
393 pub fn lifetime_bounds(&self) -> impl Iterator<Item = ast::Lifetime> {
394 self.syntax()
395 .children_with_tokens()
396 .filter_map(|it| it.into_token())
397 .skip_while(|x| x.kind() != T![:])
398 .filter_map(ast::Lifetime::cast)
399 }
400}
401
402impl ast::RangePat {
403 pub fn start(&self) -> Option<ast::Pat> {
404 self.syntax()
405 .children_with_tokens()
406 .take_while(|it| !ast::RangeSeparator::can_cast(it.kind()))
407 .filter_map(|it| it.into_node())
408 .find_map(ast::Pat::cast)
409 }
410
411 pub fn end(&self) -> Option<ast::Pat> {
412 self.syntax()
413 .children_with_tokens()
414 .skip_while(|it| !ast::RangeSeparator::can_cast(it.kind()))
415 .filter_map(|it| it.into_node())
416 .find_map(ast::Pat::cast)
417 }
418}
419
420impl ast::TokenTree {
421 pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> {
422 self.syntax().first_child_or_token()?.into_token().and_then(ast::LeftDelimiter::cast)
423 }
424
425 pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> {
426 self.syntax().last_child_or_token()?.into_token().and_then(ast::RightDelimiter::cast)
427 }
428}
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 0c339b987..f5199e09f 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,4850 +1,6 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen` 1//! This file is actually hand-written, but the submodules are indeed generated.
2 2
3use crate::{ 3#[rustfmt::skip]
4 ast::{self, AstChildren, AstNode}, 4pub(super) mod nodes;
5 SyntaxKind::{self, *}, 5#[rustfmt::skip]
6 SyntaxNode, 6pub(super) mod tokens;
7};
8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9pub struct SourceFile {
10 pub(crate) syntax: SyntaxNode,
11}
12impl std::fmt::Display for SourceFile {
13 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
14 std::fmt::Display::fmt(self.syntax(), f)
15 }
16}
17impl AstNode for SourceFile {
18 fn can_cast(kind: SyntaxKind) -> bool {
19 match kind {
20 SOURCE_FILE => true,
21 _ => false,
22 }
23 }
24 fn cast(syntax: SyntaxNode) -> Option<Self> {
25 if Self::can_cast(syntax.kind()) {
26 Some(Self { syntax })
27 } else {
28 None
29 }
30 }
31 fn syntax(&self) -> &SyntaxNode {
32 &self.syntax
33 }
34}
35impl ast::ModuleItemOwner for SourceFile {}
36impl ast::FnDefOwner for SourceFile {}
37impl SourceFile {
38 pub fn modules(&self) -> AstChildren<Module> {
39 AstChildren::new(&self.syntax)
40 }
41}
42#[derive(Debug, Clone, PartialEq, Eq, Hash)]
43pub struct FnDef {
44 pub(crate) syntax: SyntaxNode,
45}
46impl std::fmt::Display for FnDef {
47 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
48 std::fmt::Display::fmt(self.syntax(), f)
49 }
50}
51impl AstNode for FnDef {
52 fn can_cast(kind: SyntaxKind) -> bool {
53 match kind {
54 FN_DEF => true,
55 _ => false,
56 }
57 }
58 fn cast(syntax: SyntaxNode) -> Option<Self> {
59 if Self::can_cast(syntax.kind()) {
60 Some(Self { syntax })
61 } else {
62 None
63 }
64 }
65 fn syntax(&self) -> &SyntaxNode {
66 &self.syntax
67 }
68}
69impl ast::VisibilityOwner for FnDef {}
70impl ast::NameOwner for FnDef {}
71impl ast::TypeParamsOwner for FnDef {}
72impl ast::DocCommentsOwner for FnDef {}
73impl ast::AttrsOwner for FnDef {}
74impl FnDef {
75 pub fn param_list(&self) -> Option<ParamList> {
76 AstChildren::new(&self.syntax).next()
77 }
78 pub fn ret_type(&self) -> Option<RetType> {
79 AstChildren::new(&self.syntax).next()
80 }
81 pub fn body(&self) -> Option<BlockExpr> {
82 AstChildren::new(&self.syntax).next()
83 }
84}
85#[derive(Debug, Clone, PartialEq, Eq, Hash)]
86pub struct RetType {
87 pub(crate) syntax: SyntaxNode,
88}
89impl std::fmt::Display for RetType {
90 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
91 std::fmt::Display::fmt(self.syntax(), f)
92 }
93}
94impl AstNode for RetType {
95 fn can_cast(kind: SyntaxKind) -> bool {
96 match kind {
97 RET_TYPE => true,
98 _ => false,
99 }
100 }
101 fn cast(syntax: SyntaxNode) -> Option<Self> {
102 if Self::can_cast(syntax.kind()) {
103 Some(Self { syntax })
104 } else {
105 None
106 }
107 }
108 fn syntax(&self) -> &SyntaxNode {
109 &self.syntax
110 }
111}
112impl RetType {
113 pub fn type_ref(&self) -> Option<TypeRef> {
114 AstChildren::new(&self.syntax).next()
115 }
116}
117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
118pub struct StructDef {
119 pub(crate) syntax: SyntaxNode,
120}
121impl std::fmt::Display for StructDef {
122 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
123 std::fmt::Display::fmt(self.syntax(), f)
124 }
125}
126impl AstNode for StructDef {
127 fn can_cast(kind: SyntaxKind) -> bool {
128 match kind {
129 STRUCT_DEF => true,
130 _ => false,
131 }
132 }
133 fn cast(syntax: SyntaxNode) -> Option<Self> {
134 if Self::can_cast(syntax.kind()) {
135 Some(Self { syntax })
136 } else {
137 None
138 }
139 }
140 fn syntax(&self) -> &SyntaxNode {
141 &self.syntax
142 }
143}
144impl ast::VisibilityOwner for StructDef {}
145impl ast::NameOwner for StructDef {}
146impl ast::TypeParamsOwner for StructDef {}
147impl ast::AttrsOwner for StructDef {}
148impl ast::DocCommentsOwner for StructDef {}
149impl StructDef {}
150#[derive(Debug, Clone, PartialEq, Eq, Hash)]
151pub struct UnionDef {
152 pub(crate) syntax: SyntaxNode,
153}
154impl std::fmt::Display for UnionDef {
155 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
156 std::fmt::Display::fmt(self.syntax(), f)
157 }
158}
159impl AstNode for UnionDef {
160 fn can_cast(kind: SyntaxKind) -> bool {
161 match kind {
162 UNION_DEF => true,
163 _ => false,
164 }
165 }
166 fn cast(syntax: SyntaxNode) -> Option<Self> {
167 if Self::can_cast(syntax.kind()) {
168 Some(Self { syntax })
169 } else {
170 None
171 }
172 }
173 fn syntax(&self) -> &SyntaxNode {
174 &self.syntax
175 }
176}
177impl ast::VisibilityOwner for UnionDef {}
178impl ast::NameOwner for UnionDef {}
179impl ast::TypeParamsOwner for UnionDef {}
180impl ast::AttrsOwner for UnionDef {}
181impl ast::DocCommentsOwner for UnionDef {}
182impl UnionDef {
183 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
184 AstChildren::new(&self.syntax).next()
185 }
186}
187#[derive(Debug, Clone, PartialEq, Eq, Hash)]
188pub struct RecordFieldDefList {
189 pub(crate) syntax: SyntaxNode,
190}
191impl std::fmt::Display for RecordFieldDefList {
192 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
193 std::fmt::Display::fmt(self.syntax(), f)
194 }
195}
196impl AstNode for RecordFieldDefList {
197 fn can_cast(kind: SyntaxKind) -> bool {
198 match kind {
199 RECORD_FIELD_DEF_LIST => true,
200 _ => false,
201 }
202 }
203 fn cast(syntax: SyntaxNode) -> Option<Self> {
204 if Self::can_cast(syntax.kind()) {
205 Some(Self { syntax })
206 } else {
207 None
208 }
209 }
210 fn syntax(&self) -> &SyntaxNode {
211 &self.syntax
212 }
213}
214impl RecordFieldDefList {
215 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
216 AstChildren::new(&self.syntax)
217 }
218}
219#[derive(Debug, Clone, PartialEq, Eq, Hash)]
220pub struct RecordFieldDef {
221 pub(crate) syntax: SyntaxNode,
222}
223impl std::fmt::Display for RecordFieldDef {
224 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
225 std::fmt::Display::fmt(self.syntax(), f)
226 }
227}
228impl AstNode for RecordFieldDef {
229 fn can_cast(kind: SyntaxKind) -> bool {
230 match kind {
231 RECORD_FIELD_DEF => true,
232 _ => false,
233 }
234 }
235 fn cast(syntax: SyntaxNode) -> Option<Self> {
236 if Self::can_cast(syntax.kind()) {
237 Some(Self { syntax })
238 } else {
239 None
240 }
241 }
242 fn syntax(&self) -> &SyntaxNode {
243 &self.syntax
244 }
245}
246impl ast::VisibilityOwner for RecordFieldDef {}
247impl ast::NameOwner for RecordFieldDef {}
248impl ast::AttrsOwner for RecordFieldDef {}
249impl ast::DocCommentsOwner for RecordFieldDef {}
250impl ast::TypeAscriptionOwner for RecordFieldDef {}
251impl RecordFieldDef {}
252#[derive(Debug, Clone, PartialEq, Eq, Hash)]
253pub struct TupleFieldDefList {
254 pub(crate) syntax: SyntaxNode,
255}
256impl std::fmt::Display for TupleFieldDefList {
257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
258 std::fmt::Display::fmt(self.syntax(), f)
259 }
260}
261impl AstNode for TupleFieldDefList {
262 fn can_cast(kind: SyntaxKind) -> bool {
263 match kind {
264 TUPLE_FIELD_DEF_LIST => true,
265 _ => false,
266 }
267 }
268 fn cast(syntax: SyntaxNode) -> Option<Self> {
269 if Self::can_cast(syntax.kind()) {
270 Some(Self { syntax })
271 } else {
272 None
273 }
274 }
275 fn syntax(&self) -> &SyntaxNode {
276 &self.syntax
277 }
278}
279impl TupleFieldDefList {
280 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
281 AstChildren::new(&self.syntax)
282 }
283}
284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
285pub struct TupleFieldDef {
286 pub(crate) syntax: SyntaxNode,
287}
288impl std::fmt::Display for TupleFieldDef {
289 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
290 std::fmt::Display::fmt(self.syntax(), f)
291 }
292}
293impl AstNode for TupleFieldDef {
294 fn can_cast(kind: SyntaxKind) -> bool {
295 match kind {
296 TUPLE_FIELD_DEF => true,
297 _ => false,
298 }
299 }
300 fn cast(syntax: SyntaxNode) -> Option<Self> {
301 if Self::can_cast(syntax.kind()) {
302 Some(Self { syntax })
303 } else {
304 None
305 }
306 }
307 fn syntax(&self) -> &SyntaxNode {
308 &self.syntax
309 }
310}
311impl ast::VisibilityOwner for TupleFieldDef {}
312impl ast::AttrsOwner for TupleFieldDef {}
313impl TupleFieldDef {
314 pub fn type_ref(&self) -> Option<TypeRef> {
315 AstChildren::new(&self.syntax).next()
316 }
317}
318#[derive(Debug, Clone, PartialEq, Eq, Hash)]
319pub struct EnumDef {
320 pub(crate) syntax: SyntaxNode,
321}
322impl std::fmt::Display for EnumDef {
323 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
324 std::fmt::Display::fmt(self.syntax(), f)
325 }
326}
327impl AstNode for EnumDef {
328 fn can_cast(kind: SyntaxKind) -> bool {
329 match kind {
330 ENUM_DEF => true,
331 _ => false,
332 }
333 }
334 fn cast(syntax: SyntaxNode) -> Option<Self> {
335 if Self::can_cast(syntax.kind()) {
336 Some(Self { syntax })
337 } else {
338 None
339 }
340 }
341 fn syntax(&self) -> &SyntaxNode {
342 &self.syntax
343 }
344}
345impl ast::VisibilityOwner for EnumDef {}
346impl ast::NameOwner for EnumDef {}
347impl ast::TypeParamsOwner for EnumDef {}
348impl ast::AttrsOwner for EnumDef {}
349impl ast::DocCommentsOwner for EnumDef {}
350impl EnumDef {
351 pub fn variant_list(&self) -> Option<EnumVariantList> {
352 AstChildren::new(&self.syntax).next()
353 }
354}
355#[derive(Debug, Clone, PartialEq, Eq, Hash)]
356pub struct EnumVariantList {
357 pub(crate) syntax: SyntaxNode,
358}
359impl std::fmt::Display for EnumVariantList {
360 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
361 std::fmt::Display::fmt(self.syntax(), f)
362 }
363}
364impl AstNode for EnumVariantList {
365 fn can_cast(kind: SyntaxKind) -> bool {
366 match kind {
367 ENUM_VARIANT_LIST => true,
368 _ => false,
369 }
370 }
371 fn cast(syntax: SyntaxNode) -> Option<Self> {
372 if Self::can_cast(syntax.kind()) {
373 Some(Self { syntax })
374 } else {
375 None
376 }
377 }
378 fn syntax(&self) -> &SyntaxNode {
379 &self.syntax
380 }
381}
382impl EnumVariantList {
383 pub fn variants(&self) -> AstChildren<EnumVariant> {
384 AstChildren::new(&self.syntax)
385 }
386}
387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
388pub struct EnumVariant {
389 pub(crate) syntax: SyntaxNode,
390}
391impl std::fmt::Display for EnumVariant {
392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
393 std::fmt::Display::fmt(self.syntax(), f)
394 }
395}
396impl AstNode for EnumVariant {
397 fn can_cast(kind: SyntaxKind) -> bool {
398 match kind {
399 ENUM_VARIANT => true,
400 _ => false,
401 }
402 }
403 fn cast(syntax: SyntaxNode) -> Option<Self> {
404 if Self::can_cast(syntax.kind()) {
405 Some(Self { syntax })
406 } else {
407 None
408 }
409 }
410 fn syntax(&self) -> &SyntaxNode {
411 &self.syntax
412 }
413}
414impl ast::NameOwner for EnumVariant {}
415impl ast::DocCommentsOwner for EnumVariant {}
416impl ast::AttrsOwner for EnumVariant {}
417impl EnumVariant {
418 pub fn expr(&self) -> Option<Expr> {
419 AstChildren::new(&self.syntax).next()
420 }
421}
422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
423pub struct TraitDef {
424 pub(crate) syntax: SyntaxNode,
425}
426impl std::fmt::Display for TraitDef {
427 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
428 std::fmt::Display::fmt(self.syntax(), f)
429 }
430}
431impl AstNode for TraitDef {
432 fn can_cast(kind: SyntaxKind) -> bool {
433 match kind {
434 TRAIT_DEF => true,
435 _ => false,
436 }
437 }
438 fn cast(syntax: SyntaxNode) -> Option<Self> {
439 if Self::can_cast(syntax.kind()) {
440 Some(Self { syntax })
441 } else {
442 None
443 }
444 }
445 fn syntax(&self) -> &SyntaxNode {
446 &self.syntax
447 }
448}
449impl ast::VisibilityOwner for TraitDef {}
450impl ast::NameOwner for TraitDef {}
451impl ast::AttrsOwner for TraitDef {}
452impl ast::DocCommentsOwner for TraitDef {}
453impl ast::TypeParamsOwner for TraitDef {}
454impl ast::TypeBoundsOwner for TraitDef {}
455impl TraitDef {
456 pub fn item_list(&self) -> Option<ItemList> {
457 AstChildren::new(&self.syntax).next()
458 }
459}
460#[derive(Debug, Clone, PartialEq, Eq, Hash)]
461pub struct Module {
462 pub(crate) syntax: SyntaxNode,
463}
464impl std::fmt::Display for Module {
465 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
466 std::fmt::Display::fmt(self.syntax(), f)
467 }
468}
469impl AstNode for Module {
470 fn can_cast(kind: SyntaxKind) -> bool {
471 match kind {
472 MODULE => true,
473 _ => false,
474 }
475 }
476 fn cast(syntax: SyntaxNode) -> Option<Self> {
477 if Self::can_cast(syntax.kind()) {
478 Some(Self { syntax })
479 } else {
480 None
481 }
482 }
483 fn syntax(&self) -> &SyntaxNode {
484 &self.syntax
485 }
486}
487impl ast::VisibilityOwner for Module {}
488impl ast::NameOwner for Module {}
489impl ast::AttrsOwner for Module {}
490impl ast::DocCommentsOwner for Module {}
491impl Module {
492 pub fn item_list(&self) -> Option<ItemList> {
493 AstChildren::new(&self.syntax).next()
494 }
495}
496#[derive(Debug, Clone, PartialEq, Eq, Hash)]
497pub struct ItemList {
498 pub(crate) syntax: SyntaxNode,
499}
500impl std::fmt::Display for ItemList {
501 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
502 std::fmt::Display::fmt(self.syntax(), f)
503 }
504}
505impl AstNode for ItemList {
506 fn can_cast(kind: SyntaxKind) -> bool {
507 match kind {
508 ITEM_LIST => true,
509 _ => false,
510 }
511 }
512 fn cast(syntax: SyntaxNode) -> Option<Self> {
513 if Self::can_cast(syntax.kind()) {
514 Some(Self { syntax })
515 } else {
516 None
517 }
518 }
519 fn syntax(&self) -> &SyntaxNode {
520 &self.syntax
521 }
522}
523impl ast::FnDefOwner for ItemList {}
524impl ast::ModuleItemOwner for ItemList {}
525impl ItemList {
526 pub fn impl_items(&self) -> AstChildren<ImplItem> {
527 AstChildren::new(&self.syntax)
528 }
529}
530#[derive(Debug, Clone, PartialEq, Eq, Hash)]
531pub struct ConstDef {
532 pub(crate) syntax: SyntaxNode,
533}
534impl std::fmt::Display for ConstDef {
535 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
536 std::fmt::Display::fmt(self.syntax(), f)
537 }
538}
539impl AstNode for ConstDef {
540 fn can_cast(kind: SyntaxKind) -> bool {
541 match kind {
542 CONST_DEF => true,
543 _ => false,
544 }
545 }
546 fn cast(syntax: SyntaxNode) -> Option<Self> {
547 if Self::can_cast(syntax.kind()) {
548 Some(Self { syntax })
549 } else {
550 None
551 }
552 }
553 fn syntax(&self) -> &SyntaxNode {
554 &self.syntax
555 }
556}
557impl ast::VisibilityOwner for ConstDef {}
558impl ast::NameOwner for ConstDef {}
559impl ast::TypeParamsOwner for ConstDef {}
560impl ast::AttrsOwner for ConstDef {}
561impl ast::DocCommentsOwner for ConstDef {}
562impl ast::TypeAscriptionOwner for ConstDef {}
563impl ConstDef {
564 pub fn body(&self) -> Option<Expr> {
565 AstChildren::new(&self.syntax).next()
566 }
567}
568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
569pub struct StaticDef {
570 pub(crate) syntax: SyntaxNode,
571}
572impl std::fmt::Display for StaticDef {
573 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
574 std::fmt::Display::fmt(self.syntax(), f)
575 }
576}
577impl AstNode for StaticDef {
578 fn can_cast(kind: SyntaxKind) -> bool {
579 match kind {
580 STATIC_DEF => true,
581 _ => false,
582 }
583 }
584 fn cast(syntax: SyntaxNode) -> Option<Self> {
585 if Self::can_cast(syntax.kind()) {
586 Some(Self { syntax })
587 } else {
588 None
589 }
590 }
591 fn syntax(&self) -> &SyntaxNode {
592 &self.syntax
593 }
594}
595impl ast::VisibilityOwner for StaticDef {}
596impl ast::NameOwner for StaticDef {}
597impl ast::TypeParamsOwner for StaticDef {}
598impl ast::AttrsOwner for StaticDef {}
599impl ast::DocCommentsOwner for StaticDef {}
600impl ast::TypeAscriptionOwner for StaticDef {}
601impl StaticDef {
602 pub fn body(&self) -> Option<Expr> {
603 AstChildren::new(&self.syntax).next()
604 }
605}
606#[derive(Debug, Clone, PartialEq, Eq, Hash)]
607pub struct TypeAliasDef {
608 pub(crate) syntax: SyntaxNode,
609}
610impl std::fmt::Display for TypeAliasDef {
611 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
612 std::fmt::Display::fmt(self.syntax(), f)
613 }
614}
615impl AstNode for TypeAliasDef {
616 fn can_cast(kind: SyntaxKind) -> bool {
617 match kind {
618 TYPE_ALIAS_DEF => true,
619 _ => false,
620 }
621 }
622 fn cast(syntax: SyntaxNode) -> Option<Self> {
623 if Self::can_cast(syntax.kind()) {
624 Some(Self { syntax })
625 } else {
626 None
627 }
628 }
629 fn syntax(&self) -> &SyntaxNode {
630 &self.syntax
631 }
632}
633impl ast::VisibilityOwner for TypeAliasDef {}
634impl ast::NameOwner for TypeAliasDef {}
635impl ast::TypeParamsOwner for TypeAliasDef {}
636impl ast::AttrsOwner for TypeAliasDef {}
637impl ast::DocCommentsOwner for TypeAliasDef {}
638impl ast::TypeBoundsOwner for TypeAliasDef {}
639impl TypeAliasDef {
640 pub fn type_ref(&self) -> Option<TypeRef> {
641 AstChildren::new(&self.syntax).next()
642 }
643}
644#[derive(Debug, Clone, PartialEq, Eq, Hash)]
645pub struct ImplDef {
646 pub(crate) syntax: SyntaxNode,
647}
648impl std::fmt::Display for ImplDef {
649 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
650 std::fmt::Display::fmt(self.syntax(), f)
651 }
652}
653impl AstNode for ImplDef {
654 fn can_cast(kind: SyntaxKind) -> bool {
655 match kind {
656 IMPL_DEF => true,
657 _ => false,
658 }
659 }
660 fn cast(syntax: SyntaxNode) -> Option<Self> {
661 if Self::can_cast(syntax.kind()) {
662 Some(Self { syntax })
663 } else {
664 None
665 }
666 }
667 fn syntax(&self) -> &SyntaxNode {
668 &self.syntax
669 }
670}
671impl ast::TypeParamsOwner for ImplDef {}
672impl ast::AttrsOwner for ImplDef {}
673impl ImplDef {
674 pub fn item_list(&self) -> Option<ItemList> {
675 AstChildren::new(&self.syntax).next()
676 }
677}
678#[derive(Debug, Clone, PartialEq, Eq, Hash)]
679pub struct ParenType {
680 pub(crate) syntax: SyntaxNode,
681}
682impl std::fmt::Display for ParenType {
683 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
684 std::fmt::Display::fmt(self.syntax(), f)
685 }
686}
687impl AstNode for ParenType {
688 fn can_cast(kind: SyntaxKind) -> bool {
689 match kind {
690 PAREN_TYPE => true,
691 _ => false,
692 }
693 }
694 fn cast(syntax: SyntaxNode) -> Option<Self> {
695 if Self::can_cast(syntax.kind()) {
696 Some(Self { syntax })
697 } else {
698 None
699 }
700 }
701 fn syntax(&self) -> &SyntaxNode {
702 &self.syntax
703 }
704}
705impl ParenType {
706 pub fn type_ref(&self) -> Option<TypeRef> {
707 AstChildren::new(&self.syntax).next()
708 }
709}
710#[derive(Debug, Clone, PartialEq, Eq, Hash)]
711pub struct TupleType {
712 pub(crate) syntax: SyntaxNode,
713}
714impl std::fmt::Display for TupleType {
715 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
716 std::fmt::Display::fmt(self.syntax(), f)
717 }
718}
719impl AstNode for TupleType {
720 fn can_cast(kind: SyntaxKind) -> bool {
721 match kind {
722 TUPLE_TYPE => true,
723 _ => false,
724 }
725 }
726 fn cast(syntax: SyntaxNode) -> Option<Self> {
727 if Self::can_cast(syntax.kind()) {
728 Some(Self { syntax })
729 } else {
730 None
731 }
732 }
733 fn syntax(&self) -> &SyntaxNode {
734 &self.syntax
735 }
736}
737impl TupleType {
738 pub fn fields(&self) -> AstChildren<TypeRef> {
739 AstChildren::new(&self.syntax)
740 }
741}
742#[derive(Debug, Clone, PartialEq, Eq, Hash)]
743pub struct NeverType {
744 pub(crate) syntax: SyntaxNode,
745}
746impl std::fmt::Display for NeverType {
747 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
748 std::fmt::Display::fmt(self.syntax(), f)
749 }
750}
751impl AstNode for NeverType {
752 fn can_cast(kind: SyntaxKind) -> bool {
753 match kind {
754 NEVER_TYPE => true,
755 _ => false,
756 }
757 }
758 fn cast(syntax: SyntaxNode) -> Option<Self> {
759 if Self::can_cast(syntax.kind()) {
760 Some(Self { syntax })
761 } else {
762 None
763 }
764 }
765 fn syntax(&self) -> &SyntaxNode {
766 &self.syntax
767 }
768}
769impl NeverType {}
770#[derive(Debug, Clone, PartialEq, Eq, Hash)]
771pub struct PathType {
772 pub(crate) syntax: SyntaxNode,
773}
774impl std::fmt::Display for PathType {
775 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
776 std::fmt::Display::fmt(self.syntax(), f)
777 }
778}
779impl AstNode for PathType {
780 fn can_cast(kind: SyntaxKind) -> bool {
781 match kind {
782 PATH_TYPE => true,
783 _ => false,
784 }
785 }
786 fn cast(syntax: SyntaxNode) -> Option<Self> {
787 if Self::can_cast(syntax.kind()) {
788 Some(Self { syntax })
789 } else {
790 None
791 }
792 }
793 fn syntax(&self) -> &SyntaxNode {
794 &self.syntax
795 }
796}
797impl PathType {
798 pub fn path(&self) -> Option<Path> {
799 AstChildren::new(&self.syntax).next()
800 }
801}
802#[derive(Debug, Clone, PartialEq, Eq, Hash)]
803pub struct PointerType {
804 pub(crate) syntax: SyntaxNode,
805}
806impl std::fmt::Display for PointerType {
807 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
808 std::fmt::Display::fmt(self.syntax(), f)
809 }
810}
811impl AstNode for PointerType {
812 fn can_cast(kind: SyntaxKind) -> bool {
813 match kind {
814 POINTER_TYPE => true,
815 _ => false,
816 }
817 }
818 fn cast(syntax: SyntaxNode) -> Option<Self> {
819 if Self::can_cast(syntax.kind()) {
820 Some(Self { syntax })
821 } else {
822 None
823 }
824 }
825 fn syntax(&self) -> &SyntaxNode {
826 &self.syntax
827 }
828}
829impl PointerType {
830 pub fn type_ref(&self) -> Option<TypeRef> {
831 AstChildren::new(&self.syntax).next()
832 }
833}
834#[derive(Debug, Clone, PartialEq, Eq, Hash)]
835pub struct ArrayType {
836 pub(crate) syntax: SyntaxNode,
837}
838impl std::fmt::Display for ArrayType {
839 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
840 std::fmt::Display::fmt(self.syntax(), f)
841 }
842}
843impl AstNode for ArrayType {
844 fn can_cast(kind: SyntaxKind) -> bool {
845 match kind {
846 ARRAY_TYPE => true,
847 _ => false,
848 }
849 }
850 fn cast(syntax: SyntaxNode) -> Option<Self> {
851 if Self::can_cast(syntax.kind()) {
852 Some(Self { syntax })
853 } else {
854 None
855 }
856 }
857 fn syntax(&self) -> &SyntaxNode {
858 &self.syntax
859 }
860}
861impl ArrayType {
862 pub fn type_ref(&self) -> Option<TypeRef> {
863 AstChildren::new(&self.syntax).next()
864 }
865 pub fn expr(&self) -> Option<Expr> {
866 AstChildren::new(&self.syntax).next()
867 }
868}
869#[derive(Debug, Clone, PartialEq, Eq, Hash)]
870pub struct SliceType {
871 pub(crate) syntax: SyntaxNode,
872}
873impl std::fmt::Display for SliceType {
874 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
875 std::fmt::Display::fmt(self.syntax(), f)
876 }
877}
878impl AstNode for SliceType {
879 fn can_cast(kind: SyntaxKind) -> bool {
880 match kind {
881 SLICE_TYPE => true,
882 _ => false,
883 }
884 }
885 fn cast(syntax: SyntaxNode) -> Option<Self> {
886 if Self::can_cast(syntax.kind()) {
887 Some(Self { syntax })
888 } else {
889 None
890 }
891 }
892 fn syntax(&self) -> &SyntaxNode {
893 &self.syntax
894 }
895}
896impl SliceType {
897 pub fn type_ref(&self) -> Option<TypeRef> {
898 AstChildren::new(&self.syntax).next()
899 }
900}
901#[derive(Debug, Clone, PartialEq, Eq, Hash)]
902pub struct ReferenceType {
903 pub(crate) syntax: SyntaxNode,
904}
905impl std::fmt::Display for ReferenceType {
906 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
907 std::fmt::Display::fmt(self.syntax(), f)
908 }
909}
910impl AstNode for ReferenceType {
911 fn can_cast(kind: SyntaxKind) -> bool {
912 match kind {
913 REFERENCE_TYPE => true,
914 _ => false,
915 }
916 }
917 fn cast(syntax: SyntaxNode) -> Option<Self> {
918 if Self::can_cast(syntax.kind()) {
919 Some(Self { syntax })
920 } else {
921 None
922 }
923 }
924 fn syntax(&self) -> &SyntaxNode {
925 &self.syntax
926 }
927}
928impl ReferenceType {
929 pub fn type_ref(&self) -> Option<TypeRef> {
930 AstChildren::new(&self.syntax).next()
931 }
932}
933#[derive(Debug, Clone, PartialEq, Eq, Hash)]
934pub struct PlaceholderType {
935 pub(crate) syntax: SyntaxNode,
936}
937impl std::fmt::Display for PlaceholderType {
938 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
939 std::fmt::Display::fmt(self.syntax(), f)
940 }
941}
942impl AstNode for PlaceholderType {
943 fn can_cast(kind: SyntaxKind) -> bool {
944 match kind {
945 PLACEHOLDER_TYPE => true,
946 _ => false,
947 }
948 }
949 fn cast(syntax: SyntaxNode) -> Option<Self> {
950 if Self::can_cast(syntax.kind()) {
951 Some(Self { syntax })
952 } else {
953 None
954 }
955 }
956 fn syntax(&self) -> &SyntaxNode {
957 &self.syntax
958 }
959}
960impl PlaceholderType {}
961#[derive(Debug, Clone, PartialEq, Eq, Hash)]
962pub struct FnPointerType {
963 pub(crate) syntax: SyntaxNode,
964}
965impl std::fmt::Display for FnPointerType {
966 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
967 std::fmt::Display::fmt(self.syntax(), f)
968 }
969}
970impl AstNode for FnPointerType {
971 fn can_cast(kind: SyntaxKind) -> bool {
972 match kind {
973 FN_POINTER_TYPE => true,
974 _ => false,
975 }
976 }
977 fn cast(syntax: SyntaxNode) -> Option<Self> {
978 if Self::can_cast(syntax.kind()) {
979 Some(Self { syntax })
980 } else {
981 None
982 }
983 }
984 fn syntax(&self) -> &SyntaxNode {
985 &self.syntax
986 }
987}
988impl FnPointerType {
989 pub fn param_list(&self) -> Option<ParamList> {
990 AstChildren::new(&self.syntax).next()
991 }
992 pub fn ret_type(&self) -> Option<RetType> {
993 AstChildren::new(&self.syntax).next()
994 }
995}
996#[derive(Debug, Clone, PartialEq, Eq, Hash)]
997pub struct ForType {
998 pub(crate) syntax: SyntaxNode,
999}
1000impl std::fmt::Display for ForType {
1001 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1002 std::fmt::Display::fmt(self.syntax(), f)
1003 }
1004}
1005impl AstNode for ForType {
1006 fn can_cast(kind: SyntaxKind) -> bool {
1007 match kind {
1008 FOR_TYPE => true,
1009 _ => false,
1010 }
1011 }
1012 fn cast(syntax: SyntaxNode) -> Option<Self> {
1013 if Self::can_cast(syntax.kind()) {
1014 Some(Self { syntax })
1015 } else {
1016 None
1017 }
1018 }
1019 fn syntax(&self) -> &SyntaxNode {
1020 &self.syntax
1021 }
1022}
1023impl ForType {
1024 pub fn type_ref(&self) -> Option<TypeRef> {
1025 AstChildren::new(&self.syntax).next()
1026 }
1027}
1028#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1029pub struct ImplTraitType {
1030 pub(crate) syntax: SyntaxNode,
1031}
1032impl std::fmt::Display for ImplTraitType {
1033 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1034 std::fmt::Display::fmt(self.syntax(), f)
1035 }
1036}
1037impl AstNode for ImplTraitType {
1038 fn can_cast(kind: SyntaxKind) -> bool {
1039 match kind {
1040 IMPL_TRAIT_TYPE => true,
1041 _ => false,
1042 }
1043 }
1044 fn cast(syntax: SyntaxNode) -> Option<Self> {
1045 if Self::can_cast(syntax.kind()) {
1046 Some(Self { syntax })
1047 } else {
1048 None
1049 }
1050 }
1051 fn syntax(&self) -> &SyntaxNode {
1052 &self.syntax
1053 }
1054}
1055impl ast::TypeBoundsOwner for ImplTraitType {}
1056impl ImplTraitType {}
1057#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1058pub struct DynTraitType {
1059 pub(crate) syntax: SyntaxNode,
1060}
1061impl std::fmt::Display for DynTraitType {
1062 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1063 std::fmt::Display::fmt(self.syntax(), f)
1064 }
1065}
1066impl AstNode for DynTraitType {
1067 fn can_cast(kind: SyntaxKind) -> bool {
1068 match kind {
1069 DYN_TRAIT_TYPE => true,
1070 _ => false,
1071 }
1072 }
1073 fn cast(syntax: SyntaxNode) -> Option<Self> {
1074 if Self::can_cast(syntax.kind()) {
1075 Some(Self { syntax })
1076 } else {
1077 None
1078 }
1079 }
1080 fn syntax(&self) -> &SyntaxNode {
1081 &self.syntax
1082 }
1083}
1084impl ast::TypeBoundsOwner for DynTraitType {}
1085impl DynTraitType {}
1086#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1087pub struct TupleExpr {
1088 pub(crate) syntax: SyntaxNode,
1089}
1090impl std::fmt::Display for TupleExpr {
1091 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1092 std::fmt::Display::fmt(self.syntax(), f)
1093 }
1094}
1095impl AstNode for TupleExpr {
1096 fn can_cast(kind: SyntaxKind) -> bool {
1097 match kind {
1098 TUPLE_EXPR => true,
1099 _ => false,
1100 }
1101 }
1102 fn cast(syntax: SyntaxNode) -> Option<Self> {
1103 if Self::can_cast(syntax.kind()) {
1104 Some(Self { syntax })
1105 } else {
1106 None
1107 }
1108 }
1109 fn syntax(&self) -> &SyntaxNode {
1110 &self.syntax
1111 }
1112}
1113impl TupleExpr {
1114 pub fn exprs(&self) -> AstChildren<Expr> {
1115 AstChildren::new(&self.syntax)
1116 }
1117}
1118#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1119pub struct ArrayExpr {
1120 pub(crate) syntax: SyntaxNode,
1121}
1122impl std::fmt::Display for ArrayExpr {
1123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1124 std::fmt::Display::fmt(self.syntax(), f)
1125 }
1126}
1127impl AstNode for ArrayExpr {
1128 fn can_cast(kind: SyntaxKind) -> bool {
1129 match kind {
1130 ARRAY_EXPR => true,
1131 _ => false,
1132 }
1133 }
1134 fn cast(syntax: SyntaxNode) -> Option<Self> {
1135 if Self::can_cast(syntax.kind()) {
1136 Some(Self { syntax })
1137 } else {
1138 None
1139 }
1140 }
1141 fn syntax(&self) -> &SyntaxNode {
1142 &self.syntax
1143 }
1144}
1145impl ArrayExpr {
1146 pub fn exprs(&self) -> AstChildren<Expr> {
1147 AstChildren::new(&self.syntax)
1148 }
1149}
1150#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1151pub struct ParenExpr {
1152 pub(crate) syntax: SyntaxNode,
1153}
1154impl std::fmt::Display for ParenExpr {
1155 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1156 std::fmt::Display::fmt(self.syntax(), f)
1157 }
1158}
1159impl AstNode for ParenExpr {
1160 fn can_cast(kind: SyntaxKind) -> bool {
1161 match kind {
1162 PAREN_EXPR => true,
1163 _ => false,
1164 }
1165 }
1166 fn cast(syntax: SyntaxNode) -> Option<Self> {
1167 if Self::can_cast(syntax.kind()) {
1168 Some(Self { syntax })
1169 } else {
1170 None
1171 }
1172 }
1173 fn syntax(&self) -> &SyntaxNode {
1174 &self.syntax
1175 }
1176}
1177impl ParenExpr {
1178 pub fn expr(&self) -> Option<Expr> {
1179 AstChildren::new(&self.syntax).next()
1180 }
1181}
1182#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1183pub struct PathExpr {
1184 pub(crate) syntax: SyntaxNode,
1185}
1186impl std::fmt::Display for PathExpr {
1187 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1188 std::fmt::Display::fmt(self.syntax(), f)
1189 }
1190}
1191impl AstNode for PathExpr {
1192 fn can_cast(kind: SyntaxKind) -> bool {
1193 match kind {
1194 PATH_EXPR => true,
1195 _ => false,
1196 }
1197 }
1198 fn cast(syntax: SyntaxNode) -> Option<Self> {
1199 if Self::can_cast(syntax.kind()) {
1200 Some(Self { syntax })
1201 } else {
1202 None
1203 }
1204 }
1205 fn syntax(&self) -> &SyntaxNode {
1206 &self.syntax
1207 }
1208}
1209impl PathExpr {
1210 pub fn path(&self) -> Option<Path> {
1211 AstChildren::new(&self.syntax).next()
1212 }
1213}
1214#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1215pub struct LambdaExpr {
1216 pub(crate) syntax: SyntaxNode,
1217}
1218impl std::fmt::Display for LambdaExpr {
1219 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1220 std::fmt::Display::fmt(self.syntax(), f)
1221 }
1222}
1223impl AstNode for LambdaExpr {
1224 fn can_cast(kind: SyntaxKind) -> bool {
1225 match kind {
1226 LAMBDA_EXPR => true,
1227 _ => false,
1228 }
1229 }
1230 fn cast(syntax: SyntaxNode) -> Option<Self> {
1231 if Self::can_cast(syntax.kind()) {
1232 Some(Self { syntax })
1233 } else {
1234 None
1235 }
1236 }
1237 fn syntax(&self) -> &SyntaxNode {
1238 &self.syntax
1239 }
1240}
1241impl LambdaExpr {
1242 pub fn param_list(&self) -> Option<ParamList> {
1243 AstChildren::new(&self.syntax).next()
1244 }
1245 pub fn ret_type(&self) -> Option<RetType> {
1246 AstChildren::new(&self.syntax).next()
1247 }
1248 pub fn body(&self) -> Option<Expr> {
1249 AstChildren::new(&self.syntax).next()
1250 }
1251}
1252#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1253pub struct IfExpr {
1254 pub(crate) syntax: SyntaxNode,
1255}
1256impl std::fmt::Display for IfExpr {
1257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1258 std::fmt::Display::fmt(self.syntax(), f)
1259 }
1260}
1261impl AstNode for IfExpr {
1262 fn can_cast(kind: SyntaxKind) -> bool {
1263 match kind {
1264 IF_EXPR => true,
1265 _ => false,
1266 }
1267 }
1268 fn cast(syntax: SyntaxNode) -> Option<Self> {
1269 if Self::can_cast(syntax.kind()) {
1270 Some(Self { syntax })
1271 } else {
1272 None
1273 }
1274 }
1275 fn syntax(&self) -> &SyntaxNode {
1276 &self.syntax
1277 }
1278}
1279impl IfExpr {
1280 pub fn condition(&self) -> Option<Condition> {
1281 AstChildren::new(&self.syntax).next()
1282 }
1283}
1284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1285pub struct LoopExpr {
1286 pub(crate) syntax: SyntaxNode,
1287}
1288impl std::fmt::Display for LoopExpr {
1289 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1290 std::fmt::Display::fmt(self.syntax(), f)
1291 }
1292}
1293impl AstNode for LoopExpr {
1294 fn can_cast(kind: SyntaxKind) -> bool {
1295 match kind {
1296 LOOP_EXPR => true,
1297 _ => false,
1298 }
1299 }
1300 fn cast(syntax: SyntaxNode) -> Option<Self> {
1301 if Self::can_cast(syntax.kind()) {
1302 Some(Self { syntax })
1303 } else {
1304 None
1305 }
1306 }
1307 fn syntax(&self) -> &SyntaxNode {
1308 &self.syntax
1309 }
1310}
1311impl ast::LoopBodyOwner for LoopExpr {}
1312impl LoopExpr {}
1313#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1314pub struct TryBlockExpr {
1315 pub(crate) syntax: SyntaxNode,
1316}
1317impl std::fmt::Display for TryBlockExpr {
1318 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1319 std::fmt::Display::fmt(self.syntax(), f)
1320 }
1321}
1322impl AstNode for TryBlockExpr {
1323 fn can_cast(kind: SyntaxKind) -> bool {
1324 match kind {
1325 TRY_BLOCK_EXPR => true,
1326 _ => false,
1327 }
1328 }
1329 fn cast(syntax: SyntaxNode) -> Option<Self> {
1330 if Self::can_cast(syntax.kind()) {
1331 Some(Self { syntax })
1332 } else {
1333 None
1334 }
1335 }
1336 fn syntax(&self) -> &SyntaxNode {
1337 &self.syntax
1338 }
1339}
1340impl TryBlockExpr {
1341 pub fn body(&self) -> Option<BlockExpr> {
1342 AstChildren::new(&self.syntax).next()
1343 }
1344}
1345#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1346pub struct ForExpr {
1347 pub(crate) syntax: SyntaxNode,
1348}
1349impl std::fmt::Display for ForExpr {
1350 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1351 std::fmt::Display::fmt(self.syntax(), f)
1352 }
1353}
1354impl AstNode for ForExpr {
1355 fn can_cast(kind: SyntaxKind) -> bool {
1356 match kind {
1357 FOR_EXPR => true,
1358 _ => false,
1359 }
1360 }
1361 fn cast(syntax: SyntaxNode) -> Option<Self> {
1362 if Self::can_cast(syntax.kind()) {
1363 Some(Self { syntax })
1364 } else {
1365 None
1366 }
1367 }
1368 fn syntax(&self) -> &SyntaxNode {
1369 &self.syntax
1370 }
1371}
1372impl ast::LoopBodyOwner for ForExpr {}
1373impl ForExpr {
1374 pub fn pat(&self) -> Option<Pat> {
1375 AstChildren::new(&self.syntax).next()
1376 }
1377 pub fn iterable(&self) -> Option<Expr> {
1378 AstChildren::new(&self.syntax).next()
1379 }
1380}
1381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1382pub struct WhileExpr {
1383 pub(crate) syntax: SyntaxNode,
1384}
1385impl std::fmt::Display for WhileExpr {
1386 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1387 std::fmt::Display::fmt(self.syntax(), f)
1388 }
1389}
1390impl AstNode for WhileExpr {
1391 fn can_cast(kind: SyntaxKind) -> bool {
1392 match kind {
1393 WHILE_EXPR => true,
1394 _ => false,
1395 }
1396 }
1397 fn cast(syntax: SyntaxNode) -> Option<Self> {
1398 if Self::can_cast(syntax.kind()) {
1399 Some(Self { syntax })
1400 } else {
1401 None
1402 }
1403 }
1404 fn syntax(&self) -> &SyntaxNode {
1405 &self.syntax
1406 }
1407}
1408impl ast::LoopBodyOwner for WhileExpr {}
1409impl WhileExpr {
1410 pub fn condition(&self) -> Option<Condition> {
1411 AstChildren::new(&self.syntax).next()
1412 }
1413}
1414#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1415pub struct ContinueExpr {
1416 pub(crate) syntax: SyntaxNode,
1417}
1418impl std::fmt::Display for ContinueExpr {
1419 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1420 std::fmt::Display::fmt(self.syntax(), f)
1421 }
1422}
1423impl AstNode for ContinueExpr {
1424 fn can_cast(kind: SyntaxKind) -> bool {
1425 match kind {
1426 CONTINUE_EXPR => true,
1427 _ => false,
1428 }
1429 }
1430 fn cast(syntax: SyntaxNode) -> Option<Self> {
1431 if Self::can_cast(syntax.kind()) {
1432 Some(Self { syntax })
1433 } else {
1434 None
1435 }
1436 }
1437 fn syntax(&self) -> &SyntaxNode {
1438 &self.syntax
1439 }
1440}
1441impl ContinueExpr {}
1442#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1443pub struct BreakExpr {
1444 pub(crate) syntax: SyntaxNode,
1445}
1446impl std::fmt::Display for BreakExpr {
1447 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1448 std::fmt::Display::fmt(self.syntax(), f)
1449 }
1450}
1451impl AstNode for BreakExpr {
1452 fn can_cast(kind: SyntaxKind) -> bool {
1453 match kind {
1454 BREAK_EXPR => true,
1455 _ => false,
1456 }
1457 }
1458 fn cast(syntax: SyntaxNode) -> Option<Self> {
1459 if Self::can_cast(syntax.kind()) {
1460 Some(Self { syntax })
1461 } else {
1462 None
1463 }
1464 }
1465 fn syntax(&self) -> &SyntaxNode {
1466 &self.syntax
1467 }
1468}
1469impl BreakExpr {
1470 pub fn expr(&self) -> Option<Expr> {
1471 AstChildren::new(&self.syntax).next()
1472 }
1473}
1474#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1475pub struct Label {
1476 pub(crate) syntax: SyntaxNode,
1477}
1478impl std::fmt::Display for Label {
1479 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1480 std::fmt::Display::fmt(self.syntax(), f)
1481 }
1482}
1483impl AstNode for Label {
1484 fn can_cast(kind: SyntaxKind) -> bool {
1485 match kind {
1486 LABEL => true,
1487 _ => false,
1488 }
1489 }
1490 fn cast(syntax: SyntaxNode) -> Option<Self> {
1491 if Self::can_cast(syntax.kind()) {
1492 Some(Self { syntax })
1493 } else {
1494 None
1495 }
1496 }
1497 fn syntax(&self) -> &SyntaxNode {
1498 &self.syntax
1499 }
1500}
1501impl Label {}
1502#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1503pub struct BlockExpr {
1504 pub(crate) syntax: SyntaxNode,
1505}
1506impl std::fmt::Display for BlockExpr {
1507 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1508 std::fmt::Display::fmt(self.syntax(), f)
1509 }
1510}
1511impl AstNode for BlockExpr {
1512 fn can_cast(kind: SyntaxKind) -> bool {
1513 match kind {
1514 BLOCK_EXPR => true,
1515 _ => false,
1516 }
1517 }
1518 fn cast(syntax: SyntaxNode) -> Option<Self> {
1519 if Self::can_cast(syntax.kind()) {
1520 Some(Self { syntax })
1521 } else {
1522 None
1523 }
1524 }
1525 fn syntax(&self) -> &SyntaxNode {
1526 &self.syntax
1527 }
1528}
1529impl BlockExpr {
1530 pub fn block(&self) -> Option<Block> {
1531 AstChildren::new(&self.syntax).next()
1532 }
1533}
1534#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1535pub struct ReturnExpr {
1536 pub(crate) syntax: SyntaxNode,
1537}
1538impl std::fmt::Display for ReturnExpr {
1539 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1540 std::fmt::Display::fmt(self.syntax(), f)
1541 }
1542}
1543impl AstNode for ReturnExpr {
1544 fn can_cast(kind: SyntaxKind) -> bool {
1545 match kind {
1546 RETURN_EXPR => true,
1547 _ => false,
1548 }
1549 }
1550 fn cast(syntax: SyntaxNode) -> Option<Self> {
1551 if Self::can_cast(syntax.kind()) {
1552 Some(Self { syntax })
1553 } else {
1554 None
1555 }
1556 }
1557 fn syntax(&self) -> &SyntaxNode {
1558 &self.syntax
1559 }
1560}
1561impl ReturnExpr {
1562 pub fn expr(&self) -> Option<Expr> {
1563 AstChildren::new(&self.syntax).next()
1564 }
1565}
1566#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1567pub struct CallExpr {
1568 pub(crate) syntax: SyntaxNode,
1569}
1570impl std::fmt::Display for CallExpr {
1571 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1572 std::fmt::Display::fmt(self.syntax(), f)
1573 }
1574}
1575impl AstNode for CallExpr {
1576 fn can_cast(kind: SyntaxKind) -> bool {
1577 match kind {
1578 CALL_EXPR => true,
1579 _ => false,
1580 }
1581 }
1582 fn cast(syntax: SyntaxNode) -> Option<Self> {
1583 if Self::can_cast(syntax.kind()) {
1584 Some(Self { syntax })
1585 } else {
1586 None
1587 }
1588 }
1589 fn syntax(&self) -> &SyntaxNode {
1590 &self.syntax
1591 }
1592}
1593impl ast::ArgListOwner for CallExpr {}
1594impl CallExpr {
1595 pub fn expr(&self) -> Option<Expr> {
1596 AstChildren::new(&self.syntax).next()
1597 }
1598}
1599#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1600pub struct MethodCallExpr {
1601 pub(crate) syntax: SyntaxNode,
1602}
1603impl std::fmt::Display for MethodCallExpr {
1604 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1605 std::fmt::Display::fmt(self.syntax(), f)
1606 }
1607}
1608impl AstNode for MethodCallExpr {
1609 fn can_cast(kind: SyntaxKind) -> bool {
1610 match kind {
1611 METHOD_CALL_EXPR => true,
1612 _ => false,
1613 }
1614 }
1615 fn cast(syntax: SyntaxNode) -> Option<Self> {
1616 if Self::can_cast(syntax.kind()) {
1617 Some(Self { syntax })
1618 } else {
1619 None
1620 }
1621 }
1622 fn syntax(&self) -> &SyntaxNode {
1623 &self.syntax
1624 }
1625}
1626impl ast::ArgListOwner for MethodCallExpr {}
1627impl MethodCallExpr {
1628 pub fn expr(&self) -> Option<Expr> {
1629 AstChildren::new(&self.syntax).next()
1630 }
1631 pub fn name_ref(&self) -> Option<NameRef> {
1632 AstChildren::new(&self.syntax).next()
1633 }
1634 pub fn type_arg_list(&self) -> Option<TypeArgList> {
1635 AstChildren::new(&self.syntax).next()
1636 }
1637}
1638#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1639pub struct IndexExpr {
1640 pub(crate) syntax: SyntaxNode,
1641}
1642impl std::fmt::Display for IndexExpr {
1643 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1644 std::fmt::Display::fmt(self.syntax(), f)
1645 }
1646}
1647impl AstNode for IndexExpr {
1648 fn can_cast(kind: SyntaxKind) -> bool {
1649 match kind {
1650 INDEX_EXPR => true,
1651 _ => false,
1652 }
1653 }
1654 fn cast(syntax: SyntaxNode) -> Option<Self> {
1655 if Self::can_cast(syntax.kind()) {
1656 Some(Self { syntax })
1657 } else {
1658 None
1659 }
1660 }
1661 fn syntax(&self) -> &SyntaxNode {
1662 &self.syntax
1663 }
1664}
1665impl IndexExpr {}
1666#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1667pub struct FieldExpr {
1668 pub(crate) syntax: SyntaxNode,
1669}
1670impl std::fmt::Display for FieldExpr {
1671 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1672 std::fmt::Display::fmt(self.syntax(), f)
1673 }
1674}
1675impl AstNode for FieldExpr {
1676 fn can_cast(kind: SyntaxKind) -> bool {
1677 match kind {
1678 FIELD_EXPR => true,
1679 _ => false,
1680 }
1681 }
1682 fn cast(syntax: SyntaxNode) -> Option<Self> {
1683 if Self::can_cast(syntax.kind()) {
1684 Some(Self { syntax })
1685 } else {
1686 None
1687 }
1688 }
1689 fn syntax(&self) -> &SyntaxNode {
1690 &self.syntax
1691 }
1692}
1693impl FieldExpr {
1694 pub fn expr(&self) -> Option<Expr> {
1695 AstChildren::new(&self.syntax).next()
1696 }
1697 pub fn name_ref(&self) -> Option<NameRef> {
1698 AstChildren::new(&self.syntax).next()
1699 }
1700}
1701#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1702pub struct AwaitExpr {
1703 pub(crate) syntax: SyntaxNode,
1704}
1705impl std::fmt::Display for AwaitExpr {
1706 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1707 std::fmt::Display::fmt(self.syntax(), f)
1708 }
1709}
1710impl AstNode for AwaitExpr {
1711 fn can_cast(kind: SyntaxKind) -> bool {
1712 match kind {
1713 AWAIT_EXPR => true,
1714 _ => false,
1715 }
1716 }
1717 fn cast(syntax: SyntaxNode) -> Option<Self> {
1718 if Self::can_cast(syntax.kind()) {
1719 Some(Self { syntax })
1720 } else {
1721 None
1722 }
1723 }
1724 fn syntax(&self) -> &SyntaxNode {
1725 &self.syntax
1726 }
1727}
1728impl AwaitExpr {
1729 pub fn expr(&self) -> Option<Expr> {
1730 AstChildren::new(&self.syntax).next()
1731 }
1732}
1733#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1734pub struct TryExpr {
1735 pub(crate) syntax: SyntaxNode,
1736}
1737impl std::fmt::Display for TryExpr {
1738 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1739 std::fmt::Display::fmt(self.syntax(), f)
1740 }
1741}
1742impl AstNode for TryExpr {
1743 fn can_cast(kind: SyntaxKind) -> bool {
1744 match kind {
1745 TRY_EXPR => true,
1746 _ => false,
1747 }
1748 }
1749 fn cast(syntax: SyntaxNode) -> Option<Self> {
1750 if Self::can_cast(syntax.kind()) {
1751 Some(Self { syntax })
1752 } else {
1753 None
1754 }
1755 }
1756 fn syntax(&self) -> &SyntaxNode {
1757 &self.syntax
1758 }
1759}
1760impl TryExpr {
1761 pub fn expr(&self) -> Option<Expr> {
1762 AstChildren::new(&self.syntax).next()
1763 }
1764}
1765#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1766pub struct CastExpr {
1767 pub(crate) syntax: SyntaxNode,
1768}
1769impl std::fmt::Display for CastExpr {
1770 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1771 std::fmt::Display::fmt(self.syntax(), f)
1772 }
1773}
1774impl AstNode for CastExpr {
1775 fn can_cast(kind: SyntaxKind) -> bool {
1776 match kind {
1777 CAST_EXPR => true,
1778 _ => false,
1779 }
1780 }
1781 fn cast(syntax: SyntaxNode) -> Option<Self> {
1782 if Self::can_cast(syntax.kind()) {
1783 Some(Self { syntax })
1784 } else {
1785 None
1786 }
1787 }
1788 fn syntax(&self) -> &SyntaxNode {
1789 &self.syntax
1790 }
1791}
1792impl CastExpr {
1793 pub fn expr(&self) -> Option<Expr> {
1794 AstChildren::new(&self.syntax).next()
1795 }
1796 pub fn type_ref(&self) -> Option<TypeRef> {
1797 AstChildren::new(&self.syntax).next()
1798 }
1799}
1800#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1801pub struct RefExpr {
1802 pub(crate) syntax: SyntaxNode,
1803}
1804impl std::fmt::Display for RefExpr {
1805 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1806 std::fmt::Display::fmt(self.syntax(), f)
1807 }
1808}
1809impl AstNode for RefExpr {
1810 fn can_cast(kind: SyntaxKind) -> bool {
1811 match kind {
1812 REF_EXPR => true,
1813 _ => false,
1814 }
1815 }
1816 fn cast(syntax: SyntaxNode) -> Option<Self> {
1817 if Self::can_cast(syntax.kind()) {
1818 Some(Self { syntax })
1819 } else {
1820 None
1821 }
1822 }
1823 fn syntax(&self) -> &SyntaxNode {
1824 &self.syntax
1825 }
1826}
1827impl RefExpr {
1828 pub fn expr(&self) -> Option<Expr> {
1829 AstChildren::new(&self.syntax).next()
1830 }
1831}
1832#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1833pub struct PrefixExpr {
1834 pub(crate) syntax: SyntaxNode,
1835}
1836impl std::fmt::Display for PrefixExpr {
1837 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1838 std::fmt::Display::fmt(self.syntax(), f)
1839 }
1840}
1841impl AstNode for PrefixExpr {
1842 fn can_cast(kind: SyntaxKind) -> bool {
1843 match kind {
1844 PREFIX_EXPR => true,
1845 _ => false,
1846 }
1847 }
1848 fn cast(syntax: SyntaxNode) -> Option<Self> {
1849 if Self::can_cast(syntax.kind()) {
1850 Some(Self { syntax })
1851 } else {
1852 None
1853 }
1854 }
1855 fn syntax(&self) -> &SyntaxNode {
1856 &self.syntax
1857 }
1858}
1859impl PrefixExpr {
1860 pub fn expr(&self) -> Option<Expr> {
1861 AstChildren::new(&self.syntax).next()
1862 }
1863}
1864#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1865pub struct BoxExpr {
1866 pub(crate) syntax: SyntaxNode,
1867}
1868impl std::fmt::Display for BoxExpr {
1869 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1870 std::fmt::Display::fmt(self.syntax(), f)
1871 }
1872}
1873impl AstNode for BoxExpr {
1874 fn can_cast(kind: SyntaxKind) -> bool {
1875 match kind {
1876 BOX_EXPR => true,
1877 _ => false,
1878 }
1879 }
1880 fn cast(syntax: SyntaxNode) -> Option<Self> {
1881 if Self::can_cast(syntax.kind()) {
1882 Some(Self { syntax })
1883 } else {
1884 None
1885 }
1886 }
1887 fn syntax(&self) -> &SyntaxNode {
1888 &self.syntax
1889 }
1890}
1891impl BoxExpr {
1892 pub fn expr(&self) -> Option<Expr> {
1893 AstChildren::new(&self.syntax).next()
1894 }
1895}
1896#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1897pub struct RangeExpr {
1898 pub(crate) syntax: SyntaxNode,
1899}
1900impl std::fmt::Display for RangeExpr {
1901 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1902 std::fmt::Display::fmt(self.syntax(), f)
1903 }
1904}
1905impl AstNode for RangeExpr {
1906 fn can_cast(kind: SyntaxKind) -> bool {
1907 match kind {
1908 RANGE_EXPR => true,
1909 _ => false,
1910 }
1911 }
1912 fn cast(syntax: SyntaxNode) -> Option<Self> {
1913 if Self::can_cast(syntax.kind()) {
1914 Some(Self { syntax })
1915 } else {
1916 None
1917 }
1918 }
1919 fn syntax(&self) -> &SyntaxNode {
1920 &self.syntax
1921 }
1922}
1923impl RangeExpr {}
1924#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1925pub struct BinExpr {
1926 pub(crate) syntax: SyntaxNode,
1927}
1928impl std::fmt::Display for BinExpr {
1929 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1930 std::fmt::Display::fmt(self.syntax(), f)
1931 }
1932}
1933impl AstNode for BinExpr {
1934 fn can_cast(kind: SyntaxKind) -> bool {
1935 match kind {
1936 BIN_EXPR => true,
1937 _ => false,
1938 }
1939 }
1940 fn cast(syntax: SyntaxNode) -> Option<Self> {
1941 if Self::can_cast(syntax.kind()) {
1942 Some(Self { syntax })
1943 } else {
1944 None
1945 }
1946 }
1947 fn syntax(&self) -> &SyntaxNode {
1948 &self.syntax
1949 }
1950}
1951impl BinExpr {}
1952#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1953pub struct Literal {
1954 pub(crate) syntax: SyntaxNode,
1955}
1956impl std::fmt::Display for Literal {
1957 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1958 std::fmt::Display::fmt(self.syntax(), f)
1959 }
1960}
1961impl AstNode for Literal {
1962 fn can_cast(kind: SyntaxKind) -> bool {
1963 match kind {
1964 LITERAL => true,
1965 _ => false,
1966 }
1967 }
1968 fn cast(syntax: SyntaxNode) -> Option<Self> {
1969 if Self::can_cast(syntax.kind()) {
1970 Some(Self { syntax })
1971 } else {
1972 None
1973 }
1974 }
1975 fn syntax(&self) -> &SyntaxNode {
1976 &self.syntax
1977 }
1978}
1979impl Literal {}
1980#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1981pub struct MatchExpr {
1982 pub(crate) syntax: SyntaxNode,
1983}
1984impl std::fmt::Display for MatchExpr {
1985 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1986 std::fmt::Display::fmt(self.syntax(), f)
1987 }
1988}
1989impl AstNode for MatchExpr {
1990 fn can_cast(kind: SyntaxKind) -> bool {
1991 match kind {
1992 MATCH_EXPR => true,
1993 _ => false,
1994 }
1995 }
1996 fn cast(syntax: SyntaxNode) -> Option<Self> {
1997 if Self::can_cast(syntax.kind()) {
1998 Some(Self { syntax })
1999 } else {
2000 None
2001 }
2002 }
2003 fn syntax(&self) -> &SyntaxNode {
2004 &self.syntax
2005 }
2006}
2007impl MatchExpr {
2008 pub fn expr(&self) -> Option<Expr> {
2009 AstChildren::new(&self.syntax).next()
2010 }
2011 pub fn match_arm_list(&self) -> Option<MatchArmList> {
2012 AstChildren::new(&self.syntax).next()
2013 }
2014}
2015#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2016pub struct MatchArmList {
2017 pub(crate) syntax: SyntaxNode,
2018}
2019impl std::fmt::Display for MatchArmList {
2020 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2021 std::fmt::Display::fmt(self.syntax(), f)
2022 }
2023}
2024impl AstNode for MatchArmList {
2025 fn can_cast(kind: SyntaxKind) -> bool {
2026 match kind {
2027 MATCH_ARM_LIST => true,
2028 _ => false,
2029 }
2030 }
2031 fn cast(syntax: SyntaxNode) -> Option<Self> {
2032 if Self::can_cast(syntax.kind()) {
2033 Some(Self { syntax })
2034 } else {
2035 None
2036 }
2037 }
2038 fn syntax(&self) -> &SyntaxNode {
2039 &self.syntax
2040 }
2041}
2042impl ast::AttrsOwner for MatchArmList {}
2043impl MatchArmList {
2044 pub fn arms(&self) -> AstChildren<MatchArm> {
2045 AstChildren::new(&self.syntax)
2046 }
2047}
2048#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2049pub struct MatchArm {
2050 pub(crate) syntax: SyntaxNode,
2051}
2052impl std::fmt::Display for MatchArm {
2053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2054 std::fmt::Display::fmt(self.syntax(), f)
2055 }
2056}
2057impl AstNode for MatchArm {
2058 fn can_cast(kind: SyntaxKind) -> bool {
2059 match kind {
2060 MATCH_ARM => true,
2061 _ => false,
2062 }
2063 }
2064 fn cast(syntax: SyntaxNode) -> Option<Self> {
2065 if Self::can_cast(syntax.kind()) {
2066 Some(Self { syntax })
2067 } else {
2068 None
2069 }
2070 }
2071 fn syntax(&self) -> &SyntaxNode {
2072 &self.syntax
2073 }
2074}
2075impl ast::AttrsOwner for MatchArm {}
2076impl MatchArm {
2077 pub fn pat(&self) -> Option<Pat> {
2078 AstChildren::new(&self.syntax).next()
2079 }
2080 pub fn guard(&self) -> Option<MatchGuard> {
2081 AstChildren::new(&self.syntax).next()
2082 }
2083 pub fn expr(&self) -> Option<Expr> {
2084 AstChildren::new(&self.syntax).next()
2085 }
2086}
2087#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2088pub struct MatchGuard {
2089 pub(crate) syntax: SyntaxNode,
2090}
2091impl std::fmt::Display for MatchGuard {
2092 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2093 std::fmt::Display::fmt(self.syntax(), f)
2094 }
2095}
2096impl AstNode for MatchGuard {
2097 fn can_cast(kind: SyntaxKind) -> bool {
2098 match kind {
2099 MATCH_GUARD => true,
2100 _ => false,
2101 }
2102 }
2103 fn cast(syntax: SyntaxNode) -> Option<Self> {
2104 if Self::can_cast(syntax.kind()) {
2105 Some(Self { syntax })
2106 } else {
2107 None
2108 }
2109 }
2110 fn syntax(&self) -> &SyntaxNode {
2111 &self.syntax
2112 }
2113}
2114impl MatchGuard {
2115 pub fn expr(&self) -> Option<Expr> {
2116 AstChildren::new(&self.syntax).next()
2117 }
2118}
2119#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2120pub struct RecordLit {
2121 pub(crate) syntax: SyntaxNode,
2122}
2123impl std::fmt::Display for RecordLit {
2124 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2125 std::fmt::Display::fmt(self.syntax(), f)
2126 }
2127}
2128impl AstNode for RecordLit {
2129 fn can_cast(kind: SyntaxKind) -> bool {
2130 match kind {
2131 RECORD_LIT => true,
2132 _ => false,
2133 }
2134 }
2135 fn cast(syntax: SyntaxNode) -> Option<Self> {
2136 if Self::can_cast(syntax.kind()) {
2137 Some(Self { syntax })
2138 } else {
2139 None
2140 }
2141 }
2142 fn syntax(&self) -> &SyntaxNode {
2143 &self.syntax
2144 }
2145}
2146impl RecordLit {
2147 pub fn path(&self) -> Option<Path> {
2148 AstChildren::new(&self.syntax).next()
2149 }
2150 pub fn record_field_list(&self) -> Option<RecordFieldList> {
2151 AstChildren::new(&self.syntax).next()
2152 }
2153}
2154#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2155pub struct RecordFieldList {
2156 pub(crate) syntax: SyntaxNode,
2157}
2158impl std::fmt::Display for RecordFieldList {
2159 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2160 std::fmt::Display::fmt(self.syntax(), f)
2161 }
2162}
2163impl AstNode for RecordFieldList {
2164 fn can_cast(kind: SyntaxKind) -> bool {
2165 match kind {
2166 RECORD_FIELD_LIST => true,
2167 _ => false,
2168 }
2169 }
2170 fn cast(syntax: SyntaxNode) -> Option<Self> {
2171 if Self::can_cast(syntax.kind()) {
2172 Some(Self { syntax })
2173 } else {
2174 None
2175 }
2176 }
2177 fn syntax(&self) -> &SyntaxNode {
2178 &self.syntax
2179 }
2180}
2181impl RecordFieldList {
2182 pub fn fields(&self) -> AstChildren<RecordField> {
2183 AstChildren::new(&self.syntax)
2184 }
2185 pub fn spread(&self) -> Option<Expr> {
2186 AstChildren::new(&self.syntax).next()
2187 }
2188}
2189#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2190pub struct RecordField {
2191 pub(crate) syntax: SyntaxNode,
2192}
2193impl std::fmt::Display for RecordField {
2194 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2195 std::fmt::Display::fmt(self.syntax(), f)
2196 }
2197}
2198impl AstNode for RecordField {
2199 fn can_cast(kind: SyntaxKind) -> bool {
2200 match kind {
2201 RECORD_FIELD => true,
2202 _ => false,
2203 }
2204 }
2205 fn cast(syntax: SyntaxNode) -> Option<Self> {
2206 if Self::can_cast(syntax.kind()) {
2207 Some(Self { syntax })
2208 } else {
2209 None
2210 }
2211 }
2212 fn syntax(&self) -> &SyntaxNode {
2213 &self.syntax
2214 }
2215}
2216impl RecordField {
2217 pub fn name_ref(&self) -> Option<NameRef> {
2218 AstChildren::new(&self.syntax).next()
2219 }
2220 pub fn expr(&self) -> Option<Expr> {
2221 AstChildren::new(&self.syntax).next()
2222 }
2223}
2224#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2225pub struct OrPat {
2226 pub(crate) syntax: SyntaxNode,
2227}
2228impl std::fmt::Display for OrPat {
2229 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2230 std::fmt::Display::fmt(self.syntax(), f)
2231 }
2232}
2233impl AstNode for OrPat {
2234 fn can_cast(kind: SyntaxKind) -> bool {
2235 match kind {
2236 OR_PAT => true,
2237 _ => false,
2238 }
2239 }
2240 fn cast(syntax: SyntaxNode) -> Option<Self> {
2241 if Self::can_cast(syntax.kind()) {
2242 Some(Self { syntax })
2243 } else {
2244 None
2245 }
2246 }
2247 fn syntax(&self) -> &SyntaxNode {
2248 &self.syntax
2249 }
2250}
2251impl OrPat {
2252 pub fn pats(&self) -> AstChildren<Pat> {
2253 AstChildren::new(&self.syntax)
2254 }
2255}
2256#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2257pub struct ParenPat {
2258 pub(crate) syntax: SyntaxNode,
2259}
2260impl std::fmt::Display for ParenPat {
2261 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2262 std::fmt::Display::fmt(self.syntax(), f)
2263 }
2264}
2265impl AstNode for ParenPat {
2266 fn can_cast(kind: SyntaxKind) -> bool {
2267 match kind {
2268 PAREN_PAT => true,
2269 _ => false,
2270 }
2271 }
2272 fn cast(syntax: SyntaxNode) -> Option<Self> {
2273 if Self::can_cast(syntax.kind()) {
2274 Some(Self { syntax })
2275 } else {
2276 None
2277 }
2278 }
2279 fn syntax(&self) -> &SyntaxNode {
2280 &self.syntax
2281 }
2282}
2283impl ParenPat {
2284 pub fn pat(&self) -> Option<Pat> {
2285 AstChildren::new(&self.syntax).next()
2286 }
2287}
2288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2289pub struct RefPat {
2290 pub(crate) syntax: SyntaxNode,
2291}
2292impl std::fmt::Display for RefPat {
2293 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2294 std::fmt::Display::fmt(self.syntax(), f)
2295 }
2296}
2297impl AstNode for RefPat {
2298 fn can_cast(kind: SyntaxKind) -> bool {
2299 match kind {
2300 REF_PAT => true,
2301 _ => false,
2302 }
2303 }
2304 fn cast(syntax: SyntaxNode) -> Option<Self> {
2305 if Self::can_cast(syntax.kind()) {
2306 Some(Self { syntax })
2307 } else {
2308 None
2309 }
2310 }
2311 fn syntax(&self) -> &SyntaxNode {
2312 &self.syntax
2313 }
2314}
2315impl RefPat {
2316 pub fn pat(&self) -> Option<Pat> {
2317 AstChildren::new(&self.syntax).next()
2318 }
2319}
2320#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2321pub struct BoxPat {
2322 pub(crate) syntax: SyntaxNode,
2323}
2324impl std::fmt::Display for BoxPat {
2325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2326 std::fmt::Display::fmt(self.syntax(), f)
2327 }
2328}
2329impl AstNode for BoxPat {
2330 fn can_cast(kind: SyntaxKind) -> bool {
2331 match kind {
2332 BOX_PAT => true,
2333 _ => false,
2334 }
2335 }
2336 fn cast(syntax: SyntaxNode) -> Option<Self> {
2337 if Self::can_cast(syntax.kind()) {
2338 Some(Self { syntax })
2339 } else {
2340 None
2341 }
2342 }
2343 fn syntax(&self) -> &SyntaxNode {
2344 &self.syntax
2345 }
2346}
2347impl BoxPat {
2348 pub fn pat(&self) -> Option<Pat> {
2349 AstChildren::new(&self.syntax).next()
2350 }
2351}
2352#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2353pub struct BindPat {
2354 pub(crate) syntax: SyntaxNode,
2355}
2356impl std::fmt::Display for BindPat {
2357 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2358 std::fmt::Display::fmt(self.syntax(), f)
2359 }
2360}
2361impl AstNode for BindPat {
2362 fn can_cast(kind: SyntaxKind) -> bool {
2363 match kind {
2364 BIND_PAT => true,
2365 _ => false,
2366 }
2367 }
2368 fn cast(syntax: SyntaxNode) -> Option<Self> {
2369 if Self::can_cast(syntax.kind()) {
2370 Some(Self { syntax })
2371 } else {
2372 None
2373 }
2374 }
2375 fn syntax(&self) -> &SyntaxNode {
2376 &self.syntax
2377 }
2378}
2379impl ast::NameOwner for BindPat {}
2380impl BindPat {
2381 pub fn pat(&self) -> Option<Pat> {
2382 AstChildren::new(&self.syntax).next()
2383 }
2384}
2385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2386pub struct PlaceholderPat {
2387 pub(crate) syntax: SyntaxNode,
2388}
2389impl std::fmt::Display for PlaceholderPat {
2390 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2391 std::fmt::Display::fmt(self.syntax(), f)
2392 }
2393}
2394impl AstNode for PlaceholderPat {
2395 fn can_cast(kind: SyntaxKind) -> bool {
2396 match kind {
2397 PLACEHOLDER_PAT => true,
2398 _ => false,
2399 }
2400 }
2401 fn cast(syntax: SyntaxNode) -> Option<Self> {
2402 if Self::can_cast(syntax.kind()) {
2403 Some(Self { syntax })
2404 } else {
2405 None
2406 }
2407 }
2408 fn syntax(&self) -> &SyntaxNode {
2409 &self.syntax
2410 }
2411}
2412impl PlaceholderPat {}
2413#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2414pub struct DotDotPat {
2415 pub(crate) syntax: SyntaxNode,
2416}
2417impl std::fmt::Display for DotDotPat {
2418 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2419 std::fmt::Display::fmt(self.syntax(), f)
2420 }
2421}
2422impl AstNode for DotDotPat {
2423 fn can_cast(kind: SyntaxKind) -> bool {
2424 match kind {
2425 DOT_DOT_PAT => true,
2426 _ => false,
2427 }
2428 }
2429 fn cast(syntax: SyntaxNode) -> Option<Self> {
2430 if Self::can_cast(syntax.kind()) {
2431 Some(Self { syntax })
2432 } else {
2433 None
2434 }
2435 }
2436 fn syntax(&self) -> &SyntaxNode {
2437 &self.syntax
2438 }
2439}
2440impl DotDotPat {}
2441#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2442pub struct PathPat {
2443 pub(crate) syntax: SyntaxNode,
2444}
2445impl std::fmt::Display for PathPat {
2446 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2447 std::fmt::Display::fmt(self.syntax(), f)
2448 }
2449}
2450impl AstNode for PathPat {
2451 fn can_cast(kind: SyntaxKind) -> bool {
2452 match kind {
2453 PATH_PAT => true,
2454 _ => false,
2455 }
2456 }
2457 fn cast(syntax: SyntaxNode) -> Option<Self> {
2458 if Self::can_cast(syntax.kind()) {
2459 Some(Self { syntax })
2460 } else {
2461 None
2462 }
2463 }
2464 fn syntax(&self) -> &SyntaxNode {
2465 &self.syntax
2466 }
2467}
2468impl PathPat {
2469 pub fn path(&self) -> Option<Path> {
2470 AstChildren::new(&self.syntax).next()
2471 }
2472}
2473#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2474pub struct SlicePat {
2475 pub(crate) syntax: SyntaxNode,
2476}
2477impl std::fmt::Display for SlicePat {
2478 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2479 std::fmt::Display::fmt(self.syntax(), f)
2480 }
2481}
2482impl AstNode for SlicePat {
2483 fn can_cast(kind: SyntaxKind) -> bool {
2484 match kind {
2485 SLICE_PAT => true,
2486 _ => false,
2487 }
2488 }
2489 fn cast(syntax: SyntaxNode) -> Option<Self> {
2490 if Self::can_cast(syntax.kind()) {
2491 Some(Self { syntax })
2492 } else {
2493 None
2494 }
2495 }
2496 fn syntax(&self) -> &SyntaxNode {
2497 &self.syntax
2498 }
2499}
2500impl SlicePat {
2501 pub fn args(&self) -> AstChildren<Pat> {
2502 AstChildren::new(&self.syntax)
2503 }
2504}
2505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2506pub struct RangePat {
2507 pub(crate) syntax: SyntaxNode,
2508}
2509impl std::fmt::Display for RangePat {
2510 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2511 std::fmt::Display::fmt(self.syntax(), f)
2512 }
2513}
2514impl AstNode for RangePat {
2515 fn can_cast(kind: SyntaxKind) -> bool {
2516 match kind {
2517 RANGE_PAT => true,
2518 _ => false,
2519 }
2520 }
2521 fn cast(syntax: SyntaxNode) -> Option<Self> {
2522 if Self::can_cast(syntax.kind()) {
2523 Some(Self { syntax })
2524 } else {
2525 None
2526 }
2527 }
2528 fn syntax(&self) -> &SyntaxNode {
2529 &self.syntax
2530 }
2531}
2532impl RangePat {}
2533#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2534pub struct LiteralPat {
2535 pub(crate) syntax: SyntaxNode,
2536}
2537impl std::fmt::Display for LiteralPat {
2538 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2539 std::fmt::Display::fmt(self.syntax(), f)
2540 }
2541}
2542impl AstNode for LiteralPat {
2543 fn can_cast(kind: SyntaxKind) -> bool {
2544 match kind {
2545 LITERAL_PAT => true,
2546 _ => false,
2547 }
2548 }
2549 fn cast(syntax: SyntaxNode) -> Option<Self> {
2550 if Self::can_cast(syntax.kind()) {
2551 Some(Self { syntax })
2552 } else {
2553 None
2554 }
2555 }
2556 fn syntax(&self) -> &SyntaxNode {
2557 &self.syntax
2558 }
2559}
2560impl LiteralPat {
2561 pub fn literal(&self) -> Option<Literal> {
2562 AstChildren::new(&self.syntax).next()
2563 }
2564}
2565#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2566pub struct MacroPat {
2567 pub(crate) syntax: SyntaxNode,
2568}
2569impl std::fmt::Display for MacroPat {
2570 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2571 std::fmt::Display::fmt(self.syntax(), f)
2572 }
2573}
2574impl AstNode for MacroPat {
2575 fn can_cast(kind: SyntaxKind) -> bool {
2576 match kind {
2577 MACRO_PAT => true,
2578 _ => false,
2579 }
2580 }
2581 fn cast(syntax: SyntaxNode) -> Option<Self> {
2582 if Self::can_cast(syntax.kind()) {
2583 Some(Self { syntax })
2584 } else {
2585 None
2586 }
2587 }
2588 fn syntax(&self) -> &SyntaxNode {
2589 &self.syntax
2590 }
2591}
2592impl MacroPat {
2593 pub fn macro_call(&self) -> Option<MacroCall> {
2594 AstChildren::new(&self.syntax).next()
2595 }
2596}
2597#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2598pub struct RecordPat {
2599 pub(crate) syntax: SyntaxNode,
2600}
2601impl std::fmt::Display for RecordPat {
2602 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2603 std::fmt::Display::fmt(self.syntax(), f)
2604 }
2605}
2606impl AstNode for RecordPat {
2607 fn can_cast(kind: SyntaxKind) -> bool {
2608 match kind {
2609 RECORD_PAT => true,
2610 _ => false,
2611 }
2612 }
2613 fn cast(syntax: SyntaxNode) -> Option<Self> {
2614 if Self::can_cast(syntax.kind()) {
2615 Some(Self { syntax })
2616 } else {
2617 None
2618 }
2619 }
2620 fn syntax(&self) -> &SyntaxNode {
2621 &self.syntax
2622 }
2623}
2624impl RecordPat {
2625 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2626 AstChildren::new(&self.syntax).next()
2627 }
2628 pub fn path(&self) -> Option<Path> {
2629 AstChildren::new(&self.syntax).next()
2630 }
2631}
2632#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2633pub struct RecordFieldPatList {
2634 pub(crate) syntax: SyntaxNode,
2635}
2636impl std::fmt::Display for RecordFieldPatList {
2637 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2638 std::fmt::Display::fmt(self.syntax(), f)
2639 }
2640}
2641impl AstNode for RecordFieldPatList {
2642 fn can_cast(kind: SyntaxKind) -> bool {
2643 match kind {
2644 RECORD_FIELD_PAT_LIST => true,
2645 _ => false,
2646 }
2647 }
2648 fn cast(syntax: SyntaxNode) -> Option<Self> {
2649 if Self::can_cast(syntax.kind()) {
2650 Some(Self { syntax })
2651 } else {
2652 None
2653 }
2654 }
2655 fn syntax(&self) -> &SyntaxNode {
2656 &self.syntax
2657 }
2658}
2659impl RecordFieldPatList {
2660 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2661 AstChildren::new(&self.syntax)
2662 }
2663 pub fn bind_pats(&self) -> AstChildren<BindPat> {
2664 AstChildren::new(&self.syntax)
2665 }
2666}
2667#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2668pub struct RecordFieldPat {
2669 pub(crate) syntax: SyntaxNode,
2670}
2671impl std::fmt::Display for RecordFieldPat {
2672 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2673 std::fmt::Display::fmt(self.syntax(), f)
2674 }
2675}
2676impl AstNode for RecordFieldPat {
2677 fn can_cast(kind: SyntaxKind) -> bool {
2678 match kind {
2679 RECORD_FIELD_PAT => true,
2680 _ => false,
2681 }
2682 }
2683 fn cast(syntax: SyntaxNode) -> Option<Self> {
2684 if Self::can_cast(syntax.kind()) {
2685 Some(Self { syntax })
2686 } else {
2687 None
2688 }
2689 }
2690 fn syntax(&self) -> &SyntaxNode {
2691 &self.syntax
2692 }
2693}
2694impl ast::NameOwner for RecordFieldPat {}
2695impl RecordFieldPat {
2696 pub fn pat(&self) -> Option<Pat> {
2697 AstChildren::new(&self.syntax).next()
2698 }
2699}
2700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2701pub struct TupleStructPat {
2702 pub(crate) syntax: SyntaxNode,
2703}
2704impl std::fmt::Display for TupleStructPat {
2705 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2706 std::fmt::Display::fmt(self.syntax(), f)
2707 }
2708}
2709impl AstNode for TupleStructPat {
2710 fn can_cast(kind: SyntaxKind) -> bool {
2711 match kind {
2712 TUPLE_STRUCT_PAT => true,
2713 _ => false,
2714 }
2715 }
2716 fn cast(syntax: SyntaxNode) -> Option<Self> {
2717 if Self::can_cast(syntax.kind()) {
2718 Some(Self { syntax })
2719 } else {
2720 None
2721 }
2722 }
2723 fn syntax(&self) -> &SyntaxNode {
2724 &self.syntax
2725 }
2726}
2727impl TupleStructPat {
2728 pub fn path(&self) -> Option<Path> {
2729 AstChildren::new(&self.syntax).next()
2730 }
2731 pub fn args(&self) -> AstChildren<Pat> {
2732 AstChildren::new(&self.syntax)
2733 }
2734}
2735#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2736pub struct TuplePat {
2737 pub(crate) syntax: SyntaxNode,
2738}
2739impl std::fmt::Display for TuplePat {
2740 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2741 std::fmt::Display::fmt(self.syntax(), f)
2742 }
2743}
2744impl AstNode for TuplePat {
2745 fn can_cast(kind: SyntaxKind) -> bool {
2746 match kind {
2747 TUPLE_PAT => true,
2748 _ => false,
2749 }
2750 }
2751 fn cast(syntax: SyntaxNode) -> Option<Self> {
2752 if Self::can_cast(syntax.kind()) {
2753 Some(Self { syntax })
2754 } else {
2755 None
2756 }
2757 }
2758 fn syntax(&self) -> &SyntaxNode {
2759 &self.syntax
2760 }
2761}
2762impl TuplePat {
2763 pub fn args(&self) -> AstChildren<Pat> {
2764 AstChildren::new(&self.syntax)
2765 }
2766}
2767#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2768pub struct Visibility {
2769 pub(crate) syntax: SyntaxNode,
2770}
2771impl std::fmt::Display for Visibility {
2772 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2773 std::fmt::Display::fmt(self.syntax(), f)
2774 }
2775}
2776impl AstNode for Visibility {
2777 fn can_cast(kind: SyntaxKind) -> bool {
2778 match kind {
2779 VISIBILITY => true,
2780 _ => false,
2781 }
2782 }
2783 fn cast(syntax: SyntaxNode) -> Option<Self> {
2784 if Self::can_cast(syntax.kind()) {
2785 Some(Self { syntax })
2786 } else {
2787 None
2788 }
2789 }
2790 fn syntax(&self) -> &SyntaxNode {
2791 &self.syntax
2792 }
2793}
2794impl Visibility {}
2795#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2796pub struct Name {
2797 pub(crate) syntax: SyntaxNode,
2798}
2799impl std::fmt::Display for Name {
2800 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2801 std::fmt::Display::fmt(self.syntax(), f)
2802 }
2803}
2804impl AstNode for Name {
2805 fn can_cast(kind: SyntaxKind) -> bool {
2806 match kind {
2807 NAME => true,
2808 _ => false,
2809 }
2810 }
2811 fn cast(syntax: SyntaxNode) -> Option<Self> {
2812 if Self::can_cast(syntax.kind()) {
2813 Some(Self { syntax })
2814 } else {
2815 None
2816 }
2817 }
2818 fn syntax(&self) -> &SyntaxNode {
2819 &self.syntax
2820 }
2821}
2822impl Name {}
2823#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2824pub struct NameRef {
2825 pub(crate) syntax: SyntaxNode,
2826}
2827impl std::fmt::Display for NameRef {
2828 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2829 std::fmt::Display::fmt(self.syntax(), f)
2830 }
2831}
2832impl AstNode for NameRef {
2833 fn can_cast(kind: SyntaxKind) -> bool {
2834 match kind {
2835 NAME_REF => true,
2836 _ => false,
2837 }
2838 }
2839 fn cast(syntax: SyntaxNode) -> Option<Self> {
2840 if Self::can_cast(syntax.kind()) {
2841 Some(Self { syntax })
2842 } else {
2843 None
2844 }
2845 }
2846 fn syntax(&self) -> &SyntaxNode {
2847 &self.syntax
2848 }
2849}
2850impl NameRef {}
2851#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2852pub struct MacroCall {
2853 pub(crate) syntax: SyntaxNode,
2854}
2855impl std::fmt::Display for MacroCall {
2856 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2857 std::fmt::Display::fmt(self.syntax(), f)
2858 }
2859}
2860impl AstNode for MacroCall {
2861 fn can_cast(kind: SyntaxKind) -> bool {
2862 match kind {
2863 MACRO_CALL => true,
2864 _ => false,
2865 }
2866 }
2867 fn cast(syntax: SyntaxNode) -> Option<Self> {
2868 if Self::can_cast(syntax.kind()) {
2869 Some(Self { syntax })
2870 } else {
2871 None
2872 }
2873 }
2874 fn syntax(&self) -> &SyntaxNode {
2875 &self.syntax
2876 }
2877}
2878impl ast::NameOwner for MacroCall {}
2879impl ast::AttrsOwner for MacroCall {}
2880impl ast::DocCommentsOwner for MacroCall {}
2881impl MacroCall {
2882 pub fn token_tree(&self) -> Option<TokenTree> {
2883 AstChildren::new(&self.syntax).next()
2884 }
2885 pub fn path(&self) -> Option<Path> {
2886 AstChildren::new(&self.syntax).next()
2887 }
2888}
2889#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2890pub struct Attr {
2891 pub(crate) syntax: SyntaxNode,
2892}
2893impl std::fmt::Display for Attr {
2894 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2895 std::fmt::Display::fmt(self.syntax(), f)
2896 }
2897}
2898impl AstNode for Attr {
2899 fn can_cast(kind: SyntaxKind) -> bool {
2900 match kind {
2901 ATTR => true,
2902 _ => false,
2903 }
2904 }
2905 fn cast(syntax: SyntaxNode) -> Option<Self> {
2906 if Self::can_cast(syntax.kind()) {
2907 Some(Self { syntax })
2908 } else {
2909 None
2910 }
2911 }
2912 fn syntax(&self) -> &SyntaxNode {
2913 &self.syntax
2914 }
2915}
2916impl Attr {
2917 pub fn path(&self) -> Option<Path> {
2918 AstChildren::new(&self.syntax).next()
2919 }
2920 pub fn input(&self) -> Option<AttrInput> {
2921 AstChildren::new(&self.syntax).next()
2922 }
2923}
2924#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2925pub struct TokenTree {
2926 pub(crate) syntax: SyntaxNode,
2927}
2928impl std::fmt::Display for TokenTree {
2929 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2930 std::fmt::Display::fmt(self.syntax(), f)
2931 }
2932}
2933impl AstNode for TokenTree {
2934 fn can_cast(kind: SyntaxKind) -> bool {
2935 match kind {
2936 TOKEN_TREE => true,
2937 _ => false,
2938 }
2939 }
2940 fn cast(syntax: SyntaxNode) -> Option<Self> {
2941 if Self::can_cast(syntax.kind()) {
2942 Some(Self { syntax })
2943 } else {
2944 None
2945 }
2946 }
2947 fn syntax(&self) -> &SyntaxNode {
2948 &self.syntax
2949 }
2950}
2951impl TokenTree {}
2952#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2953pub struct TypeParamList {
2954 pub(crate) syntax: SyntaxNode,
2955}
2956impl std::fmt::Display for TypeParamList {
2957 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2958 std::fmt::Display::fmt(self.syntax(), f)
2959 }
2960}
2961impl AstNode for TypeParamList {
2962 fn can_cast(kind: SyntaxKind) -> bool {
2963 match kind {
2964 TYPE_PARAM_LIST => true,
2965 _ => false,
2966 }
2967 }
2968 fn cast(syntax: SyntaxNode) -> Option<Self> {
2969 if Self::can_cast(syntax.kind()) {
2970 Some(Self { syntax })
2971 } else {
2972 None
2973 }
2974 }
2975 fn syntax(&self) -> &SyntaxNode {
2976 &self.syntax
2977 }
2978}
2979impl TypeParamList {
2980 pub fn type_params(&self) -> AstChildren<TypeParam> {
2981 AstChildren::new(&self.syntax)
2982 }
2983 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
2984 AstChildren::new(&self.syntax)
2985 }
2986}
2987#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2988pub struct TypeParam {
2989 pub(crate) syntax: SyntaxNode,
2990}
2991impl std::fmt::Display for TypeParam {
2992 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2993 std::fmt::Display::fmt(self.syntax(), f)
2994 }
2995}
2996impl AstNode for TypeParam {
2997 fn can_cast(kind: SyntaxKind) -> bool {
2998 match kind {
2999 TYPE_PARAM => true,
3000 _ => false,
3001 }
3002 }
3003 fn cast(syntax: SyntaxNode) -> Option<Self> {
3004 if Self::can_cast(syntax.kind()) {
3005 Some(Self { syntax })
3006 } else {
3007 None
3008 }
3009 }
3010 fn syntax(&self) -> &SyntaxNode {
3011 &self.syntax
3012 }
3013}
3014impl ast::NameOwner for TypeParam {}
3015impl ast::AttrsOwner for TypeParam {}
3016impl ast::TypeBoundsOwner for TypeParam {}
3017impl TypeParam {
3018 pub fn default_type(&self) -> Option<TypeRef> {
3019 AstChildren::new(&self.syntax).next()
3020 }
3021}
3022#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3023pub struct ConstParam {
3024 pub(crate) syntax: SyntaxNode,
3025}
3026impl std::fmt::Display for ConstParam {
3027 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3028 std::fmt::Display::fmt(self.syntax(), f)
3029 }
3030}
3031impl AstNode for ConstParam {
3032 fn can_cast(kind: SyntaxKind) -> bool {
3033 match kind {
3034 CONST_PARAM => true,
3035 _ => false,
3036 }
3037 }
3038 fn cast(syntax: SyntaxNode) -> Option<Self> {
3039 if Self::can_cast(syntax.kind()) {
3040 Some(Self { syntax })
3041 } else {
3042 None
3043 }
3044 }
3045 fn syntax(&self) -> &SyntaxNode {
3046 &self.syntax
3047 }
3048}
3049impl ast::NameOwner for ConstParam {}
3050impl ast::AttrsOwner for ConstParam {}
3051impl ast::TypeAscriptionOwner for ConstParam {}
3052impl ConstParam {
3053 pub fn default_val(&self) -> Option<Expr> {
3054 AstChildren::new(&self.syntax).next()
3055 }
3056}
3057#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3058pub struct LifetimeParam {
3059 pub(crate) syntax: SyntaxNode,
3060}
3061impl std::fmt::Display for LifetimeParam {
3062 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3063 std::fmt::Display::fmt(self.syntax(), f)
3064 }
3065}
3066impl AstNode for LifetimeParam {
3067 fn can_cast(kind: SyntaxKind) -> bool {
3068 match kind {
3069 LIFETIME_PARAM => true,
3070 _ => false,
3071 }
3072 }
3073 fn cast(syntax: SyntaxNode) -> Option<Self> {
3074 if Self::can_cast(syntax.kind()) {
3075 Some(Self { syntax })
3076 } else {
3077 None
3078 }
3079 }
3080 fn syntax(&self) -> &SyntaxNode {
3081 &self.syntax
3082 }
3083}
3084impl ast::AttrsOwner for LifetimeParam {}
3085impl LifetimeParam {}
3086#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3087pub struct TypeBound {
3088 pub(crate) syntax: SyntaxNode,
3089}
3090impl std::fmt::Display for TypeBound {
3091 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3092 std::fmt::Display::fmt(self.syntax(), f)
3093 }
3094}
3095impl AstNode for TypeBound {
3096 fn can_cast(kind: SyntaxKind) -> bool {
3097 match kind {
3098 TYPE_BOUND => true,
3099 _ => false,
3100 }
3101 }
3102 fn cast(syntax: SyntaxNode) -> Option<Self> {
3103 if Self::can_cast(syntax.kind()) {
3104 Some(Self { syntax })
3105 } else {
3106 None
3107 }
3108 }
3109 fn syntax(&self) -> &SyntaxNode {
3110 &self.syntax
3111 }
3112}
3113impl TypeBound {
3114 pub fn type_ref(&self) -> Option<TypeRef> {
3115 AstChildren::new(&self.syntax).next()
3116 }
3117}
3118#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3119pub struct TypeBoundList {
3120 pub(crate) syntax: SyntaxNode,
3121}
3122impl std::fmt::Display for TypeBoundList {
3123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3124 std::fmt::Display::fmt(self.syntax(), f)
3125 }
3126}
3127impl AstNode for TypeBoundList {
3128 fn can_cast(kind: SyntaxKind) -> bool {
3129 match kind {
3130 TYPE_BOUND_LIST => true,
3131 _ => false,
3132 }
3133 }
3134 fn cast(syntax: SyntaxNode) -> Option<Self> {
3135 if Self::can_cast(syntax.kind()) {
3136 Some(Self { syntax })
3137 } else {
3138 None
3139 }
3140 }
3141 fn syntax(&self) -> &SyntaxNode {
3142 &self.syntax
3143 }
3144}
3145impl TypeBoundList {
3146 pub fn bounds(&self) -> AstChildren<TypeBound> {
3147 AstChildren::new(&self.syntax)
3148 }
3149}
3150#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3151pub struct WherePred {
3152 pub(crate) syntax: SyntaxNode,
3153}
3154impl std::fmt::Display for WherePred {
3155 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3156 std::fmt::Display::fmt(self.syntax(), f)
3157 }
3158}
3159impl AstNode for WherePred {
3160 fn can_cast(kind: SyntaxKind) -> bool {
3161 match kind {
3162 WHERE_PRED => true,
3163 _ => false,
3164 }
3165 }
3166 fn cast(syntax: SyntaxNode) -> Option<Self> {
3167 if Self::can_cast(syntax.kind()) {
3168 Some(Self { syntax })
3169 } else {
3170 None
3171 }
3172 }
3173 fn syntax(&self) -> &SyntaxNode {
3174 &self.syntax
3175 }
3176}
3177impl ast::TypeBoundsOwner for WherePred {}
3178impl WherePred {
3179 pub fn type_ref(&self) -> Option<TypeRef> {
3180 AstChildren::new(&self.syntax).next()
3181 }
3182}
3183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3184pub struct WhereClause {
3185 pub(crate) syntax: SyntaxNode,
3186}
3187impl std::fmt::Display for WhereClause {
3188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3189 std::fmt::Display::fmt(self.syntax(), f)
3190 }
3191}
3192impl AstNode for WhereClause {
3193 fn can_cast(kind: SyntaxKind) -> bool {
3194 match kind {
3195 WHERE_CLAUSE => true,
3196 _ => false,
3197 }
3198 }
3199 fn cast(syntax: SyntaxNode) -> Option<Self> {
3200 if Self::can_cast(syntax.kind()) {
3201 Some(Self { syntax })
3202 } else {
3203 None
3204 }
3205 }
3206 fn syntax(&self) -> &SyntaxNode {
3207 &self.syntax
3208 }
3209}
3210impl WhereClause {
3211 pub fn predicates(&self) -> AstChildren<WherePred> {
3212 AstChildren::new(&self.syntax)
3213 }
3214}
3215#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3216pub struct ExprStmt {
3217 pub(crate) syntax: SyntaxNode,
3218}
3219impl std::fmt::Display for ExprStmt {
3220 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3221 std::fmt::Display::fmt(self.syntax(), f)
3222 }
3223}
3224impl AstNode for ExprStmt {
3225 fn can_cast(kind: SyntaxKind) -> bool {
3226 match kind {
3227 EXPR_STMT => true,
3228 _ => false,
3229 }
3230 }
3231 fn cast(syntax: SyntaxNode) -> Option<Self> {
3232 if Self::can_cast(syntax.kind()) {
3233 Some(Self { syntax })
3234 } else {
3235 None
3236 }
3237 }
3238 fn syntax(&self) -> &SyntaxNode {
3239 &self.syntax
3240 }
3241}
3242impl ExprStmt {
3243 pub fn expr(&self) -> Option<Expr> {
3244 AstChildren::new(&self.syntax).next()
3245 }
3246}
3247#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3248pub struct LetStmt {
3249 pub(crate) syntax: SyntaxNode,
3250}
3251impl std::fmt::Display for LetStmt {
3252 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3253 std::fmt::Display::fmt(self.syntax(), f)
3254 }
3255}
3256impl AstNode for LetStmt {
3257 fn can_cast(kind: SyntaxKind) -> bool {
3258 match kind {
3259 LET_STMT => true,
3260 _ => false,
3261 }
3262 }
3263 fn cast(syntax: SyntaxNode) -> Option<Self> {
3264 if Self::can_cast(syntax.kind()) {
3265 Some(Self { syntax })
3266 } else {
3267 None
3268 }
3269 }
3270 fn syntax(&self) -> &SyntaxNode {
3271 &self.syntax
3272 }
3273}
3274impl ast::TypeAscriptionOwner for LetStmt {}
3275impl LetStmt {
3276 pub fn pat(&self) -> Option<Pat> {
3277 AstChildren::new(&self.syntax).next()
3278 }
3279 pub fn initializer(&self) -> Option<Expr> {
3280 AstChildren::new(&self.syntax).next()
3281 }
3282}
3283#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3284pub struct Condition {
3285 pub(crate) syntax: SyntaxNode,
3286}
3287impl std::fmt::Display for Condition {
3288 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3289 std::fmt::Display::fmt(self.syntax(), f)
3290 }
3291}
3292impl AstNode for Condition {
3293 fn can_cast(kind: SyntaxKind) -> bool {
3294 match kind {
3295 CONDITION => true,
3296 _ => false,
3297 }
3298 }
3299 fn cast(syntax: SyntaxNode) -> Option<Self> {
3300 if Self::can_cast(syntax.kind()) {
3301 Some(Self { syntax })
3302 } else {
3303 None
3304 }
3305 }
3306 fn syntax(&self) -> &SyntaxNode {
3307 &self.syntax
3308 }
3309}
3310impl Condition {
3311 pub fn pat(&self) -> Option<Pat> {
3312 AstChildren::new(&self.syntax).next()
3313 }
3314 pub fn expr(&self) -> Option<Expr> {
3315 AstChildren::new(&self.syntax).next()
3316 }
3317}
3318#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3319pub struct Block {
3320 pub(crate) syntax: SyntaxNode,
3321}
3322impl std::fmt::Display for Block {
3323 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3324 std::fmt::Display::fmt(self.syntax(), f)
3325 }
3326}
3327impl AstNode for Block {
3328 fn can_cast(kind: SyntaxKind) -> bool {
3329 match kind {
3330 BLOCK => true,
3331 _ => false,
3332 }
3333 }
3334 fn cast(syntax: SyntaxNode) -> Option<Self> {
3335 if Self::can_cast(syntax.kind()) {
3336 Some(Self { syntax })
3337 } else {
3338 None
3339 }
3340 }
3341 fn syntax(&self) -> &SyntaxNode {
3342 &self.syntax
3343 }
3344}
3345impl ast::AttrsOwner for Block {}
3346impl ast::ModuleItemOwner for Block {}
3347impl Block {
3348 pub fn statements(&self) -> AstChildren<Stmt> {
3349 AstChildren::new(&self.syntax)
3350 }
3351 pub fn expr(&self) -> Option<Expr> {
3352 AstChildren::new(&self.syntax).next()
3353 }
3354}
3355#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3356pub struct ParamList {
3357 pub(crate) syntax: SyntaxNode,
3358}
3359impl std::fmt::Display for ParamList {
3360 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3361 std::fmt::Display::fmt(self.syntax(), f)
3362 }
3363}
3364impl AstNode for ParamList {
3365 fn can_cast(kind: SyntaxKind) -> bool {
3366 match kind {
3367 PARAM_LIST => true,
3368 _ => false,
3369 }
3370 }
3371 fn cast(syntax: SyntaxNode) -> Option<Self> {
3372 if Self::can_cast(syntax.kind()) {
3373 Some(Self { syntax })
3374 } else {
3375 None
3376 }
3377 }
3378 fn syntax(&self) -> &SyntaxNode {
3379 &self.syntax
3380 }
3381}
3382impl ParamList {
3383 pub fn self_param(&self) -> Option<SelfParam> {
3384 AstChildren::new(&self.syntax).next()
3385 }
3386 pub fn params(&self) -> AstChildren<Param> {
3387 AstChildren::new(&self.syntax)
3388 }
3389}
3390#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3391pub struct SelfParam {
3392 pub(crate) syntax: SyntaxNode,
3393}
3394impl std::fmt::Display for SelfParam {
3395 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3396 std::fmt::Display::fmt(self.syntax(), f)
3397 }
3398}
3399impl AstNode for SelfParam {
3400 fn can_cast(kind: SyntaxKind) -> bool {
3401 match kind {
3402 SELF_PARAM => true,
3403 _ => false,
3404 }
3405 }
3406 fn cast(syntax: SyntaxNode) -> Option<Self> {
3407 if Self::can_cast(syntax.kind()) {
3408 Some(Self { syntax })
3409 } else {
3410 None
3411 }
3412 }
3413 fn syntax(&self) -> &SyntaxNode {
3414 &self.syntax
3415 }
3416}
3417impl ast::TypeAscriptionOwner for SelfParam {}
3418impl ast::AttrsOwner for SelfParam {}
3419impl SelfParam {}
3420#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3421pub struct Param {
3422 pub(crate) syntax: SyntaxNode,
3423}
3424impl std::fmt::Display for Param {
3425 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3426 std::fmt::Display::fmt(self.syntax(), f)
3427 }
3428}
3429impl AstNode for Param {
3430 fn can_cast(kind: SyntaxKind) -> bool {
3431 match kind {
3432 PARAM => true,
3433 _ => false,
3434 }
3435 }
3436 fn cast(syntax: SyntaxNode) -> Option<Self> {
3437 if Self::can_cast(syntax.kind()) {
3438 Some(Self { syntax })
3439 } else {
3440 None
3441 }
3442 }
3443 fn syntax(&self) -> &SyntaxNode {
3444 &self.syntax
3445 }
3446}
3447impl ast::TypeAscriptionOwner for Param {}
3448impl ast::AttrsOwner for Param {}
3449impl Param {
3450 pub fn pat(&self) -> Option<Pat> {
3451 AstChildren::new(&self.syntax).next()
3452 }
3453}
3454#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3455pub struct UseItem {
3456 pub(crate) syntax: SyntaxNode,
3457}
3458impl std::fmt::Display for UseItem {
3459 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3460 std::fmt::Display::fmt(self.syntax(), f)
3461 }
3462}
3463impl AstNode for UseItem {
3464 fn can_cast(kind: SyntaxKind) -> bool {
3465 match kind {
3466 USE_ITEM => true,
3467 _ => false,
3468 }
3469 }
3470 fn cast(syntax: SyntaxNode) -> Option<Self> {
3471 if Self::can_cast(syntax.kind()) {
3472 Some(Self { syntax })
3473 } else {
3474 None
3475 }
3476 }
3477 fn syntax(&self) -> &SyntaxNode {
3478 &self.syntax
3479 }
3480}
3481impl ast::AttrsOwner for UseItem {}
3482impl ast::VisibilityOwner for UseItem {}
3483impl UseItem {
3484 pub fn use_tree(&self) -> Option<UseTree> {
3485 AstChildren::new(&self.syntax).next()
3486 }
3487}
3488#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3489pub struct UseTree {
3490 pub(crate) syntax: SyntaxNode,
3491}
3492impl std::fmt::Display for UseTree {
3493 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3494 std::fmt::Display::fmt(self.syntax(), f)
3495 }
3496}
3497impl AstNode for UseTree {
3498 fn can_cast(kind: SyntaxKind) -> bool {
3499 match kind {
3500 USE_TREE => true,
3501 _ => false,
3502 }
3503 }
3504 fn cast(syntax: SyntaxNode) -> Option<Self> {
3505 if Self::can_cast(syntax.kind()) {
3506 Some(Self { syntax })
3507 } else {
3508 None
3509 }
3510 }
3511 fn syntax(&self) -> &SyntaxNode {
3512 &self.syntax
3513 }
3514}
3515impl UseTree {
3516 pub fn path(&self) -> Option<Path> {
3517 AstChildren::new(&self.syntax).next()
3518 }
3519 pub fn use_tree_list(&self) -> Option<UseTreeList> {
3520 AstChildren::new(&self.syntax).next()
3521 }
3522 pub fn alias(&self) -> Option<Alias> {
3523 AstChildren::new(&self.syntax).next()
3524 }
3525}
3526#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3527pub struct Alias {
3528 pub(crate) syntax: SyntaxNode,
3529}
3530impl std::fmt::Display for Alias {
3531 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3532 std::fmt::Display::fmt(self.syntax(), f)
3533 }
3534}
3535impl AstNode for Alias {
3536 fn can_cast(kind: SyntaxKind) -> bool {
3537 match kind {
3538 ALIAS => true,
3539 _ => false,
3540 }
3541 }
3542 fn cast(syntax: SyntaxNode) -> Option<Self> {
3543 if Self::can_cast(syntax.kind()) {
3544 Some(Self { syntax })
3545 } else {
3546 None
3547 }
3548 }
3549 fn syntax(&self) -> &SyntaxNode {
3550 &self.syntax
3551 }
3552}
3553impl ast::NameOwner for Alias {}
3554impl Alias {}
3555#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3556pub struct UseTreeList {
3557 pub(crate) syntax: SyntaxNode,
3558}
3559impl std::fmt::Display for UseTreeList {
3560 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3561 std::fmt::Display::fmt(self.syntax(), f)
3562 }
3563}
3564impl AstNode for UseTreeList {
3565 fn can_cast(kind: SyntaxKind) -> bool {
3566 match kind {
3567 USE_TREE_LIST => true,
3568 _ => false,
3569 }
3570 }
3571 fn cast(syntax: SyntaxNode) -> Option<Self> {
3572 if Self::can_cast(syntax.kind()) {
3573 Some(Self { syntax })
3574 } else {
3575 None
3576 }
3577 }
3578 fn syntax(&self) -> &SyntaxNode {
3579 &self.syntax
3580 }
3581}
3582impl UseTreeList {
3583 pub fn use_trees(&self) -> AstChildren<UseTree> {
3584 AstChildren::new(&self.syntax)
3585 }
3586}
3587#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3588pub struct ExternCrateItem {
3589 pub(crate) syntax: SyntaxNode,
3590}
3591impl std::fmt::Display for ExternCrateItem {
3592 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3593 std::fmt::Display::fmt(self.syntax(), f)
3594 }
3595}
3596impl AstNode for ExternCrateItem {
3597 fn can_cast(kind: SyntaxKind) -> bool {
3598 match kind {
3599 EXTERN_CRATE_ITEM => true,
3600 _ => false,
3601 }
3602 }
3603 fn cast(syntax: SyntaxNode) -> Option<Self> {
3604 if Self::can_cast(syntax.kind()) {
3605 Some(Self { syntax })
3606 } else {
3607 None
3608 }
3609 }
3610 fn syntax(&self) -> &SyntaxNode {
3611 &self.syntax
3612 }
3613}
3614impl ast::AttrsOwner for ExternCrateItem {}
3615impl ast::VisibilityOwner for ExternCrateItem {}
3616impl ExternCrateItem {
3617 pub fn name_ref(&self) -> Option<NameRef> {
3618 AstChildren::new(&self.syntax).next()
3619 }
3620 pub fn alias(&self) -> Option<Alias> {
3621 AstChildren::new(&self.syntax).next()
3622 }
3623}
3624#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3625pub struct ArgList {
3626 pub(crate) syntax: SyntaxNode,
3627}
3628impl std::fmt::Display for ArgList {
3629 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3630 std::fmt::Display::fmt(self.syntax(), f)
3631 }
3632}
3633impl AstNode for ArgList {
3634 fn can_cast(kind: SyntaxKind) -> bool {
3635 match kind {
3636 ARG_LIST => true,
3637 _ => false,
3638 }
3639 }
3640 fn cast(syntax: SyntaxNode) -> Option<Self> {
3641 if Self::can_cast(syntax.kind()) {
3642 Some(Self { syntax })
3643 } else {
3644 None
3645 }
3646 }
3647 fn syntax(&self) -> &SyntaxNode {
3648 &self.syntax
3649 }
3650}
3651impl ArgList {
3652 pub fn args(&self) -> AstChildren<Expr> {
3653 AstChildren::new(&self.syntax)
3654 }
3655}
3656#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3657pub struct Path {
3658 pub(crate) syntax: SyntaxNode,
3659}
3660impl std::fmt::Display for Path {
3661 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3662 std::fmt::Display::fmt(self.syntax(), f)
3663 }
3664}
3665impl AstNode for Path {
3666 fn can_cast(kind: SyntaxKind) -> bool {
3667 match kind {
3668 PATH => true,
3669 _ => false,
3670 }
3671 }
3672 fn cast(syntax: SyntaxNode) -> Option<Self> {
3673 if Self::can_cast(syntax.kind()) {
3674 Some(Self { syntax })
3675 } else {
3676 None
3677 }
3678 }
3679 fn syntax(&self) -> &SyntaxNode {
3680 &self.syntax
3681 }
3682}
3683impl Path {
3684 pub fn segment(&self) -> Option<PathSegment> {
3685 AstChildren::new(&self.syntax).next()
3686 }
3687 pub fn qualifier(&self) -> Option<Path> {
3688 AstChildren::new(&self.syntax).next()
3689 }
3690}
3691#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3692pub struct PathSegment {
3693 pub(crate) syntax: SyntaxNode,
3694}
3695impl std::fmt::Display for PathSegment {
3696 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3697 std::fmt::Display::fmt(self.syntax(), f)
3698 }
3699}
3700impl AstNode for PathSegment {
3701 fn can_cast(kind: SyntaxKind) -> bool {
3702 match kind {
3703 PATH_SEGMENT => true,
3704 _ => false,
3705 }
3706 }
3707 fn cast(syntax: SyntaxNode) -> Option<Self> {
3708 if Self::can_cast(syntax.kind()) {
3709 Some(Self { syntax })
3710 } else {
3711 None
3712 }
3713 }
3714 fn syntax(&self) -> &SyntaxNode {
3715 &self.syntax
3716 }
3717}
3718impl PathSegment {
3719 pub fn name_ref(&self) -> Option<NameRef> {
3720 AstChildren::new(&self.syntax).next()
3721 }
3722 pub fn type_arg_list(&self) -> Option<TypeArgList> {
3723 AstChildren::new(&self.syntax).next()
3724 }
3725 pub fn param_list(&self) -> Option<ParamList> {
3726 AstChildren::new(&self.syntax).next()
3727 }
3728 pub fn ret_type(&self) -> Option<RetType> {
3729 AstChildren::new(&self.syntax).next()
3730 }
3731 pub fn path_type(&self) -> Option<PathType> {
3732 AstChildren::new(&self.syntax).next()
3733 }
3734}
3735#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3736pub struct TypeArgList {
3737 pub(crate) syntax: SyntaxNode,
3738}
3739impl std::fmt::Display for TypeArgList {
3740 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3741 std::fmt::Display::fmt(self.syntax(), f)
3742 }
3743}
3744impl AstNode for TypeArgList {
3745 fn can_cast(kind: SyntaxKind) -> bool {
3746 match kind {
3747 TYPE_ARG_LIST => true,
3748 _ => false,
3749 }
3750 }
3751 fn cast(syntax: SyntaxNode) -> Option<Self> {
3752 if Self::can_cast(syntax.kind()) {
3753 Some(Self { syntax })
3754 } else {
3755 None
3756 }
3757 }
3758 fn syntax(&self) -> &SyntaxNode {
3759 &self.syntax
3760 }
3761}
3762impl TypeArgList {
3763 pub fn type_args(&self) -> AstChildren<TypeArg> {
3764 AstChildren::new(&self.syntax)
3765 }
3766 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
3767 AstChildren::new(&self.syntax)
3768 }
3769 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3770 AstChildren::new(&self.syntax)
3771 }
3772 pub fn const_arg(&self) -> AstChildren<ConstArg> {
3773 AstChildren::new(&self.syntax)
3774 }
3775}
3776#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3777pub struct TypeArg {
3778 pub(crate) syntax: SyntaxNode,
3779}
3780impl std::fmt::Display for TypeArg {
3781 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3782 std::fmt::Display::fmt(self.syntax(), f)
3783 }
3784}
3785impl AstNode for TypeArg {
3786 fn can_cast(kind: SyntaxKind) -> bool {
3787 match kind {
3788 TYPE_ARG => true,
3789 _ => false,
3790 }
3791 }
3792 fn cast(syntax: SyntaxNode) -> Option<Self> {
3793 if Self::can_cast(syntax.kind()) {
3794 Some(Self { syntax })
3795 } else {
3796 None
3797 }
3798 }
3799 fn syntax(&self) -> &SyntaxNode {
3800 &self.syntax
3801 }
3802}
3803impl TypeArg {
3804 pub fn type_ref(&self) -> Option<TypeRef> {
3805 AstChildren::new(&self.syntax).next()
3806 }
3807}
3808#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3809pub struct AssocTypeArg {
3810 pub(crate) syntax: SyntaxNode,
3811}
3812impl std::fmt::Display for AssocTypeArg {
3813 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3814 std::fmt::Display::fmt(self.syntax(), f)
3815 }
3816}
3817impl AstNode for AssocTypeArg {
3818 fn can_cast(kind: SyntaxKind) -> bool {
3819 match kind {
3820 ASSOC_TYPE_ARG => true,
3821 _ => false,
3822 }
3823 }
3824 fn cast(syntax: SyntaxNode) -> Option<Self> {
3825 if Self::can_cast(syntax.kind()) {
3826 Some(Self { syntax })
3827 } else {
3828 None
3829 }
3830 }
3831 fn syntax(&self) -> &SyntaxNode {
3832 &self.syntax
3833 }
3834}
3835impl AssocTypeArg {
3836 pub fn name_ref(&self) -> Option<NameRef> {
3837 AstChildren::new(&self.syntax).next()
3838 }
3839 pub fn type_ref(&self) -> Option<TypeRef> {
3840 AstChildren::new(&self.syntax).next()
3841 }
3842}
3843#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3844pub struct LifetimeArg {
3845 pub(crate) syntax: SyntaxNode,
3846}
3847impl std::fmt::Display for LifetimeArg {
3848 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3849 std::fmt::Display::fmt(self.syntax(), f)
3850 }
3851}
3852impl AstNode for LifetimeArg {
3853 fn can_cast(kind: SyntaxKind) -> bool {
3854 match kind {
3855 LIFETIME_ARG => true,
3856 _ => false,
3857 }
3858 }
3859 fn cast(syntax: SyntaxNode) -> Option<Self> {
3860 if Self::can_cast(syntax.kind()) {
3861 Some(Self { syntax })
3862 } else {
3863 None
3864 }
3865 }
3866 fn syntax(&self) -> &SyntaxNode {
3867 &self.syntax
3868 }
3869}
3870impl LifetimeArg {}
3871#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3872pub struct ConstArg {
3873 pub(crate) syntax: SyntaxNode,
3874}
3875impl std::fmt::Display for ConstArg {
3876 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3877 std::fmt::Display::fmt(self.syntax(), f)
3878 }
3879}
3880impl AstNode for ConstArg {
3881 fn can_cast(kind: SyntaxKind) -> bool {
3882 match kind {
3883 CONST_ARG => true,
3884 _ => false,
3885 }
3886 }
3887 fn cast(syntax: SyntaxNode) -> Option<Self> {
3888 if Self::can_cast(syntax.kind()) {
3889 Some(Self { syntax })
3890 } else {
3891 None
3892 }
3893 }
3894 fn syntax(&self) -> &SyntaxNode {
3895 &self.syntax
3896 }
3897}
3898impl ConstArg {
3899 pub fn literal(&self) -> Option<Literal> {
3900 AstChildren::new(&self.syntax).next()
3901 }
3902 pub fn block_expr(&self) -> Option<BlockExpr> {
3903 AstChildren::new(&self.syntax).next()
3904 }
3905}
3906#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3907pub struct MacroItems {
3908 pub(crate) syntax: SyntaxNode,
3909}
3910impl std::fmt::Display for MacroItems {
3911 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3912 std::fmt::Display::fmt(self.syntax(), f)
3913 }
3914}
3915impl AstNode for MacroItems {
3916 fn can_cast(kind: SyntaxKind) -> bool {
3917 match kind {
3918 MACRO_ITEMS => true,
3919 _ => false,
3920 }
3921 }
3922 fn cast(syntax: SyntaxNode) -> Option<Self> {
3923 if Self::can_cast(syntax.kind()) {
3924 Some(Self { syntax })
3925 } else {
3926 None
3927 }
3928 }
3929 fn syntax(&self) -> &SyntaxNode {
3930 &self.syntax
3931 }
3932}
3933impl ast::ModuleItemOwner for MacroItems {}
3934impl ast::FnDefOwner for MacroItems {}
3935impl MacroItems {}
3936#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3937pub struct MacroStmts {
3938 pub(crate) syntax: SyntaxNode,
3939}
3940impl std::fmt::Display for MacroStmts {
3941 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3942 std::fmt::Display::fmt(self.syntax(), f)
3943 }
3944}
3945impl AstNode for MacroStmts {
3946 fn can_cast(kind: SyntaxKind) -> bool {
3947 match kind {
3948 MACRO_STMTS => true,
3949 _ => false,
3950 }
3951 }
3952 fn cast(syntax: SyntaxNode) -> Option<Self> {
3953 if Self::can_cast(syntax.kind()) {
3954 Some(Self { syntax })
3955 } else {
3956 None
3957 }
3958 }
3959 fn syntax(&self) -> &SyntaxNode {
3960 &self.syntax
3961 }
3962}
3963impl MacroStmts {
3964 pub fn statements(&self) -> AstChildren<Stmt> {
3965 AstChildren::new(&self.syntax)
3966 }
3967 pub fn expr(&self) -> Option<Expr> {
3968 AstChildren::new(&self.syntax).next()
3969 }
3970}
3971#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3972pub enum NominalDef {
3973 StructDef(StructDef),
3974 EnumDef(EnumDef),
3975 UnionDef(UnionDef),
3976}
3977impl From<StructDef> for NominalDef {
3978 fn from(node: StructDef) -> NominalDef {
3979 NominalDef::StructDef(node)
3980 }
3981}
3982impl From<EnumDef> for NominalDef {
3983 fn from(node: EnumDef) -> NominalDef {
3984 NominalDef::EnumDef(node)
3985 }
3986}
3987impl From<UnionDef> for NominalDef {
3988 fn from(node: UnionDef) -> NominalDef {
3989 NominalDef::UnionDef(node)
3990 }
3991}
3992impl std::fmt::Display for NominalDef {
3993 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3994 std::fmt::Display::fmt(self.syntax(), f)
3995 }
3996}
3997impl AstNode for NominalDef {
3998 fn can_cast(kind: SyntaxKind) -> bool {
3999 match kind {
4000 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
4001 _ => false,
4002 }
4003 }
4004 fn cast(syntax: SyntaxNode) -> Option<Self> {
4005 let res = match syntax.kind() {
4006 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
4007 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
4008 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
4009 _ => return None,
4010 };
4011 Some(res)
4012 }
4013 fn syntax(&self) -> &SyntaxNode {
4014 match self {
4015 NominalDef::StructDef(it) => &it.syntax,
4016 NominalDef::EnumDef(it) => &it.syntax,
4017 NominalDef::UnionDef(it) => &it.syntax,
4018 }
4019 }
4020}
4021impl ast::NameOwner for NominalDef {}
4022impl ast::TypeParamsOwner for NominalDef {}
4023impl ast::AttrsOwner for NominalDef {}
4024#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4025pub enum TypeRef {
4026 ParenType(ParenType),
4027 TupleType(TupleType),
4028 NeverType(NeverType),
4029 PathType(PathType),
4030 PointerType(PointerType),
4031 ArrayType(ArrayType),
4032 SliceType(SliceType),
4033 ReferenceType(ReferenceType),
4034 PlaceholderType(PlaceholderType),
4035 FnPointerType(FnPointerType),
4036 ForType(ForType),
4037 ImplTraitType(ImplTraitType),
4038 DynTraitType(DynTraitType),
4039}
4040impl From<ParenType> for TypeRef {
4041 fn from(node: ParenType) -> TypeRef {
4042 TypeRef::ParenType(node)
4043 }
4044}
4045impl From<TupleType> for TypeRef {
4046 fn from(node: TupleType) -> TypeRef {
4047 TypeRef::TupleType(node)
4048 }
4049}
4050impl From<NeverType> for TypeRef {
4051 fn from(node: NeverType) -> TypeRef {
4052 TypeRef::NeverType(node)
4053 }
4054}
4055impl From<PathType> for TypeRef {
4056 fn from(node: PathType) -> TypeRef {
4057 TypeRef::PathType(node)
4058 }
4059}
4060impl From<PointerType> for TypeRef {
4061 fn from(node: PointerType) -> TypeRef {
4062 TypeRef::PointerType(node)
4063 }
4064}
4065impl From<ArrayType> for TypeRef {
4066 fn from(node: ArrayType) -> TypeRef {
4067 TypeRef::ArrayType(node)
4068 }
4069}
4070impl From<SliceType> for TypeRef {
4071 fn from(node: SliceType) -> TypeRef {
4072 TypeRef::SliceType(node)
4073 }
4074}
4075impl From<ReferenceType> for TypeRef {
4076 fn from(node: ReferenceType) -> TypeRef {
4077 TypeRef::ReferenceType(node)
4078 }
4079}
4080impl From<PlaceholderType> for TypeRef {
4081 fn from(node: PlaceholderType) -> TypeRef {
4082 TypeRef::PlaceholderType(node)
4083 }
4084}
4085impl From<FnPointerType> for TypeRef {
4086 fn from(node: FnPointerType) -> TypeRef {
4087 TypeRef::FnPointerType(node)
4088 }
4089}
4090impl From<ForType> for TypeRef {
4091 fn from(node: ForType) -> TypeRef {
4092 TypeRef::ForType(node)
4093 }
4094}
4095impl From<ImplTraitType> for TypeRef {
4096 fn from(node: ImplTraitType) -> TypeRef {
4097 TypeRef::ImplTraitType(node)
4098 }
4099}
4100impl From<DynTraitType> for TypeRef {
4101 fn from(node: DynTraitType) -> TypeRef {
4102 TypeRef::DynTraitType(node)
4103 }
4104}
4105impl std::fmt::Display for TypeRef {
4106 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4107 std::fmt::Display::fmt(self.syntax(), f)
4108 }
4109}
4110impl AstNode for TypeRef {
4111 fn can_cast(kind: SyntaxKind) -> bool {
4112 match kind {
4113 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
4114 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
4115 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
4116 _ => false,
4117 }
4118 }
4119 fn cast(syntax: SyntaxNode) -> Option<Self> {
4120 let res = match syntax.kind() {
4121 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
4122 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
4123 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
4124 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
4125 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
4126 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
4127 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
4128 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
4129 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
4130 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
4131 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
4132 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
4133 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
4134 _ => return None,
4135 };
4136 Some(res)
4137 }
4138 fn syntax(&self) -> &SyntaxNode {
4139 match self {
4140 TypeRef::ParenType(it) => &it.syntax,
4141 TypeRef::TupleType(it) => &it.syntax,
4142 TypeRef::NeverType(it) => &it.syntax,
4143 TypeRef::PathType(it) => &it.syntax,
4144 TypeRef::PointerType(it) => &it.syntax,
4145 TypeRef::ArrayType(it) => &it.syntax,
4146 TypeRef::SliceType(it) => &it.syntax,
4147 TypeRef::ReferenceType(it) => &it.syntax,
4148 TypeRef::PlaceholderType(it) => &it.syntax,
4149 TypeRef::FnPointerType(it) => &it.syntax,
4150 TypeRef::ForType(it) => &it.syntax,
4151 TypeRef::ImplTraitType(it) => &it.syntax,
4152 TypeRef::DynTraitType(it) => &it.syntax,
4153 }
4154 }
4155}
4156#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4157pub enum ModuleItem {
4158 StructDef(StructDef),
4159 UnionDef(UnionDef),
4160 EnumDef(EnumDef),
4161 FnDef(FnDef),
4162 TraitDef(TraitDef),
4163 TypeAliasDef(TypeAliasDef),
4164 ImplDef(ImplDef),
4165 UseItem(UseItem),
4166 ExternCrateItem(ExternCrateItem),
4167 ConstDef(ConstDef),
4168 StaticDef(StaticDef),
4169 Module(Module),
4170 MacroCall(MacroCall),
4171}
4172impl From<StructDef> for ModuleItem {
4173 fn from(node: StructDef) -> ModuleItem {
4174 ModuleItem::StructDef(node)
4175 }
4176}
4177impl From<UnionDef> for ModuleItem {
4178 fn from(node: UnionDef) -> ModuleItem {
4179 ModuleItem::UnionDef(node)
4180 }
4181}
4182impl From<EnumDef> for ModuleItem {
4183 fn from(node: EnumDef) -> ModuleItem {
4184 ModuleItem::EnumDef(node)
4185 }
4186}
4187impl From<FnDef> for ModuleItem {
4188 fn from(node: FnDef) -> ModuleItem {
4189 ModuleItem::FnDef(node)
4190 }
4191}
4192impl From<TraitDef> for ModuleItem {
4193 fn from(node: TraitDef) -> ModuleItem {
4194 ModuleItem::TraitDef(node)
4195 }
4196}
4197impl From<TypeAliasDef> for ModuleItem {
4198 fn from(node: TypeAliasDef) -> ModuleItem {
4199 ModuleItem::TypeAliasDef(node)
4200 }
4201}
4202impl From<ImplDef> for ModuleItem {
4203 fn from(node: ImplDef) -> ModuleItem {
4204 ModuleItem::ImplDef(node)
4205 }
4206}
4207impl From<UseItem> for ModuleItem {
4208 fn from(node: UseItem) -> ModuleItem {
4209 ModuleItem::UseItem(node)
4210 }
4211}
4212impl From<ExternCrateItem> for ModuleItem {
4213 fn from(node: ExternCrateItem) -> ModuleItem {
4214 ModuleItem::ExternCrateItem(node)
4215 }
4216}
4217impl From<ConstDef> for ModuleItem {
4218 fn from(node: ConstDef) -> ModuleItem {
4219 ModuleItem::ConstDef(node)
4220 }
4221}
4222impl From<StaticDef> for ModuleItem {
4223 fn from(node: StaticDef) -> ModuleItem {
4224 ModuleItem::StaticDef(node)
4225 }
4226}
4227impl From<Module> for ModuleItem {
4228 fn from(node: Module) -> ModuleItem {
4229 ModuleItem::Module(node)
4230 }
4231}
4232impl From<MacroCall> for ModuleItem {
4233 fn from(node: MacroCall) -> ModuleItem {
4234 ModuleItem::MacroCall(node)
4235 }
4236}
4237impl std::fmt::Display for ModuleItem {
4238 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4239 std::fmt::Display::fmt(self.syntax(), f)
4240 }
4241}
4242impl AstNode for ModuleItem {
4243 fn can_cast(kind: SyntaxKind) -> bool {
4244 match kind {
4245 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
4246 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL => true,
4247 _ => false,
4248 }
4249 }
4250 fn cast(syntax: SyntaxNode) -> Option<Self> {
4251 let res = match syntax.kind() {
4252 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
4253 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
4254 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
4255 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
4256 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
4257 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
4258 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
4259 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
4260 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
4261 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
4262 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
4263 MODULE => ModuleItem::Module(Module { syntax }),
4264 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
4265 _ => return None,
4266 };
4267 Some(res)
4268 }
4269 fn syntax(&self) -> &SyntaxNode {
4270 match self {
4271 ModuleItem::StructDef(it) => &it.syntax,
4272 ModuleItem::UnionDef(it) => &it.syntax,
4273 ModuleItem::EnumDef(it) => &it.syntax,
4274 ModuleItem::FnDef(it) => &it.syntax,
4275 ModuleItem::TraitDef(it) => &it.syntax,
4276 ModuleItem::TypeAliasDef(it) => &it.syntax,
4277 ModuleItem::ImplDef(it) => &it.syntax,
4278 ModuleItem::UseItem(it) => &it.syntax,
4279 ModuleItem::ExternCrateItem(it) => &it.syntax,
4280 ModuleItem::ConstDef(it) => &it.syntax,
4281 ModuleItem::StaticDef(it) => &it.syntax,
4282 ModuleItem::Module(it) => &it.syntax,
4283 ModuleItem::MacroCall(it) => &it.syntax,
4284 }
4285 }
4286}
4287impl ast::AttrsOwner for ModuleItem {}
4288impl ast::VisibilityOwner for ModuleItem {}
4289#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4290pub enum ImplItem {
4291 FnDef(FnDef),
4292 TypeAliasDef(TypeAliasDef),
4293 ConstDef(ConstDef),
4294}
4295impl From<FnDef> for ImplItem {
4296 fn from(node: FnDef) -> ImplItem {
4297 ImplItem::FnDef(node)
4298 }
4299}
4300impl From<TypeAliasDef> for ImplItem {
4301 fn from(node: TypeAliasDef) -> ImplItem {
4302 ImplItem::TypeAliasDef(node)
4303 }
4304}
4305impl From<ConstDef> for ImplItem {
4306 fn from(node: ConstDef) -> ImplItem {
4307 ImplItem::ConstDef(node)
4308 }
4309}
4310impl std::fmt::Display for ImplItem {
4311 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4312 std::fmt::Display::fmt(self.syntax(), f)
4313 }
4314}
4315impl AstNode for ImplItem {
4316 fn can_cast(kind: SyntaxKind) -> bool {
4317 match kind {
4318 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
4319 _ => false,
4320 }
4321 }
4322 fn cast(syntax: SyntaxNode) -> Option<Self> {
4323 let res = match syntax.kind() {
4324 FN_DEF => ImplItem::FnDef(FnDef { syntax }),
4325 TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
4326 CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
4327 _ => return None,
4328 };
4329 Some(res)
4330 }
4331 fn syntax(&self) -> &SyntaxNode {
4332 match self {
4333 ImplItem::FnDef(it) => &it.syntax,
4334 ImplItem::TypeAliasDef(it) => &it.syntax,
4335 ImplItem::ConstDef(it) => &it.syntax,
4336 }
4337 }
4338}
4339impl ast::AttrsOwner for ImplItem {}
4340#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4341pub enum Expr {
4342 TupleExpr(TupleExpr),
4343 ArrayExpr(ArrayExpr),
4344 ParenExpr(ParenExpr),
4345 PathExpr(PathExpr),
4346 LambdaExpr(LambdaExpr),
4347 IfExpr(IfExpr),
4348 LoopExpr(LoopExpr),
4349 ForExpr(ForExpr),
4350 WhileExpr(WhileExpr),
4351 ContinueExpr(ContinueExpr),
4352 BreakExpr(BreakExpr),
4353 Label(Label),
4354 BlockExpr(BlockExpr),
4355 ReturnExpr(ReturnExpr),
4356 MatchExpr(MatchExpr),
4357 RecordLit(RecordLit),
4358 CallExpr(CallExpr),
4359 IndexExpr(IndexExpr),
4360 MethodCallExpr(MethodCallExpr),
4361 FieldExpr(FieldExpr),
4362 AwaitExpr(AwaitExpr),
4363 TryExpr(TryExpr),
4364 TryBlockExpr(TryBlockExpr),
4365 CastExpr(CastExpr),
4366 RefExpr(RefExpr),
4367 PrefixExpr(PrefixExpr),
4368 RangeExpr(RangeExpr),
4369 BinExpr(BinExpr),
4370 Literal(Literal),
4371 MacroCall(MacroCall),
4372 BoxExpr(BoxExpr),
4373}
4374impl From<TupleExpr> for Expr {
4375 fn from(node: TupleExpr) -> Expr {
4376 Expr::TupleExpr(node)
4377 }
4378}
4379impl From<ArrayExpr> for Expr {
4380 fn from(node: ArrayExpr) -> Expr {
4381 Expr::ArrayExpr(node)
4382 }
4383}
4384impl From<ParenExpr> for Expr {
4385 fn from(node: ParenExpr) -> Expr {
4386 Expr::ParenExpr(node)
4387 }
4388}
4389impl From<PathExpr> for Expr {
4390 fn from(node: PathExpr) -> Expr {
4391 Expr::PathExpr(node)
4392 }
4393}
4394impl From<LambdaExpr> for Expr {
4395 fn from(node: LambdaExpr) -> Expr {
4396 Expr::LambdaExpr(node)
4397 }
4398}
4399impl From<IfExpr> for Expr {
4400 fn from(node: IfExpr) -> Expr {
4401 Expr::IfExpr(node)
4402 }
4403}
4404impl From<LoopExpr> for Expr {
4405 fn from(node: LoopExpr) -> Expr {
4406 Expr::LoopExpr(node)
4407 }
4408}
4409impl From<ForExpr> for Expr {
4410 fn from(node: ForExpr) -> Expr {
4411 Expr::ForExpr(node)
4412 }
4413}
4414impl From<WhileExpr> for Expr {
4415 fn from(node: WhileExpr) -> Expr {
4416 Expr::WhileExpr(node)
4417 }
4418}
4419impl From<ContinueExpr> for Expr {
4420 fn from(node: ContinueExpr) -> Expr {
4421 Expr::ContinueExpr(node)
4422 }
4423}
4424impl From<BreakExpr> for Expr {
4425 fn from(node: BreakExpr) -> Expr {
4426 Expr::BreakExpr(node)
4427 }
4428}
4429impl From<Label> for Expr {
4430 fn from(node: Label) -> Expr {
4431 Expr::Label(node)
4432 }
4433}
4434impl From<BlockExpr> for Expr {
4435 fn from(node: BlockExpr) -> Expr {
4436 Expr::BlockExpr(node)
4437 }
4438}
4439impl From<ReturnExpr> for Expr {
4440 fn from(node: ReturnExpr) -> Expr {
4441 Expr::ReturnExpr(node)
4442 }
4443}
4444impl From<MatchExpr> for Expr {
4445 fn from(node: MatchExpr) -> Expr {
4446 Expr::MatchExpr(node)
4447 }
4448}
4449impl From<RecordLit> for Expr {
4450 fn from(node: RecordLit) -> Expr {
4451 Expr::RecordLit(node)
4452 }
4453}
4454impl From<CallExpr> for Expr {
4455 fn from(node: CallExpr) -> Expr {
4456 Expr::CallExpr(node)
4457 }
4458}
4459impl From<IndexExpr> for Expr {
4460 fn from(node: IndexExpr) -> Expr {
4461 Expr::IndexExpr(node)
4462 }
4463}
4464impl From<MethodCallExpr> for Expr {
4465 fn from(node: MethodCallExpr) -> Expr {
4466 Expr::MethodCallExpr(node)
4467 }
4468}
4469impl From<FieldExpr> for Expr {
4470 fn from(node: FieldExpr) -> Expr {
4471 Expr::FieldExpr(node)
4472 }
4473}
4474impl From<AwaitExpr> for Expr {
4475 fn from(node: AwaitExpr) -> Expr {
4476 Expr::AwaitExpr(node)
4477 }
4478}
4479impl From<TryExpr> for Expr {
4480 fn from(node: TryExpr) -> Expr {
4481 Expr::TryExpr(node)
4482 }
4483}
4484impl From<TryBlockExpr> for Expr {
4485 fn from(node: TryBlockExpr) -> Expr {
4486 Expr::TryBlockExpr(node)
4487 }
4488}
4489impl From<CastExpr> for Expr {
4490 fn from(node: CastExpr) -> Expr {
4491 Expr::CastExpr(node)
4492 }
4493}
4494impl From<RefExpr> for Expr {
4495 fn from(node: RefExpr) -> Expr {
4496 Expr::RefExpr(node)
4497 }
4498}
4499impl From<PrefixExpr> for Expr {
4500 fn from(node: PrefixExpr) -> Expr {
4501 Expr::PrefixExpr(node)
4502 }
4503}
4504impl From<RangeExpr> for Expr {
4505 fn from(node: RangeExpr) -> Expr {
4506 Expr::RangeExpr(node)
4507 }
4508}
4509impl From<BinExpr> for Expr {
4510 fn from(node: BinExpr) -> Expr {
4511 Expr::BinExpr(node)
4512 }
4513}
4514impl From<Literal> for Expr {
4515 fn from(node: Literal) -> Expr {
4516 Expr::Literal(node)
4517 }
4518}
4519impl From<MacroCall> for Expr {
4520 fn from(node: MacroCall) -> Expr {
4521 Expr::MacroCall(node)
4522 }
4523}
4524impl From<BoxExpr> for Expr {
4525 fn from(node: BoxExpr) -> Expr {
4526 Expr::BoxExpr(node)
4527 }
4528}
4529impl std::fmt::Display for Expr {
4530 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4531 std::fmt::Display::fmt(self.syntax(), f)
4532 }
4533}
4534impl AstNode for Expr {
4535 fn can_cast(kind: SyntaxKind) -> bool {
4536 match kind {
4537 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
4538 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
4539 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
4540 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
4541 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
4542 | BOX_EXPR => true,
4543 _ => false,
4544 }
4545 }
4546 fn cast(syntax: SyntaxNode) -> Option<Self> {
4547 let res = match syntax.kind() {
4548 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
4549 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
4550 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
4551 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
4552 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
4553 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
4554 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
4555 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
4556 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
4557 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
4558 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
4559 LABEL => Expr::Label(Label { syntax }),
4560 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
4561 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
4562 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
4563 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
4564 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
4565 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
4566 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
4567 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
4568 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
4569 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
4570 TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
4571 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
4572 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
4573 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
4574 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
4575 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
4576 LITERAL => Expr::Literal(Literal { syntax }),
4577 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
4578 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
4579 _ => return None,
4580 };
4581 Some(res)
4582 }
4583 fn syntax(&self) -> &SyntaxNode {
4584 match self {
4585 Expr::TupleExpr(it) => &it.syntax,
4586 Expr::ArrayExpr(it) => &it.syntax,
4587 Expr::ParenExpr(it) => &it.syntax,
4588 Expr::PathExpr(it) => &it.syntax,
4589 Expr::LambdaExpr(it) => &it.syntax,
4590 Expr::IfExpr(it) => &it.syntax,
4591 Expr::LoopExpr(it) => &it.syntax,
4592 Expr::ForExpr(it) => &it.syntax,
4593 Expr::WhileExpr(it) => &it.syntax,
4594 Expr::ContinueExpr(it) => &it.syntax,
4595 Expr::BreakExpr(it) => &it.syntax,
4596 Expr::Label(it) => &it.syntax,
4597 Expr::BlockExpr(it) => &it.syntax,
4598 Expr::ReturnExpr(it) => &it.syntax,
4599 Expr::MatchExpr(it) => &it.syntax,
4600 Expr::RecordLit(it) => &it.syntax,
4601 Expr::CallExpr(it) => &it.syntax,
4602 Expr::IndexExpr(it) => &it.syntax,
4603 Expr::MethodCallExpr(it) => &it.syntax,
4604 Expr::FieldExpr(it) => &it.syntax,
4605 Expr::AwaitExpr(it) => &it.syntax,
4606 Expr::TryExpr(it) => &it.syntax,
4607 Expr::TryBlockExpr(it) => &it.syntax,
4608 Expr::CastExpr(it) => &it.syntax,
4609 Expr::RefExpr(it) => &it.syntax,
4610 Expr::PrefixExpr(it) => &it.syntax,
4611 Expr::RangeExpr(it) => &it.syntax,
4612 Expr::BinExpr(it) => &it.syntax,
4613 Expr::Literal(it) => &it.syntax,
4614 Expr::MacroCall(it) => &it.syntax,
4615 Expr::BoxExpr(it) => &it.syntax,
4616 }
4617 }
4618}
4619#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4620pub enum Pat {
4621 OrPat(OrPat),
4622 ParenPat(ParenPat),
4623 RefPat(RefPat),
4624 BoxPat(BoxPat),
4625 BindPat(BindPat),
4626 PlaceholderPat(PlaceholderPat),
4627 DotDotPat(DotDotPat),
4628 PathPat(PathPat),
4629 RecordPat(RecordPat),
4630 TupleStructPat(TupleStructPat),
4631 TuplePat(TuplePat),
4632 SlicePat(SlicePat),
4633 RangePat(RangePat),
4634 LiteralPat(LiteralPat),
4635 MacroPat(MacroPat),
4636}
4637impl From<OrPat> for Pat {
4638 fn from(node: OrPat) -> Pat {
4639 Pat::OrPat(node)
4640 }
4641}
4642impl From<ParenPat> for Pat {
4643 fn from(node: ParenPat) -> Pat {
4644 Pat::ParenPat(node)
4645 }
4646}
4647impl From<RefPat> for Pat {
4648 fn from(node: RefPat) -> Pat {
4649 Pat::RefPat(node)
4650 }
4651}
4652impl From<BoxPat> for Pat {
4653 fn from(node: BoxPat) -> Pat {
4654 Pat::BoxPat(node)
4655 }
4656}
4657impl From<BindPat> for Pat {
4658 fn from(node: BindPat) -> Pat {
4659 Pat::BindPat(node)
4660 }
4661}
4662impl From<PlaceholderPat> for Pat {
4663 fn from(node: PlaceholderPat) -> Pat {
4664 Pat::PlaceholderPat(node)
4665 }
4666}
4667impl From<DotDotPat> for Pat {
4668 fn from(node: DotDotPat) -> Pat {
4669 Pat::DotDotPat(node)
4670 }
4671}
4672impl From<PathPat> for Pat {
4673 fn from(node: PathPat) -> Pat {
4674 Pat::PathPat(node)
4675 }
4676}
4677impl From<RecordPat> for Pat {
4678 fn from(node: RecordPat) -> Pat {
4679 Pat::RecordPat(node)
4680 }
4681}
4682impl From<TupleStructPat> for Pat {
4683 fn from(node: TupleStructPat) -> Pat {
4684 Pat::TupleStructPat(node)
4685 }
4686}
4687impl From<TuplePat> for Pat {
4688 fn from(node: TuplePat) -> Pat {
4689 Pat::TuplePat(node)
4690 }
4691}
4692impl From<SlicePat> for Pat {
4693 fn from(node: SlicePat) -> Pat {
4694 Pat::SlicePat(node)
4695 }
4696}
4697impl From<RangePat> for Pat {
4698 fn from(node: RangePat) -> Pat {
4699 Pat::RangePat(node)
4700 }
4701}
4702impl From<LiteralPat> for Pat {
4703 fn from(node: LiteralPat) -> Pat {
4704 Pat::LiteralPat(node)
4705 }
4706}
4707impl From<MacroPat> for Pat {
4708 fn from(node: MacroPat) -> Pat {
4709 Pat::MacroPat(node)
4710 }
4711}
4712impl std::fmt::Display for Pat {
4713 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4714 std::fmt::Display::fmt(self.syntax(), f)
4715 }
4716}
4717impl AstNode for Pat {
4718 fn can_cast(kind: SyntaxKind) -> bool {
4719 match kind {
4720 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
4721 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
4722 | LITERAL_PAT | MACRO_PAT => true,
4723 _ => false,
4724 }
4725 }
4726 fn cast(syntax: SyntaxNode) -> Option<Self> {
4727 let res = match syntax.kind() {
4728 OR_PAT => Pat::OrPat(OrPat { syntax }),
4729 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
4730 REF_PAT => Pat::RefPat(RefPat { syntax }),
4731 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
4732 BIND_PAT => Pat::BindPat(BindPat { syntax }),
4733 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
4734 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
4735 PATH_PAT => Pat::PathPat(PathPat { syntax }),
4736 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
4737 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
4738 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
4739 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
4740 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
4741 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
4742 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
4743 _ => return None,
4744 };
4745 Some(res)
4746 }
4747 fn syntax(&self) -> &SyntaxNode {
4748 match self {
4749 Pat::OrPat(it) => &it.syntax,
4750 Pat::ParenPat(it) => &it.syntax,
4751 Pat::RefPat(it) => &it.syntax,
4752 Pat::BoxPat(it) => &it.syntax,
4753 Pat::BindPat(it) => &it.syntax,
4754 Pat::PlaceholderPat(it) => &it.syntax,
4755 Pat::DotDotPat(it) => &it.syntax,
4756 Pat::PathPat(it) => &it.syntax,
4757 Pat::RecordPat(it) => &it.syntax,
4758 Pat::TupleStructPat(it) => &it.syntax,
4759 Pat::TuplePat(it) => &it.syntax,
4760 Pat::SlicePat(it) => &it.syntax,
4761 Pat::RangePat(it) => &it.syntax,
4762 Pat::LiteralPat(it) => &it.syntax,
4763 Pat::MacroPat(it) => &it.syntax,
4764 }
4765 }
4766}
4767#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4768pub enum AttrInput {
4769 Literal(Literal),
4770 TokenTree(TokenTree),
4771}
4772impl From<Literal> for AttrInput {
4773 fn from(node: Literal) -> AttrInput {
4774 AttrInput::Literal(node)
4775 }
4776}
4777impl From<TokenTree> for AttrInput {
4778 fn from(node: TokenTree) -> AttrInput {
4779 AttrInput::TokenTree(node)
4780 }
4781}
4782impl std::fmt::Display for AttrInput {
4783 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4784 std::fmt::Display::fmt(self.syntax(), f)
4785 }
4786}
4787impl AstNode for AttrInput {
4788 fn can_cast(kind: SyntaxKind) -> bool {
4789 match kind {
4790 LITERAL | TOKEN_TREE => true,
4791 _ => false,
4792 }
4793 }
4794 fn cast(syntax: SyntaxNode) -> Option<Self> {
4795 let res = match syntax.kind() {
4796 LITERAL => AttrInput::Literal(Literal { syntax }),
4797 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
4798 _ => return None,
4799 };
4800 Some(res)
4801 }
4802 fn syntax(&self) -> &SyntaxNode {
4803 match self {
4804 AttrInput::Literal(it) => &it.syntax,
4805 AttrInput::TokenTree(it) => &it.syntax,
4806 }
4807 }
4808}
4809#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4810pub enum Stmt {
4811 ExprStmt(ExprStmt),
4812 LetStmt(LetStmt),
4813}
4814impl From<ExprStmt> for Stmt {
4815 fn from(node: ExprStmt) -> Stmt {
4816 Stmt::ExprStmt(node)
4817 }
4818}
4819impl From<LetStmt> for Stmt {
4820 fn from(node: LetStmt) -> Stmt {
4821 Stmt::LetStmt(node)
4822 }
4823}
4824impl std::fmt::Display for Stmt {
4825 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4826 std::fmt::Display::fmt(self.syntax(), f)
4827 }
4828}
4829impl AstNode for Stmt {
4830 fn can_cast(kind: SyntaxKind) -> bool {
4831 match kind {
4832 EXPR_STMT | LET_STMT => true,
4833 _ => false,
4834 }
4835 }
4836 fn cast(syntax: SyntaxNode) -> Option<Self> {
4837 let res = match syntax.kind() {
4838 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
4839 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
4840 _ => return None,
4841 };
4842 Some(res)
4843 }
4844 fn syntax(&self) -> &SyntaxNode {
4845 match self {
4846 Stmt::ExprStmt(it) => &it.syntax,
4847 Stmt::LetStmt(it) => &it.syntax,
4848 }
4849 }
4850}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
new file mode 100644
index 000000000..bcbfd1129
--- /dev/null
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -0,0 +1,4180 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2
3use super::tokens::*;
4use crate::{
5 ast::{self, support, AstChildren, AstNode},
6 SyntaxKind::{self, *},
7 SyntaxNode,
8};
9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
10pub struct SourceFile {
11 pub(crate) syntax: SyntaxNode,
12}
13impl AstNode for SourceFile {
14 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
15 fn cast(syntax: SyntaxNode) -> Option<Self> {
16 if Self::can_cast(syntax.kind()) {
17 Some(Self { syntax })
18 } else {
19 None
20 }
21 }
22 fn syntax(&self) -> &SyntaxNode { &self.syntax }
23}
24impl ast::ModuleItemOwner for SourceFile {}
25impl ast::FnDefOwner for SourceFile {}
26impl ast::AttrsOwner for SourceFile {}
27impl SourceFile {
28 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) }
29}
30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31pub struct FnDef {
32 pub(crate) syntax: SyntaxNode,
33}
34impl AstNode for FnDef {
35 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
36 fn cast(syntax: SyntaxNode) -> Option<Self> {
37 if Self::can_cast(syntax.kind()) {
38 Some(Self { syntax })
39 } else {
40 None
41 }
42 }
43 fn syntax(&self) -> &SyntaxNode { &self.syntax }
44}
45impl ast::VisibilityOwner for FnDef {}
46impl ast::NameOwner for FnDef {}
47impl ast::TypeParamsOwner for FnDef {}
48impl ast::DocCommentsOwner for FnDef {}
49impl ast::AttrsOwner for FnDef {}
50impl FnDef {
51 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
52 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
53 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
54 pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) }
55 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
56 pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&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) }
59 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
60 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
61}
62#[derive(Debug, Clone, PartialEq, Eq, Hash)]
63pub struct RetType {
64 pub(crate) syntax: SyntaxNode,
65}
66impl AstNode for RetType {
67 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
68 fn cast(syntax: SyntaxNode) -> Option<Self> {
69 if Self::can_cast(syntax.kind()) {
70 Some(Self { syntax })
71 } else {
72 None
73 }
74 }
75 fn syntax(&self) -> &SyntaxNode { &self.syntax }
76}
77impl RetType {
78 pub fn thin_arrow_token(&self) -> Option<ThinArrow> { support::token(&self.syntax) }
79 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
80}
81#[derive(Debug, Clone, PartialEq, Eq, Hash)]
82pub struct StructDef {
83 pub(crate) syntax: SyntaxNode,
84}
85impl AstNode for StructDef {
86 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
87 fn cast(syntax: SyntaxNode) -> Option<Self> {
88 if Self::can_cast(syntax.kind()) {
89 Some(Self { syntax })
90 } else {
91 None
92 }
93 }
94 fn syntax(&self) -> &SyntaxNode { &self.syntax }
95}
96impl ast::VisibilityOwner for StructDef {}
97impl ast::NameOwner for StructDef {}
98impl ast::TypeParamsOwner for StructDef {}
99impl ast::AttrsOwner for StructDef {}
100impl ast::DocCommentsOwner for StructDef {}
101impl StructDef {
102 pub fn struct_kw_token(&self) -> Option<StructKw> { support::token(&self.syntax) }
103 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
104 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
105}
106#[derive(Debug, Clone, PartialEq, Eq, Hash)]
107pub struct UnionDef {
108 pub(crate) syntax: SyntaxNode,
109}
110impl AstNode for UnionDef {
111 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
112 fn cast(syntax: SyntaxNode) -> Option<Self> {
113 if Self::can_cast(syntax.kind()) {
114 Some(Self { syntax })
115 } else {
116 None
117 }
118 }
119 fn syntax(&self) -> &SyntaxNode { &self.syntax }
120}
121impl ast::VisibilityOwner for UnionDef {}
122impl ast::NameOwner for UnionDef {}
123impl ast::TypeParamsOwner for UnionDef {}
124impl ast::AttrsOwner for UnionDef {}
125impl ast::DocCommentsOwner for UnionDef {}
126impl UnionDef {
127 pub fn union_kw_token(&self) -> Option<UnionKw> { support::token(&self.syntax) }
128 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
129 support::child(&self.syntax)
130 }
131}
132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
133pub struct RecordFieldDefList {
134 pub(crate) syntax: SyntaxNode,
135}
136impl AstNode for RecordFieldDefList {
137 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
138 fn cast(syntax: SyntaxNode) -> Option<Self> {
139 if Self::can_cast(syntax.kind()) {
140 Some(Self { syntax })
141 } else {
142 None
143 }
144 }
145 fn syntax(&self) -> &SyntaxNode { &self.syntax }
146}
147impl RecordFieldDefList {
148 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
149 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) }
150 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
151}
152#[derive(Debug, Clone, PartialEq, Eq, Hash)]
153pub struct RecordFieldDef {
154 pub(crate) syntax: SyntaxNode,
155}
156impl AstNode for RecordFieldDef {
157 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
158 fn cast(syntax: SyntaxNode) -> Option<Self> {
159 if Self::can_cast(syntax.kind()) {
160 Some(Self { syntax })
161 } else {
162 None
163 }
164 }
165 fn syntax(&self) -> &SyntaxNode { &self.syntax }
166}
167impl ast::VisibilityOwner for RecordFieldDef {}
168impl ast::NameOwner for RecordFieldDef {}
169impl ast::AttrsOwner for RecordFieldDef {}
170impl ast::DocCommentsOwner for RecordFieldDef {}
171impl ast::TypeAscriptionOwner for RecordFieldDef {}
172impl RecordFieldDef {}
173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
174pub struct TupleFieldDefList {
175 pub(crate) syntax: SyntaxNode,
176}
177impl AstNode for TupleFieldDefList {
178 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST }
179 fn cast(syntax: SyntaxNode) -> Option<Self> {
180 if Self::can_cast(syntax.kind()) {
181 Some(Self { syntax })
182 } else {
183 None
184 }
185 }
186 fn syntax(&self) -> &SyntaxNode { &self.syntax }
187}
188impl TupleFieldDefList {
189 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
190 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
191 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
192}
193#[derive(Debug, Clone, PartialEq, Eq, Hash)]
194pub struct TupleFieldDef {
195 pub(crate) syntax: SyntaxNode,
196}
197impl AstNode for TupleFieldDef {
198 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
199 fn cast(syntax: SyntaxNode) -> Option<Self> {
200 if Self::can_cast(syntax.kind()) {
201 Some(Self { syntax })
202 } else {
203 None
204 }
205 }
206 fn syntax(&self) -> &SyntaxNode { &self.syntax }
207}
208impl ast::VisibilityOwner for TupleFieldDef {}
209impl ast::AttrsOwner for TupleFieldDef {}
210impl TupleFieldDef {
211 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
212}
213#[derive(Debug, Clone, PartialEq, Eq, Hash)]
214pub struct EnumDef {
215 pub(crate) syntax: SyntaxNode,
216}
217impl AstNode for EnumDef {
218 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
219 fn cast(syntax: SyntaxNode) -> Option<Self> {
220 if Self::can_cast(syntax.kind()) {
221 Some(Self { syntax })
222 } else {
223 None
224 }
225 }
226 fn syntax(&self) -> &SyntaxNode { &self.syntax }
227}
228impl ast::VisibilityOwner for EnumDef {}
229impl ast::NameOwner for EnumDef {}
230impl ast::TypeParamsOwner for EnumDef {}
231impl ast::AttrsOwner for EnumDef {}
232impl ast::DocCommentsOwner for EnumDef {}
233impl EnumDef {
234 pub fn enum_kw_token(&self) -> Option<EnumKw> { support::token(&self.syntax) }
235 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
236}
237#[derive(Debug, Clone, PartialEq, Eq, Hash)]
238pub struct EnumVariantList {
239 pub(crate) syntax: SyntaxNode,
240}
241impl AstNode for EnumVariantList {
242 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST }
243 fn cast(syntax: SyntaxNode) -> Option<Self> {
244 if Self::can_cast(syntax.kind()) {
245 Some(Self { syntax })
246 } else {
247 None
248 }
249 }
250 fn syntax(&self) -> &SyntaxNode { &self.syntax }
251}
252impl EnumVariantList {
253 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
254 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) }
255 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
256}
257#[derive(Debug, Clone, PartialEq, Eq, Hash)]
258pub struct EnumVariant {
259 pub(crate) syntax: SyntaxNode,
260}
261impl AstNode for EnumVariant {
262 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT }
263 fn cast(syntax: SyntaxNode) -> Option<Self> {
264 if Self::can_cast(syntax.kind()) {
265 Some(Self { syntax })
266 } else {
267 None
268 }
269 }
270 fn syntax(&self) -> &SyntaxNode { &self.syntax }
271}
272impl ast::VisibilityOwner for EnumVariant {}
273impl ast::NameOwner for EnumVariant {}
274impl ast::DocCommentsOwner for EnumVariant {}
275impl ast::AttrsOwner for EnumVariant {}
276impl EnumVariant {
277 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
278 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
279 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
280}
281#[derive(Debug, Clone, PartialEq, Eq, Hash)]
282pub struct TraitDef {
283 pub(crate) syntax: SyntaxNode,
284}
285impl AstNode for TraitDef {
286 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF }
287 fn cast(syntax: SyntaxNode) -> Option<Self> {
288 if Self::can_cast(syntax.kind()) {
289 Some(Self { syntax })
290 } else {
291 None
292 }
293 }
294 fn syntax(&self) -> &SyntaxNode { &self.syntax }
295}
296impl ast::VisibilityOwner for TraitDef {}
297impl ast::NameOwner for TraitDef {}
298impl ast::AttrsOwner for TraitDef {}
299impl ast::DocCommentsOwner for TraitDef {}
300impl ast::TypeParamsOwner for TraitDef {}
301impl ast::TypeBoundsOwner for TraitDef {}
302impl TraitDef {
303 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
304 pub fn auto_kw_token(&self) -> Option<AutoKw> { support::token(&self.syntax) }
305 pub fn trait_kw_token(&self) -> Option<TraitKw> { support::token(&self.syntax) }
306 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
307}
308#[derive(Debug, Clone, PartialEq, Eq, Hash)]
309pub struct Module {
310 pub(crate) syntax: SyntaxNode,
311}
312impl AstNode for Module {
313 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
314 fn cast(syntax: SyntaxNode) -> Option<Self> {
315 if Self::can_cast(syntax.kind()) {
316 Some(Self { syntax })
317 } else {
318 None
319 }
320 }
321 fn syntax(&self) -> &SyntaxNode { &self.syntax }
322}
323impl ast::VisibilityOwner for Module {}
324impl ast::NameOwner for Module {}
325impl ast::AttrsOwner for Module {}
326impl ast::DocCommentsOwner for Module {}
327impl Module {
328 pub fn mod_kw_token(&self) -> Option<ModKw> { support::token(&self.syntax) }
329 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
330 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
331}
332#[derive(Debug, Clone, PartialEq, Eq, Hash)]
333pub struct ItemList {
334 pub(crate) syntax: SyntaxNode,
335}
336impl AstNode for ItemList {
337 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
338 fn cast(syntax: SyntaxNode) -> Option<Self> {
339 if Self::can_cast(syntax.kind()) {
340 Some(Self { syntax })
341 } else {
342 None
343 }
344 }
345 fn syntax(&self) -> &SyntaxNode { &self.syntax }
346}
347impl ast::FnDefOwner for ItemList {}
348impl ast::ModuleItemOwner for ItemList {}
349impl ItemList {
350 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
351 pub fn impl_items(&self) -> AstChildren<ImplItem> { support::children(&self.syntax) }
352 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
353}
354#[derive(Debug, Clone, PartialEq, Eq, Hash)]
355pub struct ConstDef {
356 pub(crate) syntax: SyntaxNode,
357}
358impl AstNode for ConstDef {
359 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
360 fn cast(syntax: SyntaxNode) -> Option<Self> {
361 if Self::can_cast(syntax.kind()) {
362 Some(Self { syntax })
363 } else {
364 None
365 }
366 }
367 fn syntax(&self) -> &SyntaxNode { &self.syntax }
368}
369impl ast::VisibilityOwner for ConstDef {}
370impl ast::NameOwner for ConstDef {}
371impl ast::TypeParamsOwner for ConstDef {}
372impl ast::AttrsOwner for ConstDef {}
373impl ast::DocCommentsOwner for ConstDef {}
374impl ast::TypeAscriptionOwner for ConstDef {}
375impl ConstDef {
376 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
377 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
378 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
379 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
380 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
381}
382#[derive(Debug, Clone, PartialEq, Eq, Hash)]
383pub struct StaticDef {
384 pub(crate) syntax: SyntaxNode,
385}
386impl AstNode for StaticDef {
387 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF }
388 fn cast(syntax: SyntaxNode) -> Option<Self> {
389 if Self::can_cast(syntax.kind()) {
390 Some(Self { syntax })
391 } else {
392 None
393 }
394 }
395 fn syntax(&self) -> &SyntaxNode { &self.syntax }
396}
397impl ast::VisibilityOwner for StaticDef {}
398impl ast::NameOwner for StaticDef {}
399impl ast::TypeParamsOwner for StaticDef {}
400impl ast::AttrsOwner for StaticDef {}
401impl ast::DocCommentsOwner for StaticDef {}
402impl ast::TypeAscriptionOwner for StaticDef {}
403impl StaticDef {
404 pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) }
405 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
406 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
407 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
408 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
409}
410#[derive(Debug, Clone, PartialEq, Eq, Hash)]
411pub struct TypeAliasDef {
412 pub(crate) syntax: SyntaxNode,
413}
414impl AstNode for TypeAliasDef {
415 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF }
416 fn cast(syntax: SyntaxNode) -> Option<Self> {
417 if Self::can_cast(syntax.kind()) {
418 Some(Self { syntax })
419 } else {
420 None
421 }
422 }
423 fn syntax(&self) -> &SyntaxNode { &self.syntax }
424}
425impl ast::VisibilityOwner for TypeAliasDef {}
426impl ast::NameOwner for TypeAliasDef {}
427impl ast::TypeParamsOwner for TypeAliasDef {}
428impl ast::AttrsOwner for TypeAliasDef {}
429impl ast::DocCommentsOwner for TypeAliasDef {}
430impl ast::TypeBoundsOwner for TypeAliasDef {}
431impl TypeAliasDef {
432 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
433 pub fn type_kw_token(&self) -> Option<TypeKw> { support::token(&self.syntax) }
434 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
435 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
436 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
437}
438#[derive(Debug, Clone, PartialEq, Eq, Hash)]
439pub struct ImplDef {
440 pub(crate) syntax: SyntaxNode,
441}
442impl AstNode for ImplDef {
443 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF }
444 fn cast(syntax: SyntaxNode) -> Option<Self> {
445 if Self::can_cast(syntax.kind()) {
446 Some(Self { syntax })
447 } else {
448 None
449 }
450 }
451 fn syntax(&self) -> &SyntaxNode { &self.syntax }
452}
453impl ast::TypeParamsOwner for ImplDef {}
454impl ast::AttrsOwner for ImplDef {}
455impl ImplDef {
456 pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
457 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
458 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
459 pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) }
460 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
461 pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) }
462 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
463}
464#[derive(Debug, Clone, PartialEq, Eq, Hash)]
465pub struct ParenType {
466 pub(crate) syntax: SyntaxNode,
467}
468impl AstNode for ParenType {
469 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE }
470 fn cast(syntax: SyntaxNode) -> Option<Self> {
471 if Self::can_cast(syntax.kind()) {
472 Some(Self { syntax })
473 } else {
474 None
475 }
476 }
477 fn syntax(&self) -> &SyntaxNode { &self.syntax }
478}
479impl ParenType {
480 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
481 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
482 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
483}
484#[derive(Debug, Clone, PartialEq, Eq, Hash)]
485pub struct TupleType {
486 pub(crate) syntax: SyntaxNode,
487}
488impl AstNode for TupleType {
489 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE }
490 fn cast(syntax: SyntaxNode) -> Option<Self> {
491 if Self::can_cast(syntax.kind()) {
492 Some(Self { syntax })
493 } else {
494 None
495 }
496 }
497 fn syntax(&self) -> &SyntaxNode { &self.syntax }
498}
499impl TupleType {
500 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
501 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
502 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
503}
504#[derive(Debug, Clone, PartialEq, Eq, Hash)]
505pub struct NeverType {
506 pub(crate) syntax: SyntaxNode,
507}
508impl AstNode for NeverType {
509 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
510 fn cast(syntax: SyntaxNode) -> Option<Self> {
511 if Self::can_cast(syntax.kind()) {
512 Some(Self { syntax })
513 } else {
514 None
515 }
516 }
517 fn syntax(&self) -> &SyntaxNode { &self.syntax }
518}
519impl NeverType {
520 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
521}
522#[derive(Debug, Clone, PartialEq, Eq, Hash)]
523pub struct PathType {
524 pub(crate) syntax: SyntaxNode,
525}
526impl AstNode for PathType {
527 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE }
528 fn cast(syntax: SyntaxNode) -> Option<Self> {
529 if Self::can_cast(syntax.kind()) {
530 Some(Self { syntax })
531 } else {
532 None
533 }
534 }
535 fn syntax(&self) -> &SyntaxNode { &self.syntax }
536}
537impl PathType {
538 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
539}
540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
541pub struct PointerType {
542 pub(crate) syntax: SyntaxNode,
543}
544impl AstNode for PointerType {
545 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
546 fn cast(syntax: SyntaxNode) -> Option<Self> {
547 if Self::can_cast(syntax.kind()) {
548 Some(Self { syntax })
549 } else {
550 None
551 }
552 }
553 fn syntax(&self) -> &SyntaxNode { &self.syntax }
554}
555impl PointerType {
556 pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) }
557 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
558 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
559 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
560}
561#[derive(Debug, Clone, PartialEq, Eq, Hash)]
562pub struct ArrayType {
563 pub(crate) syntax: SyntaxNode,
564}
565impl AstNode for ArrayType {
566 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE }
567 fn cast(syntax: SyntaxNode) -> Option<Self> {
568 if Self::can_cast(syntax.kind()) {
569 Some(Self { syntax })
570 } else {
571 None
572 }
573 }
574 fn syntax(&self) -> &SyntaxNode { &self.syntax }
575}
576impl ArrayType {
577 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
578 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
579 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
580 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
581 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
582}
583#[derive(Debug, Clone, PartialEq, Eq, Hash)]
584pub struct SliceType {
585 pub(crate) syntax: SyntaxNode,
586}
587impl AstNode for SliceType {
588 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE }
589 fn cast(syntax: SyntaxNode) -> Option<Self> {
590 if Self::can_cast(syntax.kind()) {
591 Some(Self { syntax })
592 } else {
593 None
594 }
595 }
596 fn syntax(&self) -> &SyntaxNode { &self.syntax }
597}
598impl SliceType {
599 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
600 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
601 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
602}
603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
604pub struct ReferenceType {
605 pub(crate) syntax: SyntaxNode,
606}
607impl AstNode for ReferenceType {
608 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE }
609 fn cast(syntax: SyntaxNode) -> Option<Self> {
610 if Self::can_cast(syntax.kind()) {
611 Some(Self { syntax })
612 } else {
613 None
614 }
615 }
616 fn syntax(&self) -> &SyntaxNode { &self.syntax }
617}
618impl ReferenceType {
619 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
620 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
621 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
622 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
623}
624#[derive(Debug, Clone, PartialEq, Eq, Hash)]
625pub struct PlaceholderType {
626 pub(crate) syntax: SyntaxNode,
627}
628impl AstNode for PlaceholderType {
629 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE }
630 fn cast(syntax: SyntaxNode) -> Option<Self> {
631 if Self::can_cast(syntax.kind()) {
632 Some(Self { syntax })
633 } else {
634 None
635 }
636 }
637 fn syntax(&self) -> &SyntaxNode { &self.syntax }
638}
639impl PlaceholderType {
640 pub fn underscore_token(&self) -> Option<Underscore> { support::token(&self.syntax) }
641}
642#[derive(Debug, Clone, PartialEq, Eq, Hash)]
643pub struct FnPointerType {
644 pub(crate) syntax: SyntaxNode,
645}
646impl AstNode for FnPointerType {
647 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE }
648 fn cast(syntax: SyntaxNode) -> Option<Self> {
649 if Self::can_cast(syntax.kind()) {
650 Some(Self { syntax })
651 } else {
652 None
653 }
654 }
655 fn syntax(&self) -> &SyntaxNode { &self.syntax }
656}
657impl FnPointerType {
658 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
659 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
660 pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) }
661 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
662 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
663}
664#[derive(Debug, Clone, PartialEq, Eq, Hash)]
665pub struct ForType {
666 pub(crate) syntax: SyntaxNode,
667}
668impl AstNode for ForType {
669 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE }
670 fn cast(syntax: SyntaxNode) -> Option<Self> {
671 if Self::can_cast(syntax.kind()) {
672 Some(Self { syntax })
673 } else {
674 None
675 }
676 }
677 fn syntax(&self) -> &SyntaxNode { &self.syntax }
678}
679impl ForType {
680 pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) }
681 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
682 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
683}
684#[derive(Debug, Clone, PartialEq, Eq, Hash)]
685pub struct ImplTraitType {
686 pub(crate) syntax: SyntaxNode,
687}
688impl AstNode for ImplTraitType {
689 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE }
690 fn cast(syntax: SyntaxNode) -> Option<Self> {
691 if Self::can_cast(syntax.kind()) {
692 Some(Self { syntax })
693 } else {
694 None
695 }
696 }
697 fn syntax(&self) -> &SyntaxNode { &self.syntax }
698}
699impl ast::TypeBoundsOwner for ImplTraitType {}
700impl ImplTraitType {
701 pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) }
702}
703#[derive(Debug, Clone, PartialEq, Eq, Hash)]
704pub struct DynTraitType {
705 pub(crate) syntax: SyntaxNode,
706}
707impl AstNode for DynTraitType {
708 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE }
709 fn cast(syntax: SyntaxNode) -> Option<Self> {
710 if Self::can_cast(syntax.kind()) {
711 Some(Self { syntax })
712 } else {
713 None
714 }
715 }
716 fn syntax(&self) -> &SyntaxNode { &self.syntax }
717}
718impl ast::TypeBoundsOwner for DynTraitType {}
719impl DynTraitType {
720 pub fn dyn_kw_token(&self) -> Option<DynKw> { support::token(&self.syntax) }
721}
722#[derive(Debug, Clone, PartialEq, Eq, Hash)]
723pub struct TupleExpr {
724 pub(crate) syntax: SyntaxNode,
725}
726impl AstNode for TupleExpr {
727 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR }
728 fn cast(syntax: SyntaxNode) -> Option<Self> {
729 if Self::can_cast(syntax.kind()) {
730 Some(Self { syntax })
731 } else {
732 None
733 }
734 }
735 fn syntax(&self) -> &SyntaxNode { &self.syntax }
736}
737impl ast::AttrsOwner for TupleExpr {}
738impl TupleExpr {
739 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
740 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
741 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
742}
743#[derive(Debug, Clone, PartialEq, Eq, Hash)]
744pub struct ArrayExpr {
745 pub(crate) syntax: SyntaxNode,
746}
747impl AstNode for ArrayExpr {
748 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR }
749 fn cast(syntax: SyntaxNode) -> Option<Self> {
750 if Self::can_cast(syntax.kind()) {
751 Some(Self { syntax })
752 } else {
753 None
754 }
755 }
756 fn syntax(&self) -> &SyntaxNode { &self.syntax }
757}
758impl ast::AttrsOwner for ArrayExpr {}
759impl ArrayExpr {
760 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
761 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
762 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
763 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
764}
765#[derive(Debug, Clone, PartialEq, Eq, Hash)]
766pub struct ParenExpr {
767 pub(crate) syntax: SyntaxNode,
768}
769impl AstNode for ParenExpr {
770 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
771 fn cast(syntax: SyntaxNode) -> Option<Self> {
772 if Self::can_cast(syntax.kind()) {
773 Some(Self { syntax })
774 } else {
775 None
776 }
777 }
778 fn syntax(&self) -> &SyntaxNode { &self.syntax }
779}
780impl ast::AttrsOwner for ParenExpr {}
781impl ParenExpr {
782 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
783 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
784 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
785}
786#[derive(Debug, Clone, PartialEq, Eq, Hash)]
787pub struct PathExpr {
788 pub(crate) syntax: SyntaxNode,
789}
790impl AstNode for PathExpr {
791 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR }
792 fn cast(syntax: SyntaxNode) -> Option<Self> {
793 if Self::can_cast(syntax.kind()) {
794 Some(Self { syntax })
795 } else {
796 None
797 }
798 }
799 fn syntax(&self) -> &SyntaxNode { &self.syntax }
800}
801impl PathExpr {
802 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
803}
804#[derive(Debug, Clone, PartialEq, Eq, Hash)]
805pub struct LambdaExpr {
806 pub(crate) syntax: SyntaxNode,
807}
808impl AstNode for LambdaExpr {
809 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR }
810 fn cast(syntax: SyntaxNode) -> Option<Self> {
811 if Self::can_cast(syntax.kind()) {
812 Some(Self { syntax })
813 } else {
814 None
815 }
816 }
817 fn syntax(&self) -> &SyntaxNode { &self.syntax }
818}
819impl ast::AttrsOwner for LambdaExpr {}
820impl LambdaExpr {
821 pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) }
822 pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) }
823 pub fn move_kw_token(&self) -> Option<MoveKw> { support::token(&self.syntax) }
824 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
825 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
826 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
827}
828#[derive(Debug, Clone, PartialEq, Eq, Hash)]
829pub struct IfExpr {
830 pub(crate) syntax: SyntaxNode,
831}
832impl AstNode for IfExpr {
833 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
834 fn cast(syntax: SyntaxNode) -> Option<Self> {
835 if Self::can_cast(syntax.kind()) {
836 Some(Self { syntax })
837 } else {
838 None
839 }
840 }
841 fn syntax(&self) -> &SyntaxNode { &self.syntax }
842}
843impl ast::AttrsOwner for IfExpr {}
844impl IfExpr {
845 pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) }
846 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
847}
848#[derive(Debug, Clone, PartialEq, Eq, Hash)]
849pub struct LoopExpr {
850 pub(crate) syntax: SyntaxNode,
851}
852impl AstNode for LoopExpr {
853 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
854 fn cast(syntax: SyntaxNode) -> Option<Self> {
855 if Self::can_cast(syntax.kind()) {
856 Some(Self { syntax })
857 } else {
858 None
859 }
860 }
861 fn syntax(&self) -> &SyntaxNode { &self.syntax }
862}
863impl ast::AttrsOwner for LoopExpr {}
864impl ast::LoopBodyOwner for LoopExpr {}
865impl LoopExpr {
866 pub fn loop_kw_token(&self) -> Option<LoopKw> { support::token(&self.syntax) }
867}
868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
869pub struct TryBlockExpr {
870 pub(crate) syntax: SyntaxNode,
871}
872impl AstNode for TryBlockExpr {
873 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_EXPR }
874 fn cast(syntax: SyntaxNode) -> Option<Self> {
875 if Self::can_cast(syntax.kind()) {
876 Some(Self { syntax })
877 } else {
878 None
879 }
880 }
881 fn syntax(&self) -> &SyntaxNode { &self.syntax }
882}
883impl ast::AttrsOwner for TryBlockExpr {}
884impl TryBlockExpr {
885 pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) }
886 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
887}
888#[derive(Debug, Clone, PartialEq, Eq, Hash)]
889pub struct ForExpr {
890 pub(crate) syntax: SyntaxNode,
891}
892impl AstNode for ForExpr {
893 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR }
894 fn cast(syntax: SyntaxNode) -> Option<Self> {
895 if Self::can_cast(syntax.kind()) {
896 Some(Self { syntax })
897 } else {
898 None
899 }
900 }
901 fn syntax(&self) -> &SyntaxNode { &self.syntax }
902}
903impl ast::AttrsOwner for ForExpr {}
904impl ast::LoopBodyOwner for ForExpr {}
905impl ForExpr {
906 pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) }
907 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
908 pub fn in_kw_token(&self) -> Option<InKw> { support::token(&self.syntax) }
909 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
910}
911#[derive(Debug, Clone, PartialEq, Eq, Hash)]
912pub struct WhileExpr {
913 pub(crate) syntax: SyntaxNode,
914}
915impl AstNode for WhileExpr {
916 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR }
917 fn cast(syntax: SyntaxNode) -> Option<Self> {
918 if Self::can_cast(syntax.kind()) {
919 Some(Self { syntax })
920 } else {
921 None
922 }
923 }
924 fn syntax(&self) -> &SyntaxNode { &self.syntax }
925}
926impl ast::AttrsOwner for WhileExpr {}
927impl ast::LoopBodyOwner for WhileExpr {}
928impl WhileExpr {
929 pub fn while_kw_token(&self) -> Option<WhileKw> { support::token(&self.syntax) }
930 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
931}
932#[derive(Debug, Clone, PartialEq, Eq, Hash)]
933pub struct ContinueExpr {
934 pub(crate) syntax: SyntaxNode,
935}
936impl AstNode for ContinueExpr {
937 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR }
938 fn cast(syntax: SyntaxNode) -> Option<Self> {
939 if Self::can_cast(syntax.kind()) {
940 Some(Self { syntax })
941 } else {
942 None
943 }
944 }
945 fn syntax(&self) -> &SyntaxNode { &self.syntax }
946}
947impl ast::AttrsOwner for ContinueExpr {}
948impl ContinueExpr {
949 pub fn continue_kw_token(&self) -> Option<ContinueKw> { support::token(&self.syntax) }
950 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
951}
952#[derive(Debug, Clone, PartialEq, Eq, Hash)]
953pub struct BreakExpr {
954 pub(crate) syntax: SyntaxNode,
955}
956impl AstNode for BreakExpr {
957 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
958 fn cast(syntax: SyntaxNode) -> Option<Self> {
959 if Self::can_cast(syntax.kind()) {
960 Some(Self { syntax })
961 } else {
962 None
963 }
964 }
965 fn syntax(&self) -> &SyntaxNode { &self.syntax }
966}
967impl ast::AttrsOwner for BreakExpr {}
968impl BreakExpr {
969 pub fn break_kw_token(&self) -> Option<BreakKw> { support::token(&self.syntax) }
970 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
971 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
972}
973#[derive(Debug, Clone, PartialEq, Eq, Hash)]
974pub struct Label {
975 pub(crate) syntax: SyntaxNode,
976}
977impl AstNode for Label {
978 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
979 fn cast(syntax: SyntaxNode) -> Option<Self> {
980 if Self::can_cast(syntax.kind()) {
981 Some(Self { syntax })
982 } else {
983 None
984 }
985 }
986 fn syntax(&self) -> &SyntaxNode { &self.syntax }
987}
988impl Label {
989 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
990}
991#[derive(Debug, Clone, PartialEq, Eq, Hash)]
992pub struct BlockExpr {
993 pub(crate) syntax: SyntaxNode,
994}
995impl AstNode for BlockExpr {
996 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
997 fn cast(syntax: SyntaxNode) -> Option<Self> {
998 if Self::can_cast(syntax.kind()) {
999 Some(Self { syntax })
1000 } else {
1001 None
1002 }
1003 }
1004 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1005}
1006impl ast::AttrsOwner for BlockExpr {}
1007impl BlockExpr {
1008 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1009 pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
1010 pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
1011}
1012#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1013pub struct ReturnExpr {
1014 pub(crate) syntax: SyntaxNode,
1015}
1016impl AstNode for ReturnExpr {
1017 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR }
1018 fn cast(syntax: SyntaxNode) -> Option<Self> {
1019 if Self::can_cast(syntax.kind()) {
1020 Some(Self { syntax })
1021 } else {
1022 None
1023 }
1024 }
1025 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1026}
1027impl ast::AttrsOwner for ReturnExpr {}
1028impl ReturnExpr {
1029 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1030}
1031#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1032pub struct CallExpr {
1033 pub(crate) syntax: SyntaxNode,
1034}
1035impl AstNode for CallExpr {
1036 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR }
1037 fn cast(syntax: SyntaxNode) -> Option<Self> {
1038 if Self::can_cast(syntax.kind()) {
1039 Some(Self { syntax })
1040 } else {
1041 None
1042 }
1043 }
1044 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1045}
1046impl ast::ArgListOwner for CallExpr {}
1047impl CallExpr {
1048 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1049}
1050#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1051pub struct MethodCallExpr {
1052 pub(crate) syntax: SyntaxNode,
1053}
1054impl AstNode for MethodCallExpr {
1055 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR }
1056 fn cast(syntax: SyntaxNode) -> Option<Self> {
1057 if Self::can_cast(syntax.kind()) {
1058 Some(Self { syntax })
1059 } else {
1060 None
1061 }
1062 }
1063 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1064}
1065impl ast::AttrsOwner for MethodCallExpr {}
1066impl ast::ArgListOwner for MethodCallExpr {}
1067impl MethodCallExpr {
1068 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1069 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) }
1070 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1071 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1072}
1073#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1074pub struct IndexExpr {
1075 pub(crate) syntax: SyntaxNode,
1076}
1077impl AstNode for IndexExpr {
1078 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR }
1079 fn cast(syntax: SyntaxNode) -> Option<Self> {
1080 if Self::can_cast(syntax.kind()) {
1081 Some(Self { syntax })
1082 } else {
1083 None
1084 }
1085 }
1086 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1087}
1088impl ast::AttrsOwner for IndexExpr {}
1089impl IndexExpr {
1090 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
1091 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
1092}
1093#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1094pub struct FieldExpr {
1095 pub(crate) syntax: SyntaxNode,
1096}
1097impl AstNode for FieldExpr {
1098 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR }
1099 fn cast(syntax: SyntaxNode) -> Option<Self> {
1100 if Self::can_cast(syntax.kind()) {
1101 Some(Self { syntax })
1102 } else {
1103 None
1104 }
1105 }
1106 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1107}
1108impl ast::AttrsOwner for FieldExpr {}
1109impl FieldExpr {
1110 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1111 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) }
1112 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1113}
1114#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1115pub struct AwaitExpr {
1116 pub(crate) syntax: SyntaxNode,
1117}
1118impl AstNode for AwaitExpr {
1119 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
1120 fn cast(syntax: SyntaxNode) -> Option<Self> {
1121 if Self::can_cast(syntax.kind()) {
1122 Some(Self { syntax })
1123 } else {
1124 None
1125 }
1126 }
1127 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1128}
1129impl ast::AttrsOwner for AwaitExpr {}
1130impl AwaitExpr {
1131 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1132 pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) }
1133 pub fn await_kw_token(&self) -> Option<AwaitKw> { support::token(&self.syntax) }
1134}
1135#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1136pub struct TryExpr {
1137 pub(crate) syntax: SyntaxNode,
1138}
1139impl AstNode for TryExpr {
1140 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR }
1141 fn cast(syntax: SyntaxNode) -> Option<Self> {
1142 if Self::can_cast(syntax.kind()) {
1143 Some(Self { syntax })
1144 } else {
1145 None
1146 }
1147 }
1148 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1149}
1150impl ast::AttrsOwner for TryExpr {}
1151impl TryExpr {
1152 pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) }
1153 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1154}
1155#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1156pub struct CastExpr {
1157 pub(crate) syntax: SyntaxNode,
1158}
1159impl AstNode for CastExpr {
1160 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR }
1161 fn cast(syntax: SyntaxNode) -> Option<Self> {
1162 if Self::can_cast(syntax.kind()) {
1163 Some(Self { syntax })
1164 } else {
1165 None
1166 }
1167 }
1168 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1169}
1170impl ast::AttrsOwner for CastExpr {}
1171impl CastExpr {
1172 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1173 pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) }
1174 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1175}
1176#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1177pub struct RefExpr {
1178 pub(crate) syntax: SyntaxNode,
1179}
1180impl AstNode for RefExpr {
1181 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR }
1182 fn cast(syntax: SyntaxNode) -> Option<Self> {
1183 if Self::can_cast(syntax.kind()) {
1184 Some(Self { syntax })
1185 } else {
1186 None
1187 }
1188 }
1189 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1190}
1191impl ast::AttrsOwner for RefExpr {}
1192impl RefExpr {
1193 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
1194 pub fn raw_kw_token(&self) -> Option<RawKw> { support::token(&self.syntax) }
1195 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
1196 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1197}
1198#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1199pub struct PrefixExpr {
1200 pub(crate) syntax: SyntaxNode,
1201}
1202impl AstNode for PrefixExpr {
1203 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR }
1204 fn cast(syntax: SyntaxNode) -> Option<Self> {
1205 if Self::can_cast(syntax.kind()) {
1206 Some(Self { syntax })
1207 } else {
1208 None
1209 }
1210 }
1211 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1212}
1213impl ast::AttrsOwner for PrefixExpr {}
1214impl PrefixExpr {
1215 pub fn prefix_op_token(&self) -> Option<PrefixOp> { support::token(&self.syntax) }
1216 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1217}
1218#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1219pub struct BoxExpr {
1220 pub(crate) syntax: SyntaxNode,
1221}
1222impl AstNode for BoxExpr {
1223 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR }
1224 fn cast(syntax: SyntaxNode) -> Option<Self> {
1225 if Self::can_cast(syntax.kind()) {
1226 Some(Self { syntax })
1227 } else {
1228 None
1229 }
1230 }
1231 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1232}
1233impl ast::AttrsOwner for BoxExpr {}
1234impl BoxExpr {
1235 pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) }
1236 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1237}
1238#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1239pub struct RangeExpr {
1240 pub(crate) syntax: SyntaxNode,
1241}
1242impl AstNode for RangeExpr {
1243 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR }
1244 fn cast(syntax: SyntaxNode) -> Option<Self> {
1245 if Self::can_cast(syntax.kind()) {
1246 Some(Self { syntax })
1247 } else {
1248 None
1249 }
1250 }
1251 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1252}
1253impl ast::AttrsOwner for RangeExpr {}
1254impl RangeExpr {
1255 pub fn range_op_token(&self) -> Option<RangeOp> { support::token(&self.syntax) }
1256}
1257#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1258pub struct BinExpr {
1259 pub(crate) syntax: SyntaxNode,
1260}
1261impl AstNode for BinExpr {
1262 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR }
1263 fn cast(syntax: SyntaxNode) -> Option<Self> {
1264 if Self::can_cast(syntax.kind()) {
1265 Some(Self { syntax })
1266 } else {
1267 None
1268 }
1269 }
1270 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1271}
1272impl ast::AttrsOwner for BinExpr {}
1273impl BinExpr {
1274 pub fn bin_op_token(&self) -> Option<BinOp> { support::token(&self.syntax) }
1275}
1276#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1277pub struct Literal {
1278 pub(crate) syntax: SyntaxNode,
1279}
1280impl AstNode for Literal {
1281 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
1282 fn cast(syntax: SyntaxNode) -> Option<Self> {
1283 if Self::can_cast(syntax.kind()) {
1284 Some(Self { syntax })
1285 } else {
1286 None
1287 }
1288 }
1289 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1290}
1291impl Literal {
1292 pub fn literal_token_token(&self) -> Option<LiteralToken> { support::token(&self.syntax) }
1293}
1294#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1295pub struct MatchExpr {
1296 pub(crate) syntax: SyntaxNode,
1297}
1298impl AstNode for MatchExpr {
1299 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR }
1300 fn cast(syntax: SyntaxNode) -> Option<Self> {
1301 if Self::can_cast(syntax.kind()) {
1302 Some(Self { syntax })
1303 } else {
1304 None
1305 }
1306 }
1307 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1308}
1309impl ast::AttrsOwner for MatchExpr {}
1310impl MatchExpr {
1311 pub fn match_kw_token(&self) -> Option<MatchKw> { support::token(&self.syntax) }
1312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1313 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1314}
1315#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1316pub struct MatchArmList {
1317 pub(crate) syntax: SyntaxNode,
1318}
1319impl AstNode for MatchArmList {
1320 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST }
1321 fn cast(syntax: SyntaxNode) -> Option<Self> {
1322 if Self::can_cast(syntax.kind()) {
1323 Some(Self { syntax })
1324 } else {
1325 None
1326 }
1327 }
1328 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1329}
1330impl ast::AttrsOwner for MatchArmList {}
1331impl MatchArmList {
1332 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
1333 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1334 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
1335}
1336#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1337pub struct MatchArm {
1338 pub(crate) syntax: SyntaxNode,
1339}
1340impl AstNode for MatchArm {
1341 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM }
1342 fn cast(syntax: SyntaxNode) -> Option<Self> {
1343 if Self::can_cast(syntax.kind()) {
1344 Some(Self { syntax })
1345 } else {
1346 None
1347 }
1348 }
1349 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1350}
1351impl ast::AttrsOwner for MatchArm {}
1352impl MatchArm {
1353 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1354 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
1355 pub fn fat_arrow_token(&self) -> Option<FatArrow> { support::token(&self.syntax) }
1356 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1357}
1358#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1359pub struct MatchGuard {
1360 pub(crate) syntax: SyntaxNode,
1361}
1362impl AstNode for MatchGuard {
1363 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD }
1364 fn cast(syntax: SyntaxNode) -> Option<Self> {
1365 if Self::can_cast(syntax.kind()) {
1366 Some(Self { syntax })
1367 } else {
1368 None
1369 }
1370 }
1371 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1372}
1373impl MatchGuard {
1374 pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) }
1375 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1376}
1377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1378pub struct RecordLit {
1379 pub(crate) syntax: SyntaxNode,
1380}
1381impl AstNode for RecordLit {
1382 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT }
1383 fn cast(syntax: SyntaxNode) -> Option<Self> {
1384 if Self::can_cast(syntax.kind()) {
1385 Some(Self { syntax })
1386 } else {
1387 None
1388 }
1389 }
1390 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1391}
1392impl RecordLit {
1393 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1394 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
1395}
1396#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1397pub struct RecordFieldList {
1398 pub(crate) syntax: SyntaxNode,
1399}
1400impl AstNode for RecordFieldList {
1401 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
1402 fn cast(syntax: SyntaxNode) -> Option<Self> {
1403 if Self::can_cast(syntax.kind()) {
1404 Some(Self { syntax })
1405 } else {
1406 None
1407 }
1408 }
1409 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1410}
1411impl RecordFieldList {
1412 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
1413 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
1414 pub fn dotdot_token(&self) -> Option<Dotdot> { support::token(&self.syntax) }
1415 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1416 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
1417}
1418#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1419pub struct RecordField {
1420 pub(crate) syntax: SyntaxNode,
1421}
1422impl AstNode for RecordField {
1423 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
1424 fn cast(syntax: SyntaxNode) -> Option<Self> {
1425 if Self::can_cast(syntax.kind()) {
1426 Some(Self { syntax })
1427 } else {
1428 None
1429 }
1430 }
1431 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1432}
1433impl ast::AttrsOwner for RecordField {}
1434impl RecordField {
1435 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1436 pub fn colon_token(&self) -> Option<Colon> { support::token(&self.syntax) }
1437 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1438}
1439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1440pub struct OrPat {
1441 pub(crate) syntax: SyntaxNode,
1442}
1443impl AstNode for OrPat {
1444 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT }
1445 fn cast(syntax: SyntaxNode) -> Option<Self> {
1446 if Self::can_cast(syntax.kind()) {
1447 Some(Self { syntax })
1448 } else {
1449 None
1450 }
1451 }
1452 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1453}
1454impl OrPat {
1455 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1456}
1457#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1458pub struct ParenPat {
1459 pub(crate) syntax: SyntaxNode,
1460}
1461impl AstNode for ParenPat {
1462 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT }
1463 fn cast(syntax: SyntaxNode) -> Option<Self> {
1464 if Self::can_cast(syntax.kind()) {
1465 Some(Self { syntax })
1466 } else {
1467 None
1468 }
1469 }
1470 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1471}
1472impl ParenPat {
1473 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
1474 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1475 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
1476}
1477#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1478pub struct RefPat {
1479 pub(crate) syntax: SyntaxNode,
1480}
1481impl AstNode for RefPat {
1482 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT }
1483 fn cast(syntax: SyntaxNode) -> Option<Self> {
1484 if Self::can_cast(syntax.kind()) {
1485 Some(Self { syntax })
1486 } else {
1487 None
1488 }
1489 }
1490 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1491}
1492impl RefPat {
1493 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
1494 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
1495 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1496}
1497#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1498pub struct BoxPat {
1499 pub(crate) syntax: SyntaxNode,
1500}
1501impl AstNode for BoxPat {
1502 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT }
1503 fn cast(syntax: SyntaxNode) -> Option<Self> {
1504 if Self::can_cast(syntax.kind()) {
1505 Some(Self { syntax })
1506 } else {
1507 None
1508 }
1509 }
1510 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1511}
1512impl BoxPat {
1513 pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) }
1514 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1515}
1516#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1517pub struct BindPat {
1518 pub(crate) syntax: SyntaxNode,
1519}
1520impl AstNode for BindPat {
1521 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT }
1522 fn cast(syntax: SyntaxNode) -> Option<Self> {
1523 if Self::can_cast(syntax.kind()) {
1524 Some(Self { syntax })
1525 } else {
1526 None
1527 }
1528 }
1529 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1530}
1531impl ast::AttrsOwner for BindPat {}
1532impl ast::NameOwner for BindPat {}
1533impl BindPat {
1534 pub fn ref_kw_token(&self) -> Option<RefKw> { support::token(&self.syntax) }
1535 pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
1536 pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) }
1537 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1538}
1539#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1540pub struct PlaceholderPat {
1541 pub(crate) syntax: SyntaxNode,
1542}
1543impl AstNode for PlaceholderPat {
1544 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT }
1545 fn cast(syntax: SyntaxNode) -> Option<Self> {
1546 if Self::can_cast(syntax.kind()) {
1547 Some(Self { syntax })
1548 } else {
1549 None
1550 }
1551 }
1552 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1553}
1554impl PlaceholderPat {
1555 pub fn underscore_token(&self) -> Option<Underscore> { support::token(&self.syntax) }
1556}
1557#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1558pub struct DotDotPat {
1559 pub(crate) syntax: SyntaxNode,
1560}
1561impl AstNode for DotDotPat {
1562 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT }
1563 fn cast(syntax: SyntaxNode) -> Option<Self> {
1564 if Self::can_cast(syntax.kind()) {
1565 Some(Self { syntax })
1566 } else {
1567 None
1568 }
1569 }
1570 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1571}
1572impl DotDotPat {
1573 pub fn dotdot_token(&self) -> Option<Dotdot> { support::token(&self.syntax) }
1574}
1575#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1576pub struct PathPat {
1577 pub(crate) syntax: SyntaxNode,
1578}
1579impl AstNode for PathPat {
1580 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT }
1581 fn cast(syntax: SyntaxNode) -> Option<Self> {
1582 if Self::can_cast(syntax.kind()) {
1583 Some(Self { syntax })
1584 } else {
1585 None
1586 }
1587 }
1588 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1589}
1590impl PathPat {
1591 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1592}
1593#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1594pub struct SlicePat {
1595 pub(crate) syntax: SyntaxNode,
1596}
1597impl AstNode for SlicePat {
1598 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT }
1599 fn cast(syntax: SyntaxNode) -> Option<Self> {
1600 if Self::can_cast(syntax.kind()) {
1601 Some(Self { syntax })
1602 } else {
1603 None
1604 }
1605 }
1606 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1607}
1608impl SlicePat {
1609 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
1610 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1611 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
1612}
1613#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1614pub struct RangePat {
1615 pub(crate) syntax: SyntaxNode,
1616}
1617impl AstNode for RangePat {
1618 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT }
1619 fn cast(syntax: SyntaxNode) -> Option<Self> {
1620 if Self::can_cast(syntax.kind()) {
1621 Some(Self { syntax })
1622 } else {
1623 None
1624 }
1625 }
1626 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1627}
1628impl RangePat {
1629 pub fn range_separator_token(&self) -> Option<RangeSeparator> { support::token(&self.syntax) }
1630}
1631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1632pub struct LiteralPat {
1633 pub(crate) syntax: SyntaxNode,
1634}
1635impl AstNode for LiteralPat {
1636 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
1637 fn cast(syntax: SyntaxNode) -> Option<Self> {
1638 if Self::can_cast(syntax.kind()) {
1639 Some(Self { syntax })
1640 } else {
1641 None
1642 }
1643 }
1644 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1645}
1646impl LiteralPat {
1647 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1648}
1649#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1650pub struct MacroPat {
1651 pub(crate) syntax: SyntaxNode,
1652}
1653impl AstNode for MacroPat {
1654 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
1655 fn cast(syntax: SyntaxNode) -> Option<Self> {
1656 if Self::can_cast(syntax.kind()) {
1657 Some(Self { syntax })
1658 } else {
1659 None
1660 }
1661 }
1662 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1663}
1664impl MacroPat {
1665 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1666}
1667#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1668pub struct RecordPat {
1669 pub(crate) syntax: SyntaxNode,
1670}
1671impl AstNode for RecordPat {
1672 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
1673 fn cast(syntax: SyntaxNode) -> Option<Self> {
1674 if Self::can_cast(syntax.kind()) {
1675 Some(Self { syntax })
1676 } else {
1677 None
1678 }
1679 }
1680 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1681}
1682impl RecordPat {
1683 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
1684 support::child(&self.syntax)
1685 }
1686 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1687}
1688#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1689pub struct RecordFieldPatList {
1690 pub(crate) syntax: SyntaxNode,
1691}
1692impl AstNode for RecordFieldPatList {
1693 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST }
1694 fn cast(syntax: SyntaxNode) -> Option<Self> {
1695 if Self::can_cast(syntax.kind()) {
1696 Some(Self { syntax })
1697 } else {
1698 None
1699 }
1700 }
1701 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1702}
1703impl RecordFieldPatList {
1704 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
1705 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
1706 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1707 support::children(&self.syntax)
1708 }
1709 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1710 pub fn dotdot_token(&self) -> Option<Dotdot> { support::token(&self.syntax) }
1711 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
1712}
1713#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1714pub struct RecordFieldPat {
1715 pub(crate) syntax: SyntaxNode,
1716}
1717impl AstNode for RecordFieldPat {
1718 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT }
1719 fn cast(syntax: SyntaxNode) -> Option<Self> {
1720 if Self::can_cast(syntax.kind()) {
1721 Some(Self { syntax })
1722 } else {
1723 None
1724 }
1725 }
1726 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1727}
1728impl ast::AttrsOwner for RecordFieldPat {}
1729impl ast::NameOwner for RecordFieldPat {}
1730impl RecordFieldPat {
1731 pub fn colon_token(&self) -> Option<Colon> { support::token(&self.syntax) }
1732 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1733}
1734#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1735pub struct TupleStructPat {
1736 pub(crate) syntax: SyntaxNode,
1737}
1738impl AstNode for TupleStructPat {
1739 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT }
1740 fn cast(syntax: SyntaxNode) -> Option<Self> {
1741 if Self::can_cast(syntax.kind()) {
1742 Some(Self { syntax })
1743 } else {
1744 None
1745 }
1746 }
1747 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1748}
1749impl TupleStructPat {
1750 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1751 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
1752 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1753 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
1754}
1755#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1756pub struct TuplePat {
1757 pub(crate) syntax: SyntaxNode,
1758}
1759impl AstNode for TuplePat {
1760 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT }
1761 fn cast(syntax: SyntaxNode) -> Option<Self> {
1762 if Self::can_cast(syntax.kind()) {
1763 Some(Self { syntax })
1764 } else {
1765 None
1766 }
1767 }
1768 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1769}
1770impl TuplePat {
1771 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
1772 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1773 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
1774}
1775#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1776pub struct Visibility {
1777 pub(crate) syntax: SyntaxNode,
1778}
1779impl AstNode for Visibility {
1780 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
1781 fn cast(syntax: SyntaxNode) -> Option<Self> {
1782 if Self::can_cast(syntax.kind()) {
1783 Some(Self { syntax })
1784 } else {
1785 None
1786 }
1787 }
1788 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1789}
1790impl Visibility {
1791 pub fn pub_kw_token(&self) -> Option<PubKw> { support::token(&self.syntax) }
1792 pub fn super_kw_token(&self) -> Option<SuperKw> { support::token(&self.syntax) }
1793 pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) }
1794 pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) }
1795}
1796#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1797pub struct Name {
1798 pub(crate) syntax: SyntaxNode,
1799}
1800impl AstNode for Name {
1801 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
1802 fn cast(syntax: SyntaxNode) -> Option<Self> {
1803 if Self::can_cast(syntax.kind()) {
1804 Some(Self { syntax })
1805 } else {
1806 None
1807 }
1808 }
1809 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1810}
1811impl Name {
1812 pub fn ident_token(&self) -> Option<Ident> { support::token(&self.syntax) }
1813}
1814#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1815pub struct NameRef {
1816 pub(crate) syntax: SyntaxNode,
1817}
1818impl AstNode for NameRef {
1819 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
1820 fn cast(syntax: SyntaxNode) -> Option<Self> {
1821 if Self::can_cast(syntax.kind()) {
1822 Some(Self { syntax })
1823 } else {
1824 None
1825 }
1826 }
1827 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1828}
1829impl NameRef {
1830 pub fn name_ref_token_token(&self) -> Option<NameRefToken> { support::token(&self.syntax) }
1831}
1832#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1833pub struct MacroCall {
1834 pub(crate) syntax: SyntaxNode,
1835}
1836impl AstNode for MacroCall {
1837 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
1838 fn cast(syntax: SyntaxNode) -> Option<Self> {
1839 if Self::can_cast(syntax.kind()) {
1840 Some(Self { syntax })
1841 } else {
1842 None
1843 }
1844 }
1845 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1846}
1847impl ast::NameOwner for MacroCall {}
1848impl ast::AttrsOwner for MacroCall {}
1849impl ast::DocCommentsOwner for MacroCall {}
1850impl MacroCall {
1851 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1852 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
1853 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1854 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
1855}
1856#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1857pub struct Attr {
1858 pub(crate) syntax: SyntaxNode,
1859}
1860impl AstNode for Attr {
1861 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
1862 fn cast(syntax: SyntaxNode) -> Option<Self> {
1863 if Self::can_cast(syntax.kind()) {
1864 Some(Self { syntax })
1865 } else {
1866 None
1867 }
1868 }
1869 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1870}
1871impl Attr {
1872 pub fn pound_token(&self) -> Option<Pound> { support::token(&self.syntax) }
1873 pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
1874 pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
1875 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1876 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
1877 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1878 pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
1879}
1880#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1881pub struct TokenTree {
1882 pub(crate) syntax: SyntaxNode,
1883}
1884impl AstNode for TokenTree {
1885 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
1886 fn cast(syntax: SyntaxNode) -> Option<Self> {
1887 if Self::can_cast(syntax.kind()) {
1888 Some(Self { syntax })
1889 } else {
1890 None
1891 }
1892 }
1893 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1894}
1895impl TokenTree {}
1896#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1897pub struct TypeParamList {
1898 pub(crate) syntax: SyntaxNode,
1899}
1900impl AstNode for TypeParamList {
1901 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST }
1902 fn cast(syntax: SyntaxNode) -> Option<Self> {
1903 if Self::can_cast(syntax.kind()) {
1904 Some(Self { syntax })
1905 } else {
1906 None
1907 }
1908 }
1909 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1910}
1911impl TypeParamList {
1912 pub fn l_angle_token(&self) -> Option<LAngle> { support::token(&self.syntax) }
1913 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1914 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1915 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1916 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1917 pub fn r_angle_token(&self) -> Option<RAngle> { support::token(&self.syntax) }
1918}
1919#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1920pub struct TypeParam {
1921 pub(crate) syntax: SyntaxNode,
1922}
1923impl AstNode for TypeParam {
1924 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM }
1925 fn cast(syntax: SyntaxNode) -> Option<Self> {
1926 if Self::can_cast(syntax.kind()) {
1927 Some(Self { syntax })
1928 } else {
1929 None
1930 }
1931 }
1932 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1933}
1934impl ast::NameOwner for TypeParam {}
1935impl ast::AttrsOwner for TypeParam {}
1936impl ast::TypeBoundsOwner for TypeParam {}
1937impl TypeParam {
1938 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
1939 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1940}
1941#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1942pub struct ConstParam {
1943 pub(crate) syntax: SyntaxNode,
1944}
1945impl AstNode for ConstParam {
1946 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
1947 fn cast(syntax: SyntaxNode) -> Option<Self> {
1948 if Self::can_cast(syntax.kind()) {
1949 Some(Self { syntax })
1950 } else {
1951 None
1952 }
1953 }
1954 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1955}
1956impl ast::NameOwner for ConstParam {}
1957impl ast::AttrsOwner for ConstParam {}
1958impl ast::TypeAscriptionOwner for ConstParam {}
1959impl ConstParam {
1960 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
1961 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1962}
1963#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1964pub struct LifetimeParam {
1965 pub(crate) syntax: SyntaxNode,
1966}
1967impl AstNode for LifetimeParam {
1968 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM }
1969 fn cast(syntax: SyntaxNode) -> Option<Self> {
1970 if Self::can_cast(syntax.kind()) {
1971 Some(Self { syntax })
1972 } else {
1973 None
1974 }
1975 }
1976 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1977}
1978impl ast::AttrsOwner for LifetimeParam {}
1979impl LifetimeParam {
1980 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
1981}
1982#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1983pub struct TypeBound {
1984 pub(crate) syntax: SyntaxNode,
1985}
1986impl AstNode for TypeBound {
1987 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
1988 fn cast(syntax: SyntaxNode) -> Option<Self> {
1989 if Self::can_cast(syntax.kind()) {
1990 Some(Self { syntax })
1991 } else {
1992 None
1993 }
1994 }
1995 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1996}
1997impl TypeBound {
1998 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
1999 pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
2000 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2001}
2002#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2003pub struct TypeBoundList {
2004 pub(crate) syntax: SyntaxNode,
2005}
2006impl AstNode for TypeBoundList {
2007 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
2008 fn cast(syntax: SyntaxNode) -> Option<Self> {
2009 if Self::can_cast(syntax.kind()) {
2010 Some(Self { syntax })
2011 } else {
2012 None
2013 }
2014 }
2015 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2016}
2017impl TypeBoundList {
2018 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2019}
2020#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2021pub struct WherePred {
2022 pub(crate) syntax: SyntaxNode,
2023}
2024impl AstNode for WherePred {
2025 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED }
2026 fn cast(syntax: SyntaxNode) -> Option<Self> {
2027 if Self::can_cast(syntax.kind()) {
2028 Some(Self { syntax })
2029 } else {
2030 None
2031 }
2032 }
2033 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2034}
2035impl ast::TypeBoundsOwner for WherePred {}
2036impl WherePred {
2037 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
2038 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2039}
2040#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2041pub struct WhereClause {
2042 pub(crate) syntax: SyntaxNode,
2043}
2044impl AstNode for WhereClause {
2045 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
2046 fn cast(syntax: SyntaxNode) -> Option<Self> {
2047 if Self::can_cast(syntax.kind()) {
2048 Some(Self { syntax })
2049 } else {
2050 None
2051 }
2052 }
2053 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2054}
2055impl WhereClause {
2056 pub fn where_kw_token(&self) -> Option<WhereKw> { support::token(&self.syntax) }
2057 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2058}
2059#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2060pub struct Abi {
2061 pub(crate) syntax: SyntaxNode,
2062}
2063impl AstNode for Abi {
2064 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
2065 fn cast(syntax: SyntaxNode) -> Option<Self> {
2066 if Self::can_cast(syntax.kind()) {
2067 Some(Self { syntax })
2068 } else {
2069 None
2070 }
2071 }
2072 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2073}
2074impl Abi {
2075 pub fn string_token(&self) -> Option<String> { support::token(&self.syntax) }
2076}
2077#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2078pub struct ExprStmt {
2079 pub(crate) syntax: SyntaxNode,
2080}
2081impl AstNode for ExprStmt {
2082 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT }
2083 fn cast(syntax: SyntaxNode) -> Option<Self> {
2084 if Self::can_cast(syntax.kind()) {
2085 Some(Self { syntax })
2086 } else {
2087 None
2088 }
2089 }
2090 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2091}
2092impl ast::AttrsOwner for ExprStmt {}
2093impl ExprStmt {
2094 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2095 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
2096}
2097#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2098pub struct LetStmt {
2099 pub(crate) syntax: SyntaxNode,
2100}
2101impl AstNode for LetStmt {
2102 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT }
2103 fn cast(syntax: SyntaxNode) -> Option<Self> {
2104 if Self::can_cast(syntax.kind()) {
2105 Some(Self { syntax })
2106 } else {
2107 None
2108 }
2109 }
2110 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2111}
2112impl ast::AttrsOwner for LetStmt {}
2113impl ast::TypeAscriptionOwner for LetStmt {}
2114impl LetStmt {
2115 pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) }
2116 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2117 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2118 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2119 pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
2120}
2121#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2122pub struct Condition {
2123 pub(crate) syntax: SyntaxNode,
2124}
2125impl AstNode for Condition {
2126 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
2127 fn cast(syntax: SyntaxNode) -> Option<Self> {
2128 if Self::can_cast(syntax.kind()) {
2129 Some(Self { syntax })
2130 } else {
2131 None
2132 }
2133 }
2134 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2135}
2136impl Condition {
2137 pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) }
2138 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2139 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2140 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2141}
2142#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2143pub struct Block {
2144 pub(crate) syntax: SyntaxNode,
2145}
2146impl AstNode for Block {
2147 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK }
2148 fn cast(syntax: SyntaxNode) -> Option<Self> {
2149 if Self::can_cast(syntax.kind()) {
2150 Some(Self { syntax })
2151 } else {
2152 None
2153 }
2154 }
2155 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2156}
2157impl ast::AttrsOwner for Block {}
2158impl ast::ModuleItemOwner for Block {}
2159impl Block {
2160 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
2161 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2162 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2163 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
2164}
2165#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2166pub struct ParamList {
2167 pub(crate) syntax: SyntaxNode,
2168}
2169impl AstNode for ParamList {
2170 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
2171 fn cast(syntax: SyntaxNode) -> Option<Self> {
2172 if Self::can_cast(syntax.kind()) {
2173 Some(Self { syntax })
2174 } else {
2175 None
2176 }
2177 }
2178 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2179}
2180impl ParamList {
2181 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
2182 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2183 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2184 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
2185}
2186#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2187pub struct SelfParam {
2188 pub(crate) syntax: SyntaxNode,
2189}
2190impl AstNode for SelfParam {
2191 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
2192 fn cast(syntax: SyntaxNode) -> Option<Self> {
2193 if Self::can_cast(syntax.kind()) {
2194 Some(Self { syntax })
2195 } else {
2196 None
2197 }
2198 }
2199 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2200}
2201impl ast::TypeAscriptionOwner for SelfParam {}
2202impl ast::AttrsOwner for SelfParam {}
2203impl SelfParam {
2204 pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
2205 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
2206 pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) }
2207}
2208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2209pub struct Param {
2210 pub(crate) syntax: SyntaxNode,
2211}
2212impl AstNode for Param {
2213 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
2214 fn cast(syntax: SyntaxNode) -> Option<Self> {
2215 if Self::can_cast(syntax.kind()) {
2216 Some(Self { syntax })
2217 } else {
2218 None
2219 }
2220 }
2221 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2222}
2223impl ast::TypeAscriptionOwner for Param {}
2224impl ast::AttrsOwner for Param {}
2225impl Param {
2226 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2227 pub fn dotdotdot_token(&self) -> Option<Dotdotdot> { support::token(&self.syntax) }
2228}
2229#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2230pub struct UseItem {
2231 pub(crate) syntax: SyntaxNode,
2232}
2233impl AstNode for UseItem {
2234 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM }
2235 fn cast(syntax: SyntaxNode) -> Option<Self> {
2236 if Self::can_cast(syntax.kind()) {
2237 Some(Self { syntax })
2238 } else {
2239 None
2240 }
2241 }
2242 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2243}
2244impl ast::AttrsOwner for UseItem {}
2245impl ast::VisibilityOwner for UseItem {}
2246impl UseItem {
2247 pub fn use_kw_token(&self) -> Option<UseKw> { support::token(&self.syntax) }
2248 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2249}
2250#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2251pub struct UseTree {
2252 pub(crate) syntax: SyntaxNode,
2253}
2254impl AstNode for UseTree {
2255 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
2256 fn cast(syntax: SyntaxNode) -> Option<Self> {
2257 if Self::can_cast(syntax.kind()) {
2258 Some(Self { syntax })
2259 } else {
2260 None
2261 }
2262 }
2263 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2264}
2265impl UseTree {
2266 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2267 pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) }
2268 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2269 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2270}
2271#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2272pub struct Alias {
2273 pub(crate) syntax: SyntaxNode,
2274}
2275impl AstNode for Alias {
2276 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS }
2277 fn cast(syntax: SyntaxNode) -> Option<Self> {
2278 if Self::can_cast(syntax.kind()) {
2279 Some(Self { syntax })
2280 } else {
2281 None
2282 }
2283 }
2284 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2285}
2286impl ast::NameOwner for Alias {}
2287impl Alias {
2288 pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) }
2289}
2290#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2291pub struct UseTreeList {
2292 pub(crate) syntax: SyntaxNode,
2293}
2294impl AstNode for UseTreeList {
2295 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
2296 fn cast(syntax: SyntaxNode) -> Option<Self> {
2297 if Self::can_cast(syntax.kind()) {
2298 Some(Self { syntax })
2299 } else {
2300 None
2301 }
2302 }
2303 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2304}
2305impl UseTreeList {
2306 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
2307 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2308 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
2309}
2310#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2311pub struct ExternCrateItem {
2312 pub(crate) syntax: SyntaxNode,
2313}
2314impl AstNode for ExternCrateItem {
2315 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM }
2316 fn cast(syntax: SyntaxNode) -> Option<Self> {
2317 if Self::can_cast(syntax.kind()) {
2318 Some(Self { syntax })
2319 } else {
2320 None
2321 }
2322 }
2323 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2324}
2325impl ast::AttrsOwner for ExternCrateItem {}
2326impl ast::VisibilityOwner for ExternCrateItem {}
2327impl ExternCrateItem {
2328 pub fn extern_kw_token(&self) -> Option<ExternKw> { support::token(&self.syntax) }
2329 pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) }
2330 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2331 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2332}
2333#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2334pub struct ArgList {
2335 pub(crate) syntax: SyntaxNode,
2336}
2337impl AstNode for ArgList {
2338 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
2339 fn cast(syntax: SyntaxNode) -> Option<Self> {
2340 if Self::can_cast(syntax.kind()) {
2341 Some(Self { syntax })
2342 } else {
2343 None
2344 }
2345 }
2346 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2347}
2348impl ArgList {
2349 pub fn l_paren_token(&self) -> Option<LParen> { support::token(&self.syntax) }
2350 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2351 pub fn r_paren_token(&self) -> Option<RParen> { support::token(&self.syntax) }
2352}
2353#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2354pub struct Path {
2355 pub(crate) syntax: SyntaxNode,
2356}
2357impl AstNode for Path {
2358 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
2359 fn cast(syntax: SyntaxNode) -> Option<Self> {
2360 if Self::can_cast(syntax.kind()) {
2361 Some(Self { syntax })
2362 } else {
2363 None
2364 }
2365 }
2366 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2367}
2368impl Path {
2369 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2370 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2371}
2372#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2373pub struct PathSegment {
2374 pub(crate) syntax: SyntaxNode,
2375}
2376impl AstNode for PathSegment {
2377 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
2378 fn cast(syntax: SyntaxNode) -> Option<Self> {
2379 if Self::can_cast(syntax.kind()) {
2380 Some(Self { syntax })
2381 } else {
2382 None
2383 }
2384 }
2385 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2386}
2387impl PathSegment {
2388 pub fn coloncolon_token(&self) -> Option<Coloncolon> { support::token(&self.syntax) }
2389 pub fn l_angle_token(&self) -> Option<LAngle> { support::token(&self.syntax) }
2390 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2391 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
2392 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
2393 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
2394 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2395 pub fn r_angle_token(&self) -> Option<RAngle> { support::token(&self.syntax) }
2396}
2397#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2398pub struct TypeArgList {
2399 pub(crate) syntax: SyntaxNode,
2400}
2401impl AstNode for TypeArgList {
2402 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST }
2403 fn cast(syntax: SyntaxNode) -> Option<Self> {
2404 if Self::can_cast(syntax.kind()) {
2405 Some(Self { syntax })
2406 } else {
2407 None
2408 }
2409 }
2410 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2411}
2412impl TypeArgList {
2413 pub fn coloncolon_token(&self) -> Option<Coloncolon> { support::token(&self.syntax) }
2414 pub fn l_angle_token(&self) -> Option<LAngle> { support::token(&self.syntax) }
2415 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2416 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2417 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2418 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2419 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2420 pub fn r_angle_token(&self) -> Option<RAngle> { support::token(&self.syntax) }
2421}
2422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2423pub struct TypeArg {
2424 pub(crate) syntax: SyntaxNode,
2425}
2426impl AstNode for TypeArg {
2427 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG }
2428 fn cast(syntax: SyntaxNode) -> Option<Self> {
2429 if Self::can_cast(syntax.kind()) {
2430 Some(Self { syntax })
2431 } else {
2432 None
2433 }
2434 }
2435 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2436}
2437impl TypeArg {
2438 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2439}
2440#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2441pub struct AssocTypeArg {
2442 pub(crate) syntax: SyntaxNode,
2443}
2444impl AstNode for AssocTypeArg {
2445 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
2446 fn cast(syntax: SyntaxNode) -> Option<Self> {
2447 if Self::can_cast(syntax.kind()) {
2448 Some(Self { syntax })
2449 } else {
2450 None
2451 }
2452 }
2453 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2454}
2455impl ast::TypeBoundsOwner for AssocTypeArg {}
2456impl AssocTypeArg {
2457 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2458 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2459 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2460}
2461#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2462pub struct LifetimeArg {
2463 pub(crate) syntax: SyntaxNode,
2464}
2465impl AstNode for LifetimeArg {
2466 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG }
2467 fn cast(syntax: SyntaxNode) -> Option<Self> {
2468 if Self::can_cast(syntax.kind()) {
2469 Some(Self { syntax })
2470 } else {
2471 None
2472 }
2473 }
2474 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2475}
2476impl LifetimeArg {
2477 pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
2478}
2479#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2480pub struct ConstArg {
2481 pub(crate) syntax: SyntaxNode,
2482}
2483impl AstNode for ConstArg {
2484 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG }
2485 fn cast(syntax: SyntaxNode) -> Option<Self> {
2486 if Self::can_cast(syntax.kind()) {
2487 Some(Self { syntax })
2488 } else {
2489 None
2490 }
2491 }
2492 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2493}
2494impl ConstArg {
2495 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2496 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2497 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2498}
2499#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2500pub struct MacroItems {
2501 pub(crate) syntax: SyntaxNode,
2502}
2503impl AstNode for MacroItems {
2504 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS }
2505 fn cast(syntax: SyntaxNode) -> Option<Self> {
2506 if Self::can_cast(syntax.kind()) {
2507 Some(Self { syntax })
2508 } else {
2509 None
2510 }
2511 }
2512 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2513}
2514impl ast::ModuleItemOwner for MacroItems {}
2515impl ast::FnDefOwner for MacroItems {}
2516impl MacroItems {}
2517#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2518pub struct MacroStmts {
2519 pub(crate) syntax: SyntaxNode,
2520}
2521impl AstNode for MacroStmts {
2522 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS }
2523 fn cast(syntax: SyntaxNode) -> Option<Self> {
2524 if Self::can_cast(syntax.kind()) {
2525 Some(Self { syntax })
2526 } else {
2527 None
2528 }
2529 }
2530 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2531}
2532impl MacroStmts {
2533 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2534 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2535}
2536#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2537pub struct ExternItemList {
2538 pub(crate) syntax: SyntaxNode,
2539}
2540impl AstNode for ExternItemList {
2541 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
2542 fn cast(syntax: SyntaxNode) -> Option<Self> {
2543 if Self::can_cast(syntax.kind()) {
2544 Some(Self { syntax })
2545 } else {
2546 None
2547 }
2548 }
2549 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2550}
2551impl ast::FnDefOwner for ExternItemList {}
2552impl ast::ModuleItemOwner for ExternItemList {}
2553impl ExternItemList {
2554 pub fn l_curly_token(&self) -> Option<LCurly> { support::token(&self.syntax) }
2555 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2556 pub fn r_curly_token(&self) -> Option<RCurly> { support::token(&self.syntax) }
2557}
2558#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2559pub struct ExternBlock {
2560 pub(crate) syntax: SyntaxNode,
2561}
2562impl AstNode for ExternBlock {
2563 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
2564 fn cast(syntax: SyntaxNode) -> Option<Self> {
2565 if Self::can_cast(syntax.kind()) {
2566 Some(Self { syntax })
2567 } else {
2568 None
2569 }
2570 }
2571 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2572}
2573impl ExternBlock {
2574 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2575 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2576}
2577#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2578pub struct MetaItem {
2579 pub(crate) syntax: SyntaxNode,
2580}
2581impl AstNode for MetaItem {
2582 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM }
2583 fn cast(syntax: SyntaxNode) -> Option<Self> {
2584 if Self::can_cast(syntax.kind()) {
2585 Some(Self { syntax })
2586 } else {
2587 None
2588 }
2589 }
2590 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2591}
2592impl MetaItem {
2593 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2594 pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
2595 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2596 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2597}
2598#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2599pub struct MacroDef {
2600 pub(crate) syntax: SyntaxNode,
2601}
2602impl AstNode for MacroDef {
2603 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF }
2604 fn cast(syntax: SyntaxNode) -> Option<Self> {
2605 if Self::can_cast(syntax.kind()) {
2606 Some(Self { syntax })
2607 } else {
2608 None
2609 }
2610 }
2611 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2612}
2613impl MacroDef {
2614 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2615 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2616}
2617#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2618pub enum NominalDef {
2619 StructDef(StructDef),
2620 EnumDef(EnumDef),
2621 UnionDef(UnionDef),
2622}
2623impl From<StructDef> for NominalDef {
2624 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) }
2625}
2626impl From<EnumDef> for NominalDef {
2627 fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) }
2628}
2629impl From<UnionDef> for NominalDef {
2630 fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) }
2631}
2632impl AstNode for NominalDef {
2633 fn can_cast(kind: SyntaxKind) -> bool {
2634 match kind {
2635 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
2636 _ => false,
2637 }
2638 }
2639 fn cast(syntax: SyntaxNode) -> Option<Self> {
2640 let res = match syntax.kind() {
2641 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
2642 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
2643 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
2644 _ => return None,
2645 };
2646 Some(res)
2647 }
2648 fn syntax(&self) -> &SyntaxNode {
2649 match self {
2650 NominalDef::StructDef(it) => &it.syntax,
2651 NominalDef::EnumDef(it) => &it.syntax,
2652 NominalDef::UnionDef(it) => &it.syntax,
2653 }
2654 }
2655}
2656impl ast::NameOwner for NominalDef {}
2657impl ast::TypeParamsOwner for NominalDef {}
2658impl ast::AttrsOwner for NominalDef {}
2659#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2660pub enum GenericParam {
2661 LifetimeParam(LifetimeParam),
2662 TypeParam(TypeParam),
2663 ConstParam(ConstParam),
2664}
2665impl From<LifetimeParam> for GenericParam {
2666 fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) }
2667}
2668impl From<TypeParam> for GenericParam {
2669 fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) }
2670}
2671impl From<ConstParam> for GenericParam {
2672 fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) }
2673}
2674impl AstNode for GenericParam {
2675 fn can_cast(kind: SyntaxKind) -> bool {
2676 match kind {
2677 LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
2678 _ => false,
2679 }
2680 }
2681 fn cast(syntax: SyntaxNode) -> Option<Self> {
2682 let res = match syntax.kind() {
2683 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
2684 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
2685 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
2686 _ => return None,
2687 };
2688 Some(res)
2689 }
2690 fn syntax(&self) -> &SyntaxNode {
2691 match self {
2692 GenericParam::LifetimeParam(it) => &it.syntax,
2693 GenericParam::TypeParam(it) => &it.syntax,
2694 GenericParam::ConstParam(it) => &it.syntax,
2695 }
2696 }
2697}
2698#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2699pub enum GenericArg {
2700 LifetimeArg(LifetimeArg),
2701 TypeArg(TypeArg),
2702 ConstArg(ConstArg),
2703 AssocTypeArg(AssocTypeArg),
2704}
2705impl From<LifetimeArg> for GenericArg {
2706 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) }
2707}
2708impl From<TypeArg> for GenericArg {
2709 fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) }
2710}
2711impl From<ConstArg> for GenericArg {
2712 fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) }
2713}
2714impl From<AssocTypeArg> for GenericArg {
2715 fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) }
2716}
2717impl AstNode for GenericArg {
2718 fn can_cast(kind: SyntaxKind) -> bool {
2719 match kind {
2720 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true,
2721 _ => false,
2722 }
2723 }
2724 fn cast(syntax: SyntaxNode) -> Option<Self> {
2725 let res = match syntax.kind() {
2726 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
2727 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
2728 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
2729 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
2730 _ => return None,
2731 };
2732 Some(res)
2733 }
2734 fn syntax(&self) -> &SyntaxNode {
2735 match self {
2736 GenericArg::LifetimeArg(it) => &it.syntax,
2737 GenericArg::TypeArg(it) => &it.syntax,
2738 GenericArg::ConstArg(it) => &it.syntax,
2739 GenericArg::AssocTypeArg(it) => &it.syntax,
2740 }
2741 }
2742}
2743#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2744pub enum TypeRef {
2745 ParenType(ParenType),
2746 TupleType(TupleType),
2747 NeverType(NeverType),
2748 PathType(PathType),
2749 PointerType(PointerType),
2750 ArrayType(ArrayType),
2751 SliceType(SliceType),
2752 ReferenceType(ReferenceType),
2753 PlaceholderType(PlaceholderType),
2754 FnPointerType(FnPointerType),
2755 ForType(ForType),
2756 ImplTraitType(ImplTraitType),
2757 DynTraitType(DynTraitType),
2758}
2759impl From<ParenType> for TypeRef {
2760 fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) }
2761}
2762impl From<TupleType> for TypeRef {
2763 fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) }
2764}
2765impl From<NeverType> for TypeRef {
2766 fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) }
2767}
2768impl From<PathType> for TypeRef {
2769 fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) }
2770}
2771impl From<PointerType> for TypeRef {
2772 fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) }
2773}
2774impl From<ArrayType> for TypeRef {
2775 fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) }
2776}
2777impl From<SliceType> for TypeRef {
2778 fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) }
2779}
2780impl From<ReferenceType> for TypeRef {
2781 fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) }
2782}
2783impl From<PlaceholderType> for TypeRef {
2784 fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) }
2785}
2786impl From<FnPointerType> for TypeRef {
2787 fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) }
2788}
2789impl From<ForType> for TypeRef {
2790 fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) }
2791}
2792impl From<ImplTraitType> for TypeRef {
2793 fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) }
2794}
2795impl From<DynTraitType> for TypeRef {
2796 fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) }
2797}
2798impl AstNode for TypeRef {
2799 fn can_cast(kind: SyntaxKind) -> bool {
2800 match kind {
2801 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
2802 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
2803 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
2804 _ => false,
2805 }
2806 }
2807 fn cast(syntax: SyntaxNode) -> Option<Self> {
2808 let res = match syntax.kind() {
2809 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
2810 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
2811 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
2812 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
2813 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
2814 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
2815 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
2816 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
2817 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
2818 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
2819 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
2820 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
2821 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
2822 _ => return None,
2823 };
2824 Some(res)
2825 }
2826 fn syntax(&self) -> &SyntaxNode {
2827 match self {
2828 TypeRef::ParenType(it) => &it.syntax,
2829 TypeRef::TupleType(it) => &it.syntax,
2830 TypeRef::NeverType(it) => &it.syntax,
2831 TypeRef::PathType(it) => &it.syntax,
2832 TypeRef::PointerType(it) => &it.syntax,
2833 TypeRef::ArrayType(it) => &it.syntax,
2834 TypeRef::SliceType(it) => &it.syntax,
2835 TypeRef::ReferenceType(it) => &it.syntax,
2836 TypeRef::PlaceholderType(it) => &it.syntax,
2837 TypeRef::FnPointerType(it) => &it.syntax,
2838 TypeRef::ForType(it) => &it.syntax,
2839 TypeRef::ImplTraitType(it) => &it.syntax,
2840 TypeRef::DynTraitType(it) => &it.syntax,
2841 }
2842 }
2843}
2844#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2845pub enum ModuleItem {
2846 StructDef(StructDef),
2847 UnionDef(UnionDef),
2848 EnumDef(EnumDef),
2849 FnDef(FnDef),
2850 TraitDef(TraitDef),
2851 TypeAliasDef(TypeAliasDef),
2852 ImplDef(ImplDef),
2853 UseItem(UseItem),
2854 ExternCrateItem(ExternCrateItem),
2855 ConstDef(ConstDef),
2856 StaticDef(StaticDef),
2857 Module(Module),
2858 MacroCall(MacroCall),
2859 ExternBlock(ExternBlock),
2860}
2861impl From<StructDef> for ModuleItem {
2862 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) }
2863}
2864impl From<UnionDef> for ModuleItem {
2865 fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) }
2866}
2867impl From<EnumDef> for ModuleItem {
2868 fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) }
2869}
2870impl From<FnDef> for ModuleItem {
2871 fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) }
2872}
2873impl From<TraitDef> for ModuleItem {
2874 fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) }
2875}
2876impl From<TypeAliasDef> for ModuleItem {
2877 fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) }
2878}
2879impl From<ImplDef> for ModuleItem {
2880 fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) }
2881}
2882impl From<UseItem> for ModuleItem {
2883 fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) }
2884}
2885impl From<ExternCrateItem> for ModuleItem {
2886 fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) }
2887}
2888impl From<ConstDef> for ModuleItem {
2889 fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) }
2890}
2891impl From<StaticDef> for ModuleItem {
2892 fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) }
2893}
2894impl From<Module> for ModuleItem {
2895 fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) }
2896}
2897impl From<MacroCall> for ModuleItem {
2898 fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) }
2899}
2900impl From<ExternBlock> for ModuleItem {
2901 fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) }
2902}
2903impl AstNode for ModuleItem {
2904 fn can_cast(kind: SyntaxKind) -> bool {
2905 match kind {
2906 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
2907 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
2908 | EXTERN_BLOCK => true,
2909 _ => false,
2910 }
2911 }
2912 fn cast(syntax: SyntaxNode) -> Option<Self> {
2913 let res = match syntax.kind() {
2914 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
2915 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
2916 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
2917 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
2918 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
2919 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
2920 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
2921 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
2922 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
2923 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
2924 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
2925 MODULE => ModuleItem::Module(Module { syntax }),
2926 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
2927 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
2928 _ => return None,
2929 };
2930 Some(res)
2931 }
2932 fn syntax(&self) -> &SyntaxNode {
2933 match self {
2934 ModuleItem::StructDef(it) => &it.syntax,
2935 ModuleItem::UnionDef(it) => &it.syntax,
2936 ModuleItem::EnumDef(it) => &it.syntax,
2937 ModuleItem::FnDef(it) => &it.syntax,
2938 ModuleItem::TraitDef(it) => &it.syntax,
2939 ModuleItem::TypeAliasDef(it) => &it.syntax,
2940 ModuleItem::ImplDef(it) => &it.syntax,
2941 ModuleItem::UseItem(it) => &it.syntax,
2942 ModuleItem::ExternCrateItem(it) => &it.syntax,
2943 ModuleItem::ConstDef(it) => &it.syntax,
2944 ModuleItem::StaticDef(it) => &it.syntax,
2945 ModuleItem::Module(it) => &it.syntax,
2946 ModuleItem::MacroCall(it) => &it.syntax,
2947 ModuleItem::ExternBlock(it) => &it.syntax,
2948 }
2949 }
2950}
2951impl ast::NameOwner for ModuleItem {}
2952impl ast::AttrsOwner for ModuleItem {}
2953impl ast::VisibilityOwner for ModuleItem {}
2954#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2955pub enum ImplItem {
2956 FnDef(FnDef),
2957 TypeAliasDef(TypeAliasDef),
2958 ConstDef(ConstDef),
2959}
2960impl From<FnDef> for ImplItem {
2961 fn from(node: FnDef) -> ImplItem { ImplItem::FnDef(node) }
2962}
2963impl From<TypeAliasDef> for ImplItem {
2964 fn from(node: TypeAliasDef) -> ImplItem { ImplItem::TypeAliasDef(node) }
2965}
2966impl From<ConstDef> for ImplItem {
2967 fn from(node: ConstDef) -> ImplItem { ImplItem::ConstDef(node) }
2968}
2969impl AstNode for ImplItem {
2970 fn can_cast(kind: SyntaxKind) -> bool {
2971 match kind {
2972 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
2973 _ => false,
2974 }
2975 }
2976 fn cast(syntax: SyntaxNode) -> Option<Self> {
2977 let res = match syntax.kind() {
2978 FN_DEF => ImplItem::FnDef(FnDef { syntax }),
2979 TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
2980 CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
2981 _ => return None,
2982 };
2983 Some(res)
2984 }
2985 fn syntax(&self) -> &SyntaxNode {
2986 match self {
2987 ImplItem::FnDef(it) => &it.syntax,
2988 ImplItem::TypeAliasDef(it) => &it.syntax,
2989 ImplItem::ConstDef(it) => &it.syntax,
2990 }
2991 }
2992}
2993impl ast::NameOwner for ImplItem {}
2994impl ast::AttrsOwner for ImplItem {}
2995#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2996pub enum ExternItem {
2997 FnDef(FnDef),
2998 StaticDef(StaticDef),
2999}
3000impl From<FnDef> for ExternItem {
3001 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
3002}
3003impl From<StaticDef> for ExternItem {
3004 fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) }
3005}
3006impl AstNode for ExternItem {
3007 fn can_cast(kind: SyntaxKind) -> bool {
3008 match kind {
3009 FN_DEF | STATIC_DEF => true,
3010 _ => false,
3011 }
3012 }
3013 fn cast(syntax: SyntaxNode) -> Option<Self> {
3014 let res = match syntax.kind() {
3015 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
3016 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
3017 _ => return None,
3018 };
3019 Some(res)
3020 }
3021 fn syntax(&self) -> &SyntaxNode {
3022 match self {
3023 ExternItem::FnDef(it) => &it.syntax,
3024 ExternItem::StaticDef(it) => &it.syntax,
3025 }
3026 }
3027}
3028impl ast::NameOwner for ExternItem {}
3029impl ast::AttrsOwner for ExternItem {}
3030impl ast::VisibilityOwner for ExternItem {}
3031#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3032pub enum Expr {
3033 TupleExpr(TupleExpr),
3034 ArrayExpr(ArrayExpr),
3035 ParenExpr(ParenExpr),
3036 PathExpr(PathExpr),
3037 LambdaExpr(LambdaExpr),
3038 IfExpr(IfExpr),
3039 LoopExpr(LoopExpr),
3040 ForExpr(ForExpr),
3041 WhileExpr(WhileExpr),
3042 ContinueExpr(ContinueExpr),
3043 BreakExpr(BreakExpr),
3044 Label(Label),
3045 BlockExpr(BlockExpr),
3046 ReturnExpr(ReturnExpr),
3047 MatchExpr(MatchExpr),
3048 RecordLit(RecordLit),
3049 CallExpr(CallExpr),
3050 IndexExpr(IndexExpr),
3051 MethodCallExpr(MethodCallExpr),
3052 FieldExpr(FieldExpr),
3053 AwaitExpr(AwaitExpr),
3054 TryExpr(TryExpr),
3055 TryBlockExpr(TryBlockExpr),
3056 CastExpr(CastExpr),
3057 RefExpr(RefExpr),
3058 PrefixExpr(PrefixExpr),
3059 RangeExpr(RangeExpr),
3060 BinExpr(BinExpr),
3061 Literal(Literal),
3062 MacroCall(MacroCall),
3063 BoxExpr(BoxExpr),
3064}
3065impl From<TupleExpr> for Expr {
3066 fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) }
3067}
3068impl From<ArrayExpr> for Expr {
3069 fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) }
3070}
3071impl From<ParenExpr> for Expr {
3072 fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) }
3073}
3074impl From<PathExpr> for Expr {
3075 fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) }
3076}
3077impl From<LambdaExpr> for Expr {
3078 fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) }
3079}
3080impl From<IfExpr> for Expr {
3081 fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) }
3082}
3083impl From<LoopExpr> for Expr {
3084 fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) }
3085}
3086impl From<ForExpr> for Expr {
3087 fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) }
3088}
3089impl From<WhileExpr> for Expr {
3090 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) }
3091}
3092impl From<ContinueExpr> for Expr {
3093 fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) }
3094}
3095impl From<BreakExpr> for Expr {
3096 fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) }
3097}
3098impl From<Label> for Expr {
3099 fn from(node: Label) -> Expr { Expr::Label(node) }
3100}
3101impl From<BlockExpr> for Expr {
3102 fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) }
3103}
3104impl From<ReturnExpr> for Expr {
3105 fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) }
3106}
3107impl From<MatchExpr> for Expr {
3108 fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) }
3109}
3110impl From<RecordLit> for Expr {
3111 fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) }
3112}
3113impl From<CallExpr> for Expr {
3114 fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
3115}
3116impl From<IndexExpr> for Expr {
3117 fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) }
3118}
3119impl From<MethodCallExpr> for Expr {
3120 fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) }
3121}
3122impl From<FieldExpr> for Expr {
3123 fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) }
3124}
3125impl From<AwaitExpr> for Expr {
3126 fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) }
3127}
3128impl From<TryExpr> for Expr {
3129 fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) }
3130}
3131impl From<TryBlockExpr> for Expr {
3132 fn from(node: TryBlockExpr) -> Expr { Expr::TryBlockExpr(node) }
3133}
3134impl From<CastExpr> for Expr {
3135 fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) }
3136}
3137impl From<RefExpr> for Expr {
3138 fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) }
3139}
3140impl From<PrefixExpr> for Expr {
3141 fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) }
3142}
3143impl From<RangeExpr> for Expr {
3144 fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) }
3145}
3146impl From<BinExpr> for Expr {
3147 fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) }
3148}
3149impl From<Literal> for Expr {
3150 fn from(node: Literal) -> Expr { Expr::Literal(node) }
3151}
3152impl From<MacroCall> for Expr {
3153 fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) }
3154}
3155impl From<BoxExpr> for Expr {
3156 fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) }
3157}
3158impl AstNode for Expr {
3159 fn can_cast(kind: SyntaxKind) -> bool {
3160 match kind {
3161 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
3162 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
3163 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
3164 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
3165 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
3166 | BOX_EXPR => true,
3167 _ => false,
3168 }
3169 }
3170 fn cast(syntax: SyntaxNode) -> Option<Self> {
3171 let res = match syntax.kind() {
3172 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
3173 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
3174 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
3175 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
3176 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
3177 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
3178 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
3179 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
3180 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
3181 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
3182 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
3183 LABEL => Expr::Label(Label { syntax }),
3184 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
3185 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
3186 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
3187 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
3188 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
3189 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
3190 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
3191 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
3192 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
3193 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
3194 TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
3195 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
3196 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
3197 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
3198 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
3199 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
3200 LITERAL => Expr::Literal(Literal { syntax }),
3201 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
3202 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
3203 _ => return None,
3204 };
3205 Some(res)
3206 }
3207 fn syntax(&self) -> &SyntaxNode {
3208 match self {
3209 Expr::TupleExpr(it) => &it.syntax,
3210 Expr::ArrayExpr(it) => &it.syntax,
3211 Expr::ParenExpr(it) => &it.syntax,
3212 Expr::PathExpr(it) => &it.syntax,
3213 Expr::LambdaExpr(it) => &it.syntax,
3214 Expr::IfExpr(it) => &it.syntax,
3215 Expr::LoopExpr(it) => &it.syntax,
3216 Expr::ForExpr(it) => &it.syntax,
3217 Expr::WhileExpr(it) => &it.syntax,
3218 Expr::ContinueExpr(it) => &it.syntax,
3219 Expr::BreakExpr(it) => &it.syntax,
3220 Expr::Label(it) => &it.syntax,
3221 Expr::BlockExpr(it) => &it.syntax,
3222 Expr::ReturnExpr(it) => &it.syntax,
3223 Expr::MatchExpr(it) => &it.syntax,
3224 Expr::RecordLit(it) => &it.syntax,
3225 Expr::CallExpr(it) => &it.syntax,
3226 Expr::IndexExpr(it) => &it.syntax,
3227 Expr::MethodCallExpr(it) => &it.syntax,
3228 Expr::FieldExpr(it) => &it.syntax,
3229 Expr::AwaitExpr(it) => &it.syntax,
3230 Expr::TryExpr(it) => &it.syntax,
3231 Expr::TryBlockExpr(it) => &it.syntax,
3232 Expr::CastExpr(it) => &it.syntax,
3233 Expr::RefExpr(it) => &it.syntax,
3234 Expr::PrefixExpr(it) => &it.syntax,
3235 Expr::RangeExpr(it) => &it.syntax,
3236 Expr::BinExpr(it) => &it.syntax,
3237 Expr::Literal(it) => &it.syntax,
3238 Expr::MacroCall(it) => &it.syntax,
3239 Expr::BoxExpr(it) => &it.syntax,
3240 }
3241 }
3242}
3243impl ast::AttrsOwner for Expr {}
3244#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3245pub enum Pat {
3246 OrPat(OrPat),
3247 ParenPat(ParenPat),
3248 RefPat(RefPat),
3249 BoxPat(BoxPat),
3250 BindPat(BindPat),
3251 PlaceholderPat(PlaceholderPat),
3252 DotDotPat(DotDotPat),
3253 PathPat(PathPat),
3254 RecordPat(RecordPat),
3255 TupleStructPat(TupleStructPat),
3256 TuplePat(TuplePat),
3257 SlicePat(SlicePat),
3258 RangePat(RangePat),
3259 LiteralPat(LiteralPat),
3260 MacroPat(MacroPat),
3261}
3262impl From<OrPat> for Pat {
3263 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
3264}
3265impl From<ParenPat> for Pat {
3266 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
3267}
3268impl From<RefPat> for Pat {
3269 fn from(node: RefPat) -> Pat { Pat::RefPat(node) }
3270}
3271impl From<BoxPat> for Pat {
3272 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
3273}
3274impl From<BindPat> for Pat {
3275 fn from(node: BindPat) -> Pat { Pat::BindPat(node) }
3276}
3277impl From<PlaceholderPat> for Pat {
3278 fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) }
3279}
3280impl From<DotDotPat> for Pat {
3281 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) }
3282}
3283impl From<PathPat> for Pat {
3284 fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
3285}
3286impl From<RecordPat> for Pat {
3287 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
3288}
3289impl From<TupleStructPat> for Pat {
3290 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
3291}
3292impl From<TuplePat> for Pat {
3293 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
3294}
3295impl From<SlicePat> for Pat {
3296 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
3297}
3298impl From<RangePat> for Pat {
3299 fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
3300}
3301impl From<LiteralPat> for Pat {
3302 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
3303}
3304impl From<MacroPat> for Pat {
3305 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
3306}
3307impl AstNode for Pat {
3308 fn can_cast(kind: SyntaxKind) -> bool {
3309 match kind {
3310 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
3311 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
3312 | LITERAL_PAT | MACRO_PAT => true,
3313 _ => false,
3314 }
3315 }
3316 fn cast(syntax: SyntaxNode) -> Option<Self> {
3317 let res = match syntax.kind() {
3318 OR_PAT => Pat::OrPat(OrPat { syntax }),
3319 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
3320 REF_PAT => Pat::RefPat(RefPat { syntax }),
3321 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3322 BIND_PAT => Pat::BindPat(BindPat { syntax }),
3323 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
3324 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
3325 PATH_PAT => Pat::PathPat(PathPat { syntax }),
3326 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
3327 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
3328 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
3329 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
3330 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
3331 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
3332 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
3333 _ => return None,
3334 };
3335 Some(res)
3336 }
3337 fn syntax(&self) -> &SyntaxNode {
3338 match self {
3339 Pat::OrPat(it) => &it.syntax,
3340 Pat::ParenPat(it) => &it.syntax,
3341 Pat::RefPat(it) => &it.syntax,
3342 Pat::BoxPat(it) => &it.syntax,
3343 Pat::BindPat(it) => &it.syntax,
3344 Pat::PlaceholderPat(it) => &it.syntax,
3345 Pat::DotDotPat(it) => &it.syntax,
3346 Pat::PathPat(it) => &it.syntax,
3347 Pat::RecordPat(it) => &it.syntax,
3348 Pat::TupleStructPat(it) => &it.syntax,
3349 Pat::TuplePat(it) => &it.syntax,
3350 Pat::SlicePat(it) => &it.syntax,
3351 Pat::RangePat(it) => &it.syntax,
3352 Pat::LiteralPat(it) => &it.syntax,
3353 Pat::MacroPat(it) => &it.syntax,
3354 }
3355 }
3356}
3357#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3358pub enum RecordInnerPat {
3359 RecordFieldPat(RecordFieldPat),
3360 BindPat(BindPat),
3361}
3362impl From<RecordFieldPat> for RecordInnerPat {
3363 fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) }
3364}
3365impl From<BindPat> for RecordInnerPat {
3366 fn from(node: BindPat) -> RecordInnerPat { RecordInnerPat::BindPat(node) }
3367}
3368impl AstNode for RecordInnerPat {
3369 fn can_cast(kind: SyntaxKind) -> bool {
3370 match kind {
3371 RECORD_FIELD_PAT | BIND_PAT => true,
3372 _ => false,
3373 }
3374 }
3375 fn cast(syntax: SyntaxNode) -> Option<Self> {
3376 let res = match syntax.kind() {
3377 RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }),
3378 BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }),
3379 _ => return None,
3380 };
3381 Some(res)
3382 }
3383 fn syntax(&self) -> &SyntaxNode {
3384 match self {
3385 RecordInnerPat::RecordFieldPat(it) => &it.syntax,
3386 RecordInnerPat::BindPat(it) => &it.syntax,
3387 }
3388 }
3389}
3390#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3391pub enum AttrInput {
3392 Literal(Literal),
3393 TokenTree(TokenTree),
3394}
3395impl From<Literal> for AttrInput {
3396 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) }
3397}
3398impl From<TokenTree> for AttrInput {
3399 fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) }
3400}
3401impl AstNode for AttrInput {
3402 fn can_cast(kind: SyntaxKind) -> bool {
3403 match kind {
3404 LITERAL | TOKEN_TREE => true,
3405 _ => false,
3406 }
3407 }
3408 fn cast(syntax: SyntaxNode) -> Option<Self> {
3409 let res = match syntax.kind() {
3410 LITERAL => AttrInput::Literal(Literal { syntax }),
3411 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
3412 _ => return None,
3413 };
3414 Some(res)
3415 }
3416 fn syntax(&self) -> &SyntaxNode {
3417 match self {
3418 AttrInput::Literal(it) => &it.syntax,
3419 AttrInput::TokenTree(it) => &it.syntax,
3420 }
3421 }
3422}
3423#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3424pub enum Stmt {
3425 LetStmt(LetStmt),
3426 ExprStmt(ExprStmt),
3427}
3428impl From<LetStmt> for Stmt {
3429 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3430}
3431impl From<ExprStmt> for Stmt {
3432 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
3433}
3434impl AstNode for Stmt {
3435 fn can_cast(kind: SyntaxKind) -> bool {
3436 match kind {
3437 LET_STMT | EXPR_STMT => true,
3438 _ => false,
3439 }
3440 }
3441 fn cast(syntax: SyntaxNode) -> Option<Self> {
3442 let res = match syntax.kind() {
3443 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3444 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3445 _ => return None,
3446 };
3447 Some(res)
3448 }
3449 fn syntax(&self) -> &SyntaxNode {
3450 match self {
3451 Stmt::LetStmt(it) => &it.syntax,
3452 Stmt::ExprStmt(it) => &it.syntax,
3453 }
3454 }
3455}
3456#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3457pub enum FieldDefList {
3458 RecordFieldDefList(RecordFieldDefList),
3459 TupleFieldDefList(TupleFieldDefList),
3460}
3461impl From<RecordFieldDefList> for FieldDefList {
3462 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
3463}
3464impl From<TupleFieldDefList> for FieldDefList {
3465 fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) }
3466}
3467impl AstNode for FieldDefList {
3468 fn can_cast(kind: SyntaxKind) -> bool {
3469 match kind {
3470 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
3471 _ => false,
3472 }
3473 }
3474 fn cast(syntax: SyntaxNode) -> Option<Self> {
3475 let res = match syntax.kind() {
3476 RECORD_FIELD_DEF_LIST => {
3477 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
3478 }
3479 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
3480 _ => return None,
3481 };
3482 Some(res)
3483 }
3484 fn syntax(&self) -> &SyntaxNode {
3485 match self {
3486 FieldDefList::RecordFieldDefList(it) => &it.syntax,
3487 FieldDefList::TupleFieldDefList(it) => &it.syntax,
3488 }
3489 }
3490}
3491impl std::fmt::Display for NominalDef {
3492 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3493 std::fmt::Display::fmt(self.syntax(), f)
3494 }
3495}
3496impl std::fmt::Display for GenericParam {
3497 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3498 std::fmt::Display::fmt(self.syntax(), f)
3499 }
3500}
3501impl std::fmt::Display for GenericArg {
3502 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3503 std::fmt::Display::fmt(self.syntax(), f)
3504 }
3505}
3506impl std::fmt::Display for TypeRef {
3507 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3508 std::fmt::Display::fmt(self.syntax(), f)
3509 }
3510}
3511impl std::fmt::Display for ModuleItem {
3512 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3513 std::fmt::Display::fmt(self.syntax(), f)
3514 }
3515}
3516impl std::fmt::Display for ImplItem {
3517 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3518 std::fmt::Display::fmt(self.syntax(), f)
3519 }
3520}
3521impl std::fmt::Display for ExternItem {
3522 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3523 std::fmt::Display::fmt(self.syntax(), f)
3524 }
3525}
3526impl std::fmt::Display for Expr {
3527 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3528 std::fmt::Display::fmt(self.syntax(), f)
3529 }
3530}
3531impl std::fmt::Display for Pat {
3532 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3533 std::fmt::Display::fmt(self.syntax(), f)
3534 }
3535}
3536impl std::fmt::Display for RecordInnerPat {
3537 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3538 std::fmt::Display::fmt(self.syntax(), f)
3539 }
3540}
3541impl std::fmt::Display for AttrInput {
3542 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3543 std::fmt::Display::fmt(self.syntax(), f)
3544 }
3545}
3546impl std::fmt::Display for Stmt {
3547 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3548 std::fmt::Display::fmt(self.syntax(), f)
3549 }
3550}
3551impl std::fmt::Display for FieldDefList {
3552 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3553 std::fmt::Display::fmt(self.syntax(), f)
3554 }
3555}
3556impl std::fmt::Display for SourceFile {
3557 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3558 std::fmt::Display::fmt(self.syntax(), f)
3559 }
3560}
3561impl std::fmt::Display for FnDef {
3562 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3563 std::fmt::Display::fmt(self.syntax(), f)
3564 }
3565}
3566impl std::fmt::Display for RetType {
3567 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3568 std::fmt::Display::fmt(self.syntax(), f)
3569 }
3570}
3571impl std::fmt::Display for StructDef {
3572 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3573 std::fmt::Display::fmt(self.syntax(), f)
3574 }
3575}
3576impl std::fmt::Display for UnionDef {
3577 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3578 std::fmt::Display::fmt(self.syntax(), f)
3579 }
3580}
3581impl std::fmt::Display for RecordFieldDefList {
3582 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3583 std::fmt::Display::fmt(self.syntax(), f)
3584 }
3585}
3586impl std::fmt::Display for RecordFieldDef {
3587 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3588 std::fmt::Display::fmt(self.syntax(), f)
3589 }
3590}
3591impl std::fmt::Display for TupleFieldDefList {
3592 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3593 std::fmt::Display::fmt(self.syntax(), f)
3594 }
3595}
3596impl std::fmt::Display for TupleFieldDef {
3597 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3598 std::fmt::Display::fmt(self.syntax(), f)
3599 }
3600}
3601impl std::fmt::Display for EnumDef {
3602 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3603 std::fmt::Display::fmt(self.syntax(), f)
3604 }
3605}
3606impl std::fmt::Display for EnumVariantList {
3607 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3608 std::fmt::Display::fmt(self.syntax(), f)
3609 }
3610}
3611impl std::fmt::Display for EnumVariant {
3612 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3613 std::fmt::Display::fmt(self.syntax(), f)
3614 }
3615}
3616impl std::fmt::Display for TraitDef {
3617 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3618 std::fmt::Display::fmt(self.syntax(), f)
3619 }
3620}
3621impl std::fmt::Display for Module {
3622 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3623 std::fmt::Display::fmt(self.syntax(), f)
3624 }
3625}
3626impl std::fmt::Display for ItemList {
3627 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3628 std::fmt::Display::fmt(self.syntax(), f)
3629 }
3630}
3631impl std::fmt::Display for ConstDef {
3632 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3633 std::fmt::Display::fmt(self.syntax(), f)
3634 }
3635}
3636impl std::fmt::Display for StaticDef {
3637 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3638 std::fmt::Display::fmt(self.syntax(), f)
3639 }
3640}
3641impl std::fmt::Display for TypeAliasDef {
3642 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3643 std::fmt::Display::fmt(self.syntax(), f)
3644 }
3645}
3646impl std::fmt::Display for ImplDef {
3647 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3648 std::fmt::Display::fmt(self.syntax(), f)
3649 }
3650}
3651impl std::fmt::Display for ParenType {
3652 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3653 std::fmt::Display::fmt(self.syntax(), f)
3654 }
3655}
3656impl std::fmt::Display for TupleType {
3657 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3658 std::fmt::Display::fmt(self.syntax(), f)
3659 }
3660}
3661impl std::fmt::Display for NeverType {
3662 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3663 std::fmt::Display::fmt(self.syntax(), f)
3664 }
3665}
3666impl std::fmt::Display for PathType {
3667 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3668 std::fmt::Display::fmt(self.syntax(), f)
3669 }
3670}
3671impl std::fmt::Display for PointerType {
3672 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3673 std::fmt::Display::fmt(self.syntax(), f)
3674 }
3675}
3676impl std::fmt::Display for ArrayType {
3677 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3678 std::fmt::Display::fmt(self.syntax(), f)
3679 }
3680}
3681impl std::fmt::Display for SliceType {
3682 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3683 std::fmt::Display::fmt(self.syntax(), f)
3684 }
3685}
3686impl std::fmt::Display for ReferenceType {
3687 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3688 std::fmt::Display::fmt(self.syntax(), f)
3689 }
3690}
3691impl std::fmt::Display for PlaceholderType {
3692 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3693 std::fmt::Display::fmt(self.syntax(), f)
3694 }
3695}
3696impl std::fmt::Display for FnPointerType {
3697 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3698 std::fmt::Display::fmt(self.syntax(), f)
3699 }
3700}
3701impl std::fmt::Display for ForType {
3702 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3703 std::fmt::Display::fmt(self.syntax(), f)
3704 }
3705}
3706impl std::fmt::Display for ImplTraitType {
3707 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3708 std::fmt::Display::fmt(self.syntax(), f)
3709 }
3710}
3711impl std::fmt::Display for DynTraitType {
3712 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3713 std::fmt::Display::fmt(self.syntax(), f)
3714 }
3715}
3716impl std::fmt::Display for TupleExpr {
3717 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3718 std::fmt::Display::fmt(self.syntax(), f)
3719 }
3720}
3721impl std::fmt::Display for ArrayExpr {
3722 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3723 std::fmt::Display::fmt(self.syntax(), f)
3724 }
3725}
3726impl std::fmt::Display for ParenExpr {
3727 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3728 std::fmt::Display::fmt(self.syntax(), f)
3729 }
3730}
3731impl std::fmt::Display for PathExpr {
3732 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3733 std::fmt::Display::fmt(self.syntax(), f)
3734 }
3735}
3736impl std::fmt::Display for LambdaExpr {
3737 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3738 std::fmt::Display::fmt(self.syntax(), f)
3739 }
3740}
3741impl std::fmt::Display for IfExpr {
3742 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3743 std::fmt::Display::fmt(self.syntax(), f)
3744 }
3745}
3746impl std::fmt::Display for LoopExpr {
3747 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3748 std::fmt::Display::fmt(self.syntax(), f)
3749 }
3750}
3751impl std::fmt::Display for TryBlockExpr {
3752 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3753 std::fmt::Display::fmt(self.syntax(), f)
3754 }
3755}
3756impl std::fmt::Display for ForExpr {
3757 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3758 std::fmt::Display::fmt(self.syntax(), f)
3759 }
3760}
3761impl std::fmt::Display for WhileExpr {
3762 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3763 std::fmt::Display::fmt(self.syntax(), f)
3764 }
3765}
3766impl std::fmt::Display for ContinueExpr {
3767 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3768 std::fmt::Display::fmt(self.syntax(), f)
3769 }
3770}
3771impl std::fmt::Display for BreakExpr {
3772 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3773 std::fmt::Display::fmt(self.syntax(), f)
3774 }
3775}
3776impl std::fmt::Display for Label {
3777 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3778 std::fmt::Display::fmt(self.syntax(), f)
3779 }
3780}
3781impl std::fmt::Display for BlockExpr {
3782 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3783 std::fmt::Display::fmt(self.syntax(), f)
3784 }
3785}
3786impl std::fmt::Display for ReturnExpr {
3787 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3788 std::fmt::Display::fmt(self.syntax(), f)
3789 }
3790}
3791impl std::fmt::Display for CallExpr {
3792 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3793 std::fmt::Display::fmt(self.syntax(), f)
3794 }
3795}
3796impl std::fmt::Display for MethodCallExpr {
3797 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3798 std::fmt::Display::fmt(self.syntax(), f)
3799 }
3800}
3801impl std::fmt::Display for IndexExpr {
3802 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3803 std::fmt::Display::fmt(self.syntax(), f)
3804 }
3805}
3806impl std::fmt::Display for FieldExpr {
3807 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3808 std::fmt::Display::fmt(self.syntax(), f)
3809 }
3810}
3811impl std::fmt::Display for AwaitExpr {
3812 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3813 std::fmt::Display::fmt(self.syntax(), f)
3814 }
3815}
3816impl std::fmt::Display for TryExpr {
3817 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3818 std::fmt::Display::fmt(self.syntax(), f)
3819 }
3820}
3821impl std::fmt::Display for CastExpr {
3822 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3823 std::fmt::Display::fmt(self.syntax(), f)
3824 }
3825}
3826impl std::fmt::Display for RefExpr {
3827 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3828 std::fmt::Display::fmt(self.syntax(), f)
3829 }
3830}
3831impl std::fmt::Display for PrefixExpr {
3832 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3833 std::fmt::Display::fmt(self.syntax(), f)
3834 }
3835}
3836impl std::fmt::Display for BoxExpr {
3837 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3838 std::fmt::Display::fmt(self.syntax(), f)
3839 }
3840}
3841impl std::fmt::Display for RangeExpr {
3842 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3843 std::fmt::Display::fmt(self.syntax(), f)
3844 }
3845}
3846impl std::fmt::Display for BinExpr {
3847 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3848 std::fmt::Display::fmt(self.syntax(), f)
3849 }
3850}
3851impl std::fmt::Display for Literal {
3852 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3853 std::fmt::Display::fmt(self.syntax(), f)
3854 }
3855}
3856impl std::fmt::Display for MatchExpr {
3857 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3858 std::fmt::Display::fmt(self.syntax(), f)
3859 }
3860}
3861impl std::fmt::Display for MatchArmList {
3862 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3863 std::fmt::Display::fmt(self.syntax(), f)
3864 }
3865}
3866impl std::fmt::Display for MatchArm {
3867 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3868 std::fmt::Display::fmt(self.syntax(), f)
3869 }
3870}
3871impl std::fmt::Display for MatchGuard {
3872 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3873 std::fmt::Display::fmt(self.syntax(), f)
3874 }
3875}
3876impl std::fmt::Display for RecordLit {
3877 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3878 std::fmt::Display::fmt(self.syntax(), f)
3879 }
3880}
3881impl std::fmt::Display for RecordFieldList {
3882 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3883 std::fmt::Display::fmt(self.syntax(), f)
3884 }
3885}
3886impl std::fmt::Display for RecordField {
3887 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3888 std::fmt::Display::fmt(self.syntax(), f)
3889 }
3890}
3891impl std::fmt::Display for OrPat {
3892 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3893 std::fmt::Display::fmt(self.syntax(), f)
3894 }
3895}
3896impl std::fmt::Display for ParenPat {
3897 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3898 std::fmt::Display::fmt(self.syntax(), f)
3899 }
3900}
3901impl std::fmt::Display for RefPat {
3902 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3903 std::fmt::Display::fmt(self.syntax(), f)
3904 }
3905}
3906impl std::fmt::Display for BoxPat {
3907 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3908 std::fmt::Display::fmt(self.syntax(), f)
3909 }
3910}
3911impl std::fmt::Display for BindPat {
3912 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3913 std::fmt::Display::fmt(self.syntax(), f)
3914 }
3915}
3916impl std::fmt::Display for PlaceholderPat {
3917 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3918 std::fmt::Display::fmt(self.syntax(), f)
3919 }
3920}
3921impl std::fmt::Display for DotDotPat {
3922 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3923 std::fmt::Display::fmt(self.syntax(), f)
3924 }
3925}
3926impl std::fmt::Display for PathPat {
3927 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3928 std::fmt::Display::fmt(self.syntax(), f)
3929 }
3930}
3931impl std::fmt::Display for SlicePat {
3932 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3933 std::fmt::Display::fmt(self.syntax(), f)
3934 }
3935}
3936impl std::fmt::Display for RangePat {
3937 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3938 std::fmt::Display::fmt(self.syntax(), f)
3939 }
3940}
3941impl std::fmt::Display for LiteralPat {
3942 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3943 std::fmt::Display::fmt(self.syntax(), f)
3944 }
3945}
3946impl std::fmt::Display for MacroPat {
3947 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3948 std::fmt::Display::fmt(self.syntax(), f)
3949 }
3950}
3951impl std::fmt::Display for RecordPat {
3952 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3953 std::fmt::Display::fmt(self.syntax(), f)
3954 }
3955}
3956impl std::fmt::Display for RecordFieldPatList {
3957 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3958 std::fmt::Display::fmt(self.syntax(), f)
3959 }
3960}
3961impl std::fmt::Display for RecordFieldPat {
3962 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3963 std::fmt::Display::fmt(self.syntax(), f)
3964 }
3965}
3966impl std::fmt::Display for TupleStructPat {
3967 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3968 std::fmt::Display::fmt(self.syntax(), f)
3969 }
3970}
3971impl std::fmt::Display for TuplePat {
3972 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3973 std::fmt::Display::fmt(self.syntax(), f)
3974 }
3975}
3976impl std::fmt::Display for Visibility {
3977 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3978 std::fmt::Display::fmt(self.syntax(), f)
3979 }
3980}
3981impl std::fmt::Display for Name {
3982 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3983 std::fmt::Display::fmt(self.syntax(), f)
3984 }
3985}
3986impl std::fmt::Display for NameRef {
3987 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3988 std::fmt::Display::fmt(self.syntax(), f)
3989 }
3990}
3991impl std::fmt::Display for MacroCall {
3992 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3993 std::fmt::Display::fmt(self.syntax(), f)
3994 }
3995}
3996impl std::fmt::Display for Attr {
3997 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3998 std::fmt::Display::fmt(self.syntax(), f)
3999 }
4000}
4001impl std::fmt::Display for TokenTree {
4002 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4003 std::fmt::Display::fmt(self.syntax(), f)
4004 }
4005}
4006impl std::fmt::Display for TypeParamList {
4007 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4008 std::fmt::Display::fmt(self.syntax(), f)
4009 }
4010}
4011impl std::fmt::Display for TypeParam {
4012 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4013 std::fmt::Display::fmt(self.syntax(), f)
4014 }
4015}
4016impl std::fmt::Display for ConstParam {
4017 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4018 std::fmt::Display::fmt(self.syntax(), f)
4019 }
4020}
4021impl std::fmt::Display for LifetimeParam {
4022 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4023 std::fmt::Display::fmt(self.syntax(), f)
4024 }
4025}
4026impl std::fmt::Display for TypeBound {
4027 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4028 std::fmt::Display::fmt(self.syntax(), f)
4029 }
4030}
4031impl std::fmt::Display for TypeBoundList {
4032 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4033 std::fmt::Display::fmt(self.syntax(), f)
4034 }
4035}
4036impl std::fmt::Display for WherePred {
4037 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4038 std::fmt::Display::fmt(self.syntax(), f)
4039 }
4040}
4041impl std::fmt::Display for WhereClause {
4042 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4043 std::fmt::Display::fmt(self.syntax(), f)
4044 }
4045}
4046impl std::fmt::Display for Abi {
4047 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4048 std::fmt::Display::fmt(self.syntax(), f)
4049 }
4050}
4051impl std::fmt::Display for ExprStmt {
4052 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4053 std::fmt::Display::fmt(self.syntax(), f)
4054 }
4055}
4056impl std::fmt::Display for LetStmt {
4057 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4058 std::fmt::Display::fmt(self.syntax(), f)
4059 }
4060}
4061impl std::fmt::Display for Condition {
4062 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4063 std::fmt::Display::fmt(self.syntax(), f)
4064 }
4065}
4066impl std::fmt::Display for Block {
4067 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4068 std::fmt::Display::fmt(self.syntax(), f)
4069 }
4070}
4071impl std::fmt::Display for ParamList {
4072 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4073 std::fmt::Display::fmt(self.syntax(), f)
4074 }
4075}
4076impl std::fmt::Display for SelfParam {
4077 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4078 std::fmt::Display::fmt(self.syntax(), f)
4079 }
4080}
4081impl std::fmt::Display for Param {
4082 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4083 std::fmt::Display::fmt(self.syntax(), f)
4084 }
4085}
4086impl std::fmt::Display for UseItem {
4087 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4088 std::fmt::Display::fmt(self.syntax(), f)
4089 }
4090}
4091impl std::fmt::Display for UseTree {
4092 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4093 std::fmt::Display::fmt(self.syntax(), f)
4094 }
4095}
4096impl std::fmt::Display for Alias {
4097 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4098 std::fmt::Display::fmt(self.syntax(), f)
4099 }
4100}
4101impl std::fmt::Display for UseTreeList {
4102 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4103 std::fmt::Display::fmt(self.syntax(), f)
4104 }
4105}
4106impl std::fmt::Display for ExternCrateItem {
4107 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4108 std::fmt::Display::fmt(self.syntax(), f)
4109 }
4110}
4111impl std::fmt::Display for ArgList {
4112 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4113 std::fmt::Display::fmt(self.syntax(), f)
4114 }
4115}
4116impl std::fmt::Display for Path {
4117 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4118 std::fmt::Display::fmt(self.syntax(), f)
4119 }
4120}
4121impl std::fmt::Display for PathSegment {
4122 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4123 std::fmt::Display::fmt(self.syntax(), f)
4124 }
4125}
4126impl std::fmt::Display for TypeArgList {
4127 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4128 std::fmt::Display::fmt(self.syntax(), f)
4129 }
4130}
4131impl std::fmt::Display for TypeArg {
4132 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4133 std::fmt::Display::fmt(self.syntax(), f)
4134 }
4135}
4136impl std::fmt::Display for AssocTypeArg {
4137 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4138 std::fmt::Display::fmt(self.syntax(), f)
4139 }
4140}
4141impl std::fmt::Display for LifetimeArg {
4142 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4143 std::fmt::Display::fmt(self.syntax(), f)
4144 }
4145}
4146impl std::fmt::Display for ConstArg {
4147 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4148 std::fmt::Display::fmt(self.syntax(), f)
4149 }
4150}
4151impl std::fmt::Display for MacroItems {
4152 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4153 std::fmt::Display::fmt(self.syntax(), f)
4154 }
4155}
4156impl std::fmt::Display for MacroStmts {
4157 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4158 std::fmt::Display::fmt(self.syntax(), f)
4159 }
4160}
4161impl std::fmt::Display for ExternItemList {
4162 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4163 std::fmt::Display::fmt(self.syntax(), f)
4164 }
4165}
4166impl std::fmt::Display for ExternBlock {
4167 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4168 std::fmt::Display::fmt(self.syntax(), f)
4169 }
4170}
4171impl std::fmt::Display for MetaItem {
4172 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4173 std::fmt::Display::fmt(self.syntax(), f)
4174 }
4175}
4176impl std::fmt::Display for MacroDef {
4177 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4178 std::fmt::Display::fmt(self.syntax(), f)
4179 }
4180}
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
new file mode 100644
index 000000000..e64b8bce6
--- /dev/null
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -0,0 +1,2808 @@
1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2
3use crate::{
4 ast::AstToken,
5 SyntaxKind::{self, *},
6 SyntaxToken,
7};
8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
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)]
2149pub struct Whitespace {
2150 pub(crate) syntax: SyntaxToken,
2151}
2152impl std::fmt::Display for Whitespace {
2153 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2154 std::fmt::Display::fmt(&self.syntax, f)
2155 }
2156}
2157impl AstToken for Whitespace {
2158 fn can_cast(kind: SyntaxKind) -> bool { kind == WHITESPACE }
2159 fn cast(syntax: SyntaxToken) -> Option<Self> {
2160 if Self::can_cast(syntax.kind()) {
2161 Some(Self { syntax })
2162 } else {
2163 None
2164 }
2165 }
2166 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2167}
2168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
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)]
2189pub struct Comment {
2190 pub(crate) syntax: SyntaxToken,
2191}
2192impl std::fmt::Display for Comment {
2193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2194 std::fmt::Display::fmt(&self.syntax, f)
2195 }
2196}
2197impl AstToken for Comment {
2198 fn can_cast(kind: SyntaxKind) -> bool { kind == COMMENT }
2199 fn cast(syntax: SyntaxToken) -> Option<Self> {
2200 if Self::can_cast(syntax.kind()) {
2201 Some(Self { syntax })
2202 } else {
2203 None
2204 }
2205 }
2206 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2207}
2208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2209pub struct Shebang {
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,
2231}
2232impl std::fmt::Display for LDollar {
2233 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2234 std::fmt::Display::fmt(&self.syntax, f)
2235 }
2236}
2237impl AstToken for LDollar {
2238 fn can_cast(kind: SyntaxKind) -> bool { kind == L_DOLLAR }
2239 fn cast(syntax: SyntaxToken) -> Option<Self> {
2240 if Self::can_cast(syntax.kind()) {
2241 Some(Self { syntax })
2242 } else {
2243 None
2244 }
2245 }
2246 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2247}
2248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2249pub struct RDollar {
2250 pub(crate) syntax: SyntaxToken,
2251}
2252impl std::fmt::Display for RDollar {
2253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2254 std::fmt::Display::fmt(&self.syntax, f)
2255 }
2256}
2257impl AstToken for RDollar {
2258 fn can_cast(kind: SyntaxKind) -> bool { kind == R_DOLLAR }
2259 fn cast(syntax: SyntaxToken) -> Option<Self> {
2260 if Self::can_cast(syntax.kind()) {
2261 Some(Self { syntax })
2262 } else {
2263 None
2264 }
2265 }
2266 fn syntax(&self) -> &SyntaxToken { &self.syntax }
2267}
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/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs
index 1a51b8d3b..e8320b57e 100644
--- a/crates/ra_syntax/src/ast/tokens.rs
+++ b/crates/ra_syntax/src/ast/tokens.rs
@@ -1,26 +1,10 @@
1//! There are many AstNodes, but only a few tokens, so we hand-write them here. 1//! There are many AstNodes, but only a few tokens, so we hand-write them here.
2 2
3use crate::{ 3use crate::{
4 ast::AstToken, 4 ast::{AstToken, Comment, RawString, String, Whitespace},
5 SyntaxKind::{COMMENT, RAW_STRING, STRING, WHITESPACE}, 5 TextRange, TextUnit,
6 SyntaxToken, TextRange, TextUnit,
7}; 6};
8 7
9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
10pub struct Comment(SyntaxToken);
11
12impl AstToken for Comment {
13 fn cast(token: SyntaxToken) -> Option<Self> {
14 match token.kind() {
15 COMMENT => Some(Comment(token)),
16 _ => None,
17 }
18 }
19 fn syntax(&self) -> &SyntaxToken {
20 &self.0
21 }
22}
23
24impl Comment { 8impl Comment {
25 pub fn kind(&self) -> CommentKind { 9 pub fn kind(&self) -> CommentKind {
26 kind_by_prefix(self.text()) 10 kind_by_prefix(self.text())
@@ -89,20 +73,6 @@ fn prefix_by_kind(kind: CommentKind) -> &'static str {
89 unreachable!() 73 unreachable!()
90} 74}
91 75
92pub struct Whitespace(SyntaxToken);
93
94impl AstToken for Whitespace {
95 fn cast(token: SyntaxToken) -> Option<Self> {
96 match token.kind() {
97 WHITESPACE => Some(Whitespace(token)),
98 _ => None,
99 }
100 }
101 fn syntax(&self) -> &SyntaxToken {
102 &self.0
103 }
104}
105
106impl Whitespace { 76impl Whitespace {
107 pub fn spans_multiple_lines(&self) -> bool { 77 pub fn spans_multiple_lines(&self) -> bool {
108 let text = self.text(); 78 let text = self.text();
@@ -168,20 +138,6 @@ pub trait HasStringValue: HasQuotes {
168 fn value(&self) -> Option<std::string::String>; 138 fn value(&self) -> Option<std::string::String>;
169} 139}
170 140
171pub struct String(SyntaxToken);
172
173impl AstToken for String {
174 fn cast(token: SyntaxToken) -> Option<Self> {
175 match token.kind() {
176 STRING => Some(String(token)),
177 _ => None,
178 }
179 }
180 fn syntax(&self) -> &SyntaxToken {
181 &self.0
182 }
183}
184
185impl HasStringValue for String { 141impl HasStringValue for String {
186 fn value(&self) -> Option<std::string::String> { 142 fn value(&self) -> Option<std::string::String> {
187 let text = self.text().as_str(); 143 let text = self.text().as_str();
@@ -201,20 +157,6 @@ impl HasStringValue for String {
201 } 157 }
202} 158}
203 159
204pub struct RawString(SyntaxToken);
205
206impl AstToken for RawString {
207 fn cast(token: SyntaxToken) -> Option<Self> {
208 match token.kind() {
209 RAW_STRING => Some(RawString(token)),
210 _ => None,
211 }
212 }
213 fn syntax(&self) -> &SyntaxToken {
214 &self.0
215 }
216}
217
218impl HasStringValue for RawString { 160impl HasStringValue for RawString {
219 fn value(&self) -> Option<std::string::String> { 161 fn value(&self) -> Option<std::string::String> {
220 let text = self.text().as_str(); 162 let text = self.text().as_str();
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 576378306..870e83804 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -5,7 +5,7 @@
5use itertools::Itertools; 5use itertools::Itertools;
6 6
7use crate::{ 7use crate::{
8 ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, 8 ast::{self, child_opt, children, support, AstChildren, AstNode, AstToken},
9 syntax_node::SyntaxElementChildren, 9 syntax_node::SyntaxElementChildren,
10}; 10};
11 11
@@ -31,6 +31,10 @@ pub trait LoopBodyOwner: AstNode {
31 fn loop_body(&self) -> Option<ast::BlockExpr> { 31 fn loop_body(&self) -> Option<ast::BlockExpr> {
32 child_opt(self) 32 child_opt(self)
33 } 33 }
34
35 fn label(&self) -> Option<ast::Label> {
36 child_opt(self)
37 }
34} 38}
35 39
36pub trait ArgListOwner: AstNode { 40pub trait ArgListOwner: AstNode {
@@ -65,6 +69,10 @@ pub trait TypeBoundsOwner: AstNode {
65 fn type_bound_list(&self) -> Option<ast::TypeBoundList> { 69 fn type_bound_list(&self) -> Option<ast::TypeBoundList> {
66 child_opt(self) 70 child_opt(self)
67 } 71 }
72
73 fn colon(&self) -> Option<ast::Colon> {
74 support::token(self.syntax())
75 }
68} 76}
69 77
70pub trait AttrsOwner: AstNode { 78pub trait AttrsOwner: AstNode {
diff --git a/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast b/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast
new file mode 100644
index 000000000..1b0acf47c
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast
@@ -0,0 +1,61 @@
1SOURCE_FILE@[0; 40)
2 FN_DEF@[0; 39)
3 FN_KW@[0; 2) "fn"
4 WHITESPACE@[2; 3) " "
5 NAME@[3; 4)
6 IDENT@[3; 4) "f"
7 TYPE_PARAM_LIST@[4; 7)
8 L_ANGLE@[4; 5) "<"
9 TYPE_PARAM@[5; 6)
10 NAME@[5; 6)
11 IDENT@[5; 6) "T"
12 R_ANGLE@[6; 7) ">"
13 PARAM_LIST@[7; 9)
14 L_PAREN@[7; 8) "("
15 R_PAREN@[8; 9) ")"
16 WHITESPACE@[9; 10) " "
17 WHERE_CLAUSE@[10; 36)
18 WHERE_KW@[10; 15) "where"
19 WHITESPACE@[15; 16) " "
20 WHERE_PRED@[16; 36)
21 PATH_TYPE@[16; 17)
22 PATH@[16; 17)
23 PATH_SEGMENT@[16; 17)
24 NAME_REF@[16; 17)
25 IDENT@[16; 17) "T"
26 COLON@[17; 18) ":"
27 WHITESPACE@[18; 19) " "
28 TYPE_BOUND_LIST@[19; 36)
29 TYPE_BOUND@[19; 29)
30 PATH_TYPE@[19; 29)
31 PATH@[19; 29)
32 PATH_SEGMENT@[19; 29)
33 NAME_REF@[19; 21)
34 IDENT@[19; 21) "Fn"
35 PARAM_LIST@[21; 23)
36 L_PAREN@[21; 22) "("
37 R_PAREN@[22; 23) ")"
38 WHITESPACE@[23; 24) " "
39 RET_TYPE@[24; 29)
40 THIN_ARROW@[24; 26) "->"
41 WHITESPACE@[26; 27) " "
42 PATH_TYPE@[27; 29)
43 PATH@[27; 29)
44 PATH_SEGMENT@[27; 29)
45 NAME_REF@[27; 29)
46 IDENT@[27; 29) "u8"
47 WHITESPACE@[29; 30) " "
48 PLUS@[30; 31) "+"
49 WHITESPACE@[31; 32) " "
50 TYPE_BOUND@[32; 36)
51 PATH_TYPE@[32; 36)
52 PATH@[32; 36)
53 PATH_SEGMENT@[32; 36)
54 NAME_REF@[32; 36)
55 IDENT@[32; 36) "Send"
56 WHITESPACE@[36; 37) " "
57 BLOCK_EXPR@[37; 39)
58 BLOCK@[37; 39)
59 L_CURLY@[37; 38) "{"
60 R_CURLY@[38; 39) "}"
61 WHITESPACE@[39; 40) "\n"
diff --git a/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs b/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs
new file mode 100644
index 000000000..29f3655e0
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs
@@ -0,0 +1 @@
fn f<T>() where T: Fn() -> u8 + Send {}