1 //! Generated file, do not edit by hand, see `xtask/src/codegen`
4 ast::{self, support, AstChildren, AstNode},
6 SyntaxNode, SyntaxToken, T,
8 /// The entire Rust source file. Includes all top-level inner attributes and module items.
10 /// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html)
11 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
12 pub struct SourceFile {
13 pub(crate) syntax: SyntaxNode,
15 impl ast::ModuleItemOwner for SourceFile {}
16 impl ast::AttrsOwner for SourceFile {}
17 impl ast::DocCommentsOwner for SourceFile {}
19 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) }
21 /// Function definition either with body or not.
22 /// Includes all of its attributes and doc comments.
28 /// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32
37 /// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
41 /// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
42 /// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
43 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
45 pub(crate) syntax: SyntaxNode,
47 impl ast::VisibilityOwner for FnDef {}
48 impl ast::NameOwner for FnDef {}
49 impl ast::TypeParamsOwner for FnDef {}
50 impl ast::DocCommentsOwner for FnDef {}
51 impl ast::AttrsOwner for FnDef {}
53 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
54 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
55 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
56 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
57 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
58 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
59 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
60 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
61 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
62 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
64 /// Return type annotation.
67 /// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) }
70 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
71 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
73 pub(crate) syntax: SyntaxNode,
76 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
77 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
79 /// Struct definition.
80 /// Includes all of its attributes and doc comments.
86 /// struct Foo<T> where T: Debug {
95 /// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱
98 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
99 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
100 pub struct StructDef {
101 pub(crate) syntax: SyntaxNode,
103 impl ast::VisibilityOwner for StructDef {}
104 impl ast::NameOwner for StructDef {}
105 impl ast::TypeParamsOwner for StructDef {}
106 impl ast::AttrsOwner for StructDef {}
107 impl ast::DocCommentsOwner for StructDef {}
109 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
110 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
111 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
113 /// Union definition.
114 /// Includes all of its attributes and doc comments.
120 /// pub union Foo<T> where T: Debug {
129 /// [Reference](https://doc.rust-lang.org/reference/items/unions.html)
130 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
131 pub struct UnionDef {
132 pub(crate) syntax: SyntaxNode,
134 impl ast::VisibilityOwner for UnionDef {}
135 impl ast::NameOwner for UnionDef {}
136 impl ast::TypeParamsOwner for UnionDef {}
137 impl ast::AttrsOwner for UnionDef {}
138 impl ast::DocCommentsOwner for UnionDef {}
140 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
141 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
142 support::child(&self.syntax)
145 /// Record field definition list including enclosing curly braces.
148 /// struct Foo // same for union
157 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
158 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
159 pub struct RecordFieldDefList {
160 pub(crate) syntax: SyntaxNode,
162 impl RecordFieldDefList {
163 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
164 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) }
165 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
167 /// Record field definition including its attributes and doc comments.
182 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
183 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
184 pub struct RecordFieldDef {
185 pub(crate) syntax: SyntaxNode,
187 impl ast::VisibilityOwner for RecordFieldDef {}
188 impl ast::NameOwner for RecordFieldDef {}
189 impl ast::AttrsOwner for RecordFieldDef {}
190 impl ast::DocCommentsOwner for RecordFieldDef {}
191 impl ast::TypeAscriptionOwner for RecordFieldDef {}
192 impl RecordFieldDef {}
193 /// Tuple field definition list including enclosing parens.
196 /// struct Foo ❰ (u32, String, Vec<u32>) ❱;
199 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
200 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
201 pub struct TupleFieldDefList {
202 pub(crate) syntax: SyntaxNode,
204 impl TupleFieldDefList {
205 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
206 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) }
207 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
209 /// Tuple field definition including its attributes.
212 /// struct Foo(❰ #[attr] u32 ❱);
215 /// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
216 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
217 pub struct TupleFieldDef {
218 pub(crate) syntax: SyntaxNode,
220 impl ast::VisibilityOwner for TupleFieldDef {}
221 impl ast::AttrsOwner for TupleFieldDef {}
223 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
226 /// Includes all of its attributes and doc comments.
232 /// pub enum Foo<T> where T: Debug {
236 /// Baz(#[attr] u32),
247 /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
248 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
250 pub(crate) syntax: SyntaxNode,
252 impl ast::VisibilityOwner for EnumDef {}
253 impl ast::NameOwner for EnumDef {}
254 impl ast::TypeParamsOwner for EnumDef {}
255 impl ast::AttrsOwner for EnumDef {}
256 impl ast::DocCommentsOwner for EnumDef {}
258 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
259 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
261 /// Enum variant definition list including enclosing curly braces.
276 /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
277 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
278 pub struct EnumVariantList {
279 pub(crate) syntax: SyntaxNode,
281 impl EnumVariantList {
282 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
283 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) }
284 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
286 /// Enum variant definition including its attributes and discriminant value definition.
296 /// // same for tuple and record variants
300 /// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
301 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
302 pub struct EnumVariant {
303 pub(crate) syntax: SyntaxNode,
305 impl ast::VisibilityOwner for EnumVariant {}
306 impl ast::NameOwner for EnumVariant {}
307 impl ast::DocCommentsOwner for EnumVariant {}
308 impl ast::AttrsOwner for EnumVariant {}
310 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
311 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
314 /// Trait definition.
315 /// Includes all of its attributes and doc comments.
321 /// pub unsafe trait Foo<T>: Debug where T: Debug {
327 /// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
328 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
329 pub struct TraitDef {
330 pub(crate) syntax: SyntaxNode,
332 impl ast::VisibilityOwner for TraitDef {}
333 impl ast::NameOwner for TraitDef {}
334 impl ast::AttrsOwner for TraitDef {}
335 impl ast::DocCommentsOwner for TraitDef {}
336 impl ast::TypeParamsOwner for TraitDef {}
337 impl ast::TypeBoundsOwner for TraitDef {}
339 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
340 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
341 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
342 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
344 /// Module definition either with body or not.
345 /// Includes all of its inner and outer attributes, module items, doc comments.
364 /// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
365 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
367 pub(crate) syntax: SyntaxNode,
369 impl ast::VisibilityOwner for Module {}
370 impl ast::NameOwner for Module {}
371 impl ast::AttrsOwner for Module {}
372 impl ast::DocCommentsOwner for Module {}
374 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
375 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
376 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
378 /// Item defintion list.
379 /// This is used for both top-level items and impl block items.
387 /// const BRUUH: u32 = 42;
394 /// const BAZ: u32 = 42;
399 /// [Reference](https://doc.rust-lang.org/reference/items.html)
400 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
401 pub struct ItemList {
402 pub(crate) syntax: SyntaxNode,
404 impl ast::ModuleItemOwner for ItemList {}
406 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
407 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) }
408 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
410 /// Constant variable definition.
411 /// Includes all of its attributes and doc comments.
417 /// pub const FOO: u32 = 42;
421 /// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html)
422 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
423 pub struct ConstDef {
424 pub(crate) syntax: SyntaxNode,
426 impl ast::VisibilityOwner for ConstDef {}
427 impl ast::NameOwner for ConstDef {}
428 impl ast::TypeParamsOwner for ConstDef {}
429 impl ast::AttrsOwner for ConstDef {}
430 impl ast::DocCommentsOwner for ConstDef {}
431 impl ast::TypeAscriptionOwner for ConstDef {}
433 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
434 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
435 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
436 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
437 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
439 /// Static variable definition.
440 /// Includes all of its attributes and doc comments.
446 /// pub static mut FOO: u32 = 42;
450 /// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
451 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
452 pub struct StaticDef {
453 pub(crate) syntax: SyntaxNode,
455 impl ast::VisibilityOwner for StaticDef {}
456 impl ast::NameOwner for StaticDef {}
457 impl ast::TypeParamsOwner for StaticDef {}
458 impl ast::AttrsOwner for StaticDef {}
459 impl ast::DocCommentsOwner for StaticDef {}
460 impl ast::TypeAscriptionOwner for StaticDef {}
462 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
463 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
464 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
465 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
466 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
468 /// Type alias definition.
469 /// Includes associated type clauses with type bounds.
475 /// pub type Foo<T> where T: Debug = T;
479 /// ❰ type Baz: Debug; ❱
480 /// ❰ type Bruh = String; ❱
481 /// ❰ type Bruuh: Debug = u32; ❱
485 /// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
486 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
487 pub struct TypeAliasDef {
488 pub(crate) syntax: SyntaxNode,
490 impl ast::VisibilityOwner for TypeAliasDef {}
491 impl ast::NameOwner for TypeAliasDef {}
492 impl ast::TypeParamsOwner for TypeAliasDef {}
493 impl ast::AttrsOwner for TypeAliasDef {}
494 impl ast::DocCommentsOwner for TypeAliasDef {}
495 impl ast::TypeBoundsOwner for TypeAliasDef {}
497 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
498 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
499 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
500 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
501 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
503 /// Inherent and trait impl definition.
504 /// Includes all of its inner and outer attributes.
509 /// unsafe impl<T> !Foo for Bar where T: Debug {
516 /// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
517 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
519 pub(crate) syntax: SyntaxNode,
521 impl ast::TypeParamsOwner for ImplDef {}
522 impl ast::AttrsOwner for ImplDef {}
523 impl ast::DocCommentsOwner for ImplDef {}
525 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
526 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
527 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
528 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
529 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
530 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
531 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
533 /// Parenthesized type reference.
534 /// Note: parens are only used for grouping, this is not a tuple type.
537 /// // This is effectively just `u32`.
538 /// // Single-item tuple must be defined with a trailing comma: `(u32,)`
539 /// type Foo = ❰ (u32) ❱;
541 /// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
543 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
544 pub struct ParenType {
545 pub(crate) syntax: SyntaxNode,
548 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
549 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
550 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
552 /// Unnamed tuple type.
555 /// let foo: ❰ (u32, bool) ❱ = (42, true);
558 /// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
559 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
560 pub struct TupleType {
561 pub(crate) syntax: SyntaxNode,
564 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
565 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
566 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
568 /// The never type (i.e. the exclamation point).
573 /// fn no_return() -> ❰ ! ❱ {
578 /// [Reference](https://doc.rust-lang.org/reference/types/never.html)
579 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
580 pub struct NeverType {
581 pub(crate) syntax: SyntaxNode,
584 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
587 /// Includes single identifier type names and elaborate paths with
588 /// generic parameters.
591 /// type Foo = ❰ String ❱;
592 /// type Bar = ❰ std::vec::Vec<T> ❱;
593 /// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
596 /// [Reference](https://doc.rust-lang.org/reference/paths.html)
597 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
598 pub struct PathType {
599 pub(crate) syntax: SyntaxNode,
602 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
604 /// Raw pointer type.
607 /// type Foo = ❰ *const u32 ❱;
608 /// type Bar = ❰ *mut u32 ❱;
611 /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut)
612 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
613 pub struct PointerType {
614 pub(crate) syntax: SyntaxNode,
617 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
618 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
619 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
620 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
625 /// type Foo = ❰ [u32; 24 - 3] ❱;
628 /// [Reference](https://doc.rust-lang.org/reference/types/array.html)
629 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
630 pub struct ArrayType {
631 pub(crate) syntax: SyntaxNode,
634 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
635 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
636 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
637 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
638 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
643 /// type Foo = ❰ [u8] ❱;
646 /// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
647 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
648 pub struct SliceType {
649 pub(crate) syntax: SyntaxNode,
652 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
653 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
654 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
659 /// type Foo = ❰ &'static str ❱;
662 /// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
663 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
664 pub struct ReferenceType {
665 pub(crate) syntax: SyntaxNode,
668 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
669 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
670 support::token(&self.syntax, T![lifetime])
672 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
673 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
675 /// Placeholder type (i.e. the underscore).
678 /// let foo: ❰ _ ❱ = 42_u32;
681 /// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
682 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
683 pub struct PlaceholderType {
684 pub(crate) syntax: SyntaxNode,
686 impl PlaceholderType {
687 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
689 /// Function pointer type (not to be confused with `Fn*` family of traits).
692 /// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
694 /// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
697 /// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
698 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
699 pub struct FnPointerType {
700 pub(crate) syntax: SyntaxNode,
703 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
704 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
705 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
706 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
707 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
709 /// Higher order type.
712 /// type Foo = ❰ for<'a> fn(&'a str) ❱;
715 /// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
716 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
718 pub(crate) syntax: SyntaxNode,
721 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
722 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
723 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
725 /// Opaque `impl Trait` type.
728 /// fn foo(bar: ❰ impl Debug + Eq ❱) {}
731 /// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
732 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
733 pub struct ImplTraitType {
734 pub(crate) syntax: SyntaxNode,
736 impl ast::TypeBoundsOwner for ImplTraitType {}
738 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
740 /// Trait object type.
743 /// type Foo = ❰ dyn Debug ❱;
746 /// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
747 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
748 pub struct DynTraitType {
749 pub(crate) syntax: SyntaxNode,
751 impl ast::TypeBoundsOwner for DynTraitType {}
753 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
761 /// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
762 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
763 pub struct TupleExpr {
764 pub(crate) syntax: SyntaxNode,
766 impl ast::AttrsOwner for TupleExpr {}
768 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
769 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
770 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
775 /// ❰ [#![inner_attr] true, false, true] ❱;
780 /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
781 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
782 pub struct ArrayExpr {
783 pub(crate) syntax: SyntaxNode,
785 impl ast::AttrsOwner for ArrayExpr {}
787 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
788 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
789 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
790 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
792 /// Parenthesized expression.
793 /// Note: parens are only used for grouping, this is not a tuple literal.
796 /// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
799 /// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
800 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
801 pub struct ParenExpr {
802 pub(crate) syntax: SyntaxNode,
804 impl ast::AttrsOwner for ParenExpr {}
806 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
807 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
808 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
810 /// Path to a symbol in expression context.
811 /// Includes single identifier variable names and elaborate paths with
812 /// generic parameters.
817 /// ❰ Vec::<i32>::push ❱;
818 /// ❰ <[i32]>::reverse ❱;
819 /// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
822 /// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
823 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
824 pub struct PathExpr {
825 pub(crate) syntax: SyntaxNode,
828 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
830 /// Anonymous callable object literal a.k.a. closure, lambda or functor.
834 /// ❰ |a: u32| val + 1 ❱;
835 /// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
837 /// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
840 /// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
841 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
842 pub struct LambdaExpr {
843 pub(crate) syntax: SyntaxNode,
845 impl ast::AttrsOwner for LambdaExpr {}
847 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
848 pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) }
849 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
850 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
851 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
853 /// If expression. Includes both regular `if` and `if let` forms.
854 /// Beware that `else if` is a special case syntax sugar, because in general
855 /// there has to be block expression after `else`.
858 /// ❰ if bool_cond { 42 } ❱
859 /// ❰ if bool_cond { 42 } else { 24 } ❱
860 /// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
863 /// if let Pattern(foo) = bar {
871 /// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
872 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
874 pub(crate) syntax: SyntaxNode,
876 impl ast::AttrsOwner for IfExpr {}
878 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
879 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
881 /// Unconditional loop expression.
886 /// // yeah, it's that simple...
891 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
892 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
893 pub struct LoopExpr {
894 pub(crate) syntax: SyntaxNode,
896 impl ast::AttrsOwner for LoopExpr {}
897 impl ast::LoopBodyOwner for LoopExpr {}
899 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
901 /// Block expression with an optional prefix (label, try ketword,
902 /// unsafe keyword, async keyword...).
912 /// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
913 /// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
914 /// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
915 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
916 pub struct EffectExpr {
917 pub(crate) syntax: SyntaxNode,
919 impl ast::AttrsOwner for EffectExpr {}
921 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
922 pub fn try_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![try]) }
923 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
924 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
925 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
927 /// For loop expression.
928 /// Note: record struct literals are not valid as iterable expression
929 /// due to ambiguity.
933 /// for i in (0..4) {
939 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops)
940 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
942 pub(crate) syntax: SyntaxNode,
944 impl ast::AttrsOwner for ForExpr {}
945 impl ast::LoopBodyOwner for ForExpr {}
947 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
948 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
949 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
950 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
952 /// While loop expression. Includes both regular `while` and `while let` forms.
956 /// while bool_cond {
961 /// while let Pattern(foo) = bar {
967 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
968 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
969 pub struct WhileExpr {
970 pub(crate) syntax: SyntaxNode,
972 impl ast::AttrsOwner for WhileExpr {}
973 impl ast::LoopBodyOwner for WhileExpr {}
975 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
976 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
978 /// Continue expression.
981 /// while bool_cond {
987 /// ❰ continue 'outer ❱;
993 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
994 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
995 pub struct ContinueExpr {
996 pub(crate) syntax: SyntaxNode,
998 impl ast::AttrsOwner for ContinueExpr {}
1000 pub fn continue_token(&self) -> Option<SyntaxToken> {
1001 support::token(&self.syntax, T![continue])
1003 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1004 support::token(&self.syntax, T![lifetime])
1007 /// Break expression.
1010 /// while bool_cond {
1014 /// for foo in bar {
1015 /// ❰ break 'outer ❱;
1020 /// ❰ break 'outer 42 ❱;
1025 /// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1026 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1027 pub struct BreakExpr {
1028 pub(crate) syntax: SyntaxNode,
1030 impl ast::AttrsOwner for BreakExpr {}
1032 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
1033 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1034 support::token(&self.syntax, T![lifetime])
1036 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1041 /// ❰ 'outer: ❱ loop {}
1043 /// let foo = ❰ 'bar: ❱ loop {}
1050 /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1051 /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1052 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054 pub(crate) syntax: SyntaxNode,
1057 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1058 support::token(&self.syntax, T![lifetime])
1061 /// Block expression. Includes unsafe blocks and block labels.
1069 /// ❰ 'label: { break 'label } ❱
1074 /// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1075 /// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1076 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1077 pub struct BlockExpr {
1078 pub(crate) syntax: SyntaxNode,
1080 impl ast::AttrsOwner for BlockExpr {}
1081 impl ast::ModuleItemOwner for BlockExpr {}
1083 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1084 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1085 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1086 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1088 /// Return expression.
1091 /// || ❰ return 42 ❱;
1098 /// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html)
1099 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1100 pub struct ReturnExpr {
1101 pub(crate) syntax: SyntaxNode,
1103 impl ast::AttrsOwner for ReturnExpr {}
1105 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1107 /// Call expression (not to be confused with method call expression, it is
1108 /// a separate ast node).
1112 /// ❰ &str::len("bar") ❱;
1113 /// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱;
1116 /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1117 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1118 pub struct CallExpr {
1119 pub(crate) syntax: SyntaxNode,
1121 impl ast::ArgListOwner for CallExpr {}
1123 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1125 /// Method call expression.
1128 /// ❰ receiver_expr.method() ❱;
1129 /// ❰ receiver_expr.method::<T>(42, true) ❱;
1131 /// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱;
1134 /// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1135 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1136 pub struct MethodCallExpr {
1137 pub(crate) syntax: SyntaxNode,
1139 impl ast::AttrsOwner for MethodCallExpr {}
1140 impl ast::ArgListOwner for MethodCallExpr {}
1141 impl MethodCallExpr {
1142 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1143 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1144 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1145 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1147 /// Index expression a.k.a. subscript operator call.
1153 /// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
1154 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1155 pub struct IndexExpr {
1156 pub(crate) syntax: SyntaxNode,
1158 impl ast::AttrsOwner for IndexExpr {}
1160 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1161 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1163 /// Field access expression.
1168 /// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱;
1171 /// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html)
1172 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1173 pub struct FieldExpr {
1174 pub(crate) syntax: SyntaxNode,
1176 impl ast::AttrsOwner for FieldExpr {}
1178 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1179 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1180 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1182 /// Await operator call expression.
1188 /// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html)
1189 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1190 pub struct AwaitExpr {
1191 pub(crate) syntax: SyntaxNode,
1193 impl ast::AttrsOwner for AwaitExpr {}
1195 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1196 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1197 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1199 /// The question mark operator call.
1205 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator)
1206 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1207 pub struct TryExpr {
1208 pub(crate) syntax: SyntaxNode,
1210 impl ast::AttrsOwner for TryExpr {}
1212 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1213 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1215 /// Type cast expression.
1221 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions)
1222 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1223 pub struct CastExpr {
1224 pub(crate) syntax: SyntaxNode,
1226 impl ast::AttrsOwner for CastExpr {}
1228 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1229 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1230 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1232 /// Borrow operator call.
1239 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1240 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1241 pub struct RefExpr {
1242 pub(crate) syntax: SyntaxNode,
1244 impl ast::AttrsOwner for RefExpr {}
1246 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1247 pub fn raw_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![raw]) }
1248 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1249 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1251 /// Prefix operator call. This is either `!` or `*` or `-`.
1259 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1260 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1261 pub struct PrefixExpr {
1262 pub(crate) syntax: SyntaxNode,
1264 impl ast::AttrsOwner for PrefixExpr {}
1266 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1268 /// Box operator call.
1274 /// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1275 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1276 pub struct BoxExpr {
1277 pub(crate) syntax: SyntaxNode,
1279 impl ast::AttrsOwner for BoxExpr {}
1281 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1282 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1284 /// Range operator call.
1295 /// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1296 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1297 pub struct RangeExpr {
1298 pub(crate) syntax: SyntaxNode,
1300 impl ast::AttrsOwner for RangeExpr {}
1302 /// Binary operator call.
1303 /// Includes all arithmetic, logic, bitwise and assignment operators.
1306 /// ❰ 2 + ❰ 2 * 2 ❱ ❱;
1307 /// ❰ ❰ true && false ❱ || true ❱;
1310 /// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1311 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1312 pub struct BinExpr {
1313 pub(crate) syntax: SyntaxNode,
1315 impl ast::AttrsOwner for BinExpr {}
1317 /// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1321 /// ❰ br##"raw byte str"## ❱;
1329 /// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1330 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1331 pub struct Literal {
1332 pub(crate) syntax: SyntaxNode,
1335 /// Match expression.
1346 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1347 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1348 pub struct MatchExpr {
1349 pub(crate) syntax: SyntaxNode,
1351 impl ast::AttrsOwner for MatchExpr {}
1353 pub fn match_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![match]) }
1354 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1355 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1357 /// Match arm list part of match expression. Includes its inner attributes.
1370 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1371 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1372 pub struct MatchArmList {
1373 pub(crate) syntax: SyntaxNode,
1375 impl ast::AttrsOwner for MatchArmList {}
1377 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1378 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1379 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1382 /// Note: record struct literals are not valid as target match expression
1383 /// due to ambiguity.
1386 /// ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1390 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1391 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1392 pub struct MatchArm {
1393 pub(crate) syntax: SyntaxNode,
1395 impl ast::AttrsOwner for MatchArm {}
1397 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1398 pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) }
1399 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1400 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1406 /// Pattern(it) ❰ if bool_cond ❱ => it,
1410 /// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1411 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1412 pub struct MatchGuard {
1413 pub(crate) syntax: SyntaxNode,
1416 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1417 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1419 /// Record literal expression. The same syntax is used for structs,
1420 /// unions and record enum variants.
1433 /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1434 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1435 pub struct RecordLit {
1436 pub(crate) syntax: SyntaxNode,
1439 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1440 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
1442 /// Record field list including enclosing curly braces.
1451 /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1452 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1453 pub struct RecordFieldList {
1454 pub(crate) syntax: SyntaxNode,
1456 impl RecordFieldList {
1457 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1458 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
1459 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1460 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1461 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1467 /// ❰ #[attr] baz: 42 ❱
1471 /// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1472 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1473 pub struct RecordField {
1474 pub(crate) syntax: SyntaxNode,
1476 impl ast::AttrsOwner for RecordField {}
1478 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1479 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1480 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1482 /// Disjunction of patterns.
1485 /// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1488 /// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1489 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1491 pub(crate) syntax: SyntaxNode,
1494 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1496 /// Parenthesized pattern.
1497 /// Note: parens are only used for grouping, this is not a tuple pattern.
1500 /// if let ❰ &(0..=42) ❱ = foo {}
1503 /// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1504 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1505 pub struct ParenPat {
1506 pub(crate) syntax: SyntaxNode,
1509 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1510 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1511 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1513 /// Reference pattern.
1514 /// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1517 /// let ❰ &mut foo ❱ = bar;
1519 /// // TODO: clarify on the special case of double reference pattern
1520 /// // described in the link bellow
1522 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1523 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1525 pub(crate) syntax: SyntaxNode,
1528 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1529 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1530 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1535 /// let ❰ box foo ❱ = box 42;
1538 /// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1539 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1541 pub(crate) syntax: SyntaxNode,
1544 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1545 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1551 /// Some(❰ ref mut bar ❱) => {}
1552 /// ❰ baz @ None ❱ => {}
1556 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1557 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1558 pub struct BindPat {
1559 pub(crate) syntax: SyntaxNode,
1561 impl ast::AttrsOwner for BindPat {}
1562 impl ast::NameOwner for BindPat {}
1564 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1565 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1566 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1567 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1569 /// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1572 /// let ❰ _ ❱ = foo;
1575 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1576 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1577 pub struct PlaceholderPat {
1578 pub(crate) syntax: SyntaxNode,
1580 impl PlaceholderPat {
1581 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1583 /// Rest-of-the record/tuple pattern.
1584 /// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1587 /// let Foo { bar, ❰ .. ❱ } = baz;
1588 /// let (❰ .. ❱, bruh) = (42, 24, 42);
1589 /// let Bruuh(❰ .. ❱) = bruuuh;
1592 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1593 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1594 pub struct DotDotPat {
1595 pub(crate) syntax: SyntaxNode,
1598 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1601 /// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1604 /// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1605 /// if let ❰ CONST ❱ = 42 {}
1608 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1609 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1610 pub struct PathPat {
1611 pub(crate) syntax: SyntaxNode,
1614 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1619 /// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1622 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1623 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1624 pub struct SlicePat {
1625 pub(crate) syntax: SyntaxNode,
1628 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1629 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1630 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1637 /// ❰ 0..=42 ❱ => {}
1641 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1642 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1643 pub struct RangePat {
1644 pub(crate) syntax: SyntaxNode,
1647 /// Literal pattern.
1648 /// Includes only bool, number, char, and string literals.
1652 /// Number(❰ 42 ❱) => {}
1653 /// String(❰ "42" ❱) => {}
1654 /// Bool(❰ true ❱) => {}
1658 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1659 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1660 pub struct LiteralPat {
1661 pub(crate) syntax: SyntaxNode,
1664 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1666 /// Macro invocation in pattern position.
1669 /// let ❰ foo!(my custom syntax) ❱ = baz;
1672 /// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1673 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1674 pub struct MacroPat {
1675 pub(crate) syntax: SyntaxNode,
1678 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1680 /// Record literal pattern.
1683 /// let ❰ foo::Bar { baz, .. } ❱ = bruh;
1686 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1687 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1688 pub struct RecordPat {
1689 pub(crate) syntax: SyntaxNode,
1692 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
1693 support::child(&self.syntax)
1695 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1697 /// Record literal's field patterns list including enclosing curly braces.
1700 /// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1703 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1704 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1705 pub struct RecordFieldPatList {
1706 pub(crate) syntax: SyntaxNode,
1708 impl RecordFieldPatList {
1709 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1710 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
1711 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1712 support::children(&self.syntax)
1714 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1715 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1716 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1718 /// Record literal's field pattern.
1719 /// Note: record literal can also match tuple structs.
1722 /// let Foo { ❰ bar: _ ❱ } = baz;
1723 /// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1726 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1727 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1728 pub struct RecordFieldPat {
1729 pub(crate) syntax: SyntaxNode,
1731 impl ast::AttrsOwner for RecordFieldPat {}
1732 impl RecordFieldPat {
1733 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1734 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1735 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1737 /// Tuple struct literal pattern.
1740 /// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1743 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1744 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1745 pub struct TupleStructPat {
1746 pub(crate) syntax: SyntaxNode,
1748 impl TupleStructPat {
1749 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1750 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1751 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1752 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1755 /// Note: this doesn't include tuple structs (see `TupleStructPat`)
1758 /// let ❰ (foo, bar, .., baz) ❱ = bruh;
1761 /// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1762 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1763 pub struct TuplePat {
1764 pub(crate) syntax: SyntaxNode,
1767 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1768 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1769 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1774 /// ❰ pub mod ❱ foo;
1775 /// ❰ pub(crate) ❱ struct Bar;
1776 /// ❰ pub(self) ❱ enum Baz {}
1777 /// ❰ pub(super) ❱ fn bruh() {}
1778 /// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1781 /// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1782 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1783 pub struct Visibility {
1784 pub(crate) syntax: SyntaxNode,
1787 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
1788 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
1789 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1790 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1792 /// Single identifier.
1793 /// // TODO: clarify the difference between Name and NameRef
1796 /// let ❰ foo ❱ = bar;
1798 /// fn ❰ bruh ❱() {}
1801 /// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1802 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1804 pub(crate) syntax: SyntaxNode,
1807 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
1809 /// Reference to a name.
1812 /// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1815 /// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1816 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1817 pub struct NameRef {
1818 pub(crate) syntax: SyntaxNode,
1822 /// Includes all of its attributes and doc comments.
1828 /// macro_rules! foo { // macro rules is also a macro call
1829 /// ($bar: tt) => {}
1836 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
1837 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1838 pub struct MacroCall {
1839 pub(crate) syntax: SyntaxNode,
1841 impl ast::NameOwner for MacroCall {}
1842 impl ast::AttrsOwner for MacroCall {}
1843 impl ast::DocCommentsOwner for MacroCall {}
1845 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1846 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1847 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1848 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1853 /// ❰ #![inner_attr] ❱
1856 /// ❰ #[foo = "bar"] ❱
1857 /// ❰ #[baz(bruh::bruuh = "42")] ❱
1861 /// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1862 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1864 pub(crate) syntax: SyntaxNode,
1867 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1868 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1869 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1870 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1871 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1872 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1873 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1875 /// Stores a list of lexer tokens and other `TokenTree`s.
1876 /// It appears in attributes, macro_rules and macro call (foo!)
1879 /// macro_call! ❰ { my syntax here } ❱;
1882 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
1883 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1884 pub struct TokenTree {
1885 pub(crate) syntax: SyntaxNode,
1888 /// Generic lifetime, type and constants parameters list **declaration**.
1891 /// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1893 /// struct Baz❰ <T> ❱(T);
1895 /// impl❰ <T> ❱ Bruh<T> {}
1897 /// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1900 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1901 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1902 pub struct TypeParamList {
1903 pub(crate) syntax: SyntaxNode,
1905 impl TypeParamList {
1906 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1907 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1908 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1909 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1910 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1911 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1913 /// Single type parameter **declaration**.
1916 /// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1919 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1920 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1921 pub struct TypeParam {
1922 pub(crate) syntax: SyntaxNode,
1924 impl ast::NameOwner for TypeParam {}
1925 impl ast::AttrsOwner for TypeParam {}
1926 impl ast::TypeBoundsOwner for TypeParam {}
1928 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1929 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1931 /// Const generic parameter **declaration**.
1933 /// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1936 /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1937 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1938 pub struct ConstParam {
1939 pub(crate) syntax: SyntaxNode,
1941 impl ast::NameOwner for ConstParam {}
1942 impl ast::AttrsOwner for ConstParam {}
1943 impl ast::TypeAscriptionOwner for ConstParam {}
1945 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1946 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1948 /// Lifetime parameter **declaration**.
1951 /// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1954 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1955 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1956 pub struct LifetimeParam {
1957 pub(crate) syntax: SyntaxNode,
1959 impl ast::AttrsOwner for LifetimeParam {}
1960 impl LifetimeParam {
1961 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1962 support::token(&self.syntax, T![lifetime])
1965 /// Type bound declaration clause.
1968 /// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {}
1972 /// T: ❰ Send ❱ + ❰ Sync ❱
1974 /// type Baz: ❰ !Sync ❱ + ❰ Debug ❱;
1978 /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
1979 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1980 pub struct TypeBound {
1981 pub(crate) syntax: SyntaxNode,
1984 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1985 support::token(&self.syntax, T![lifetime])
1987 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1988 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1990 /// Type bounds list.
1994 /// fn foo<T: ❰ ?Sized + Debug ❱>() {}
1998 /// T: ❰ Send + Sync ❱
2000 /// type Baz: ❰ !Sync + Debug ❱;
2004 /// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2005 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2006 pub struct TypeBoundList {
2007 pub(crate) syntax: SyntaxNode,
2009 impl TypeBoundList {
2010 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2012 /// Single where predicate.
2015 /// trait Foo<'a, 'b, T>
2018 /// ❰ T: IntoIterator ❱,
2019 /// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
2023 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2024 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2025 pub struct WherePred {
2026 pub(crate) syntax: SyntaxNode,
2028 impl ast::TypeBoundsOwner for WherePred {}
2030 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2031 support::token(&self.syntax, T![lifetime])
2033 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2038 /// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
2042 /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2043 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2044 pub struct WhereClause {
2045 pub(crate) syntax: SyntaxNode,
2048 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
2049 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2051 /// Abi declaration.
2052 /// Note: the abi string is optional.
2055 /// ❰ extern "C" ❱ {
2059 /// type Bar = ❰ extern ❱ fn() -> u32;
2061 /// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
2064 /// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2065 /// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
2066 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2068 pub(crate) syntax: SyntaxNode,
2071 /// Expression statement.
2072 /// Note: may be empty (i.e. only semicolon).
2079 /// ❰ /* empty */; ❱
2081 /// // constructions with trailing curly brace can omit the semicolon // TODO: clarify
2082 /// ❰ if bool_cond { } ❱
2086 /// [Reference](https://doc.rust-lang.org/reference/statements.html)
2087 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2088 pub struct ExprStmt {
2089 pub(crate) syntax: SyntaxNode,
2091 impl ast::AttrsOwner for ExprStmt {}
2093 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2094 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2099 /// ❰ #[attr] let foo; ❱
2100 /// ❰ let bar: u64; ❱
2101 /// ❰ let baz = 42; ❱
2102 /// ❰ let bruh: bool = true; ❱
2105 /// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
2106 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2107 pub struct LetStmt {
2108 pub(crate) syntax: SyntaxNode,
2110 impl ast::AttrsOwner for LetStmt {}
2111 impl ast::TypeAscriptionOwner for LetStmt {}
2113 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2114 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2115 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2116 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2117 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2119 /// Condition of `if` or `while` expression.
2123 /// if ❰ let Pat(foo) = bar ❱ {}
2125 /// while ❰ true ❱ {}
2126 /// while ❰ let Pat(baz) = bruh ❱ {}
2129 /// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
2130 /// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
2131 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2132 pub struct Condition {
2133 pub(crate) syntax: SyntaxNode,
2136 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2137 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2138 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2139 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2141 /// Parameter list **declaration**.
2144 /// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
2145 /// let bar = ❰ |a, b| ❱ {};
2148 /// fn bruh❰ (&self, a: u32) ❱ {}
2152 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
2153 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2154 pub struct ParamList {
2155 pub(crate) syntax: SyntaxNode,
2158 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2159 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2160 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2161 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2163 /// Self parameter **declaration**.
2167 /// fn foo(❰ self ❱) {}
2168 /// fn bar(❰ &self ❱) {}
2169 /// fn baz(❰ &mut self ❱) {}
2170 /// fn blah<'a>(❰ &'a self ❱) {}
2171 /// fn blin(❰ self: Box<Self> ❱) {}
2175 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2176 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2177 pub struct SelfParam {
2178 pub(crate) syntax: SyntaxNode,
2180 impl ast::TypeAscriptionOwner for SelfParam {}
2181 impl ast::AttrsOwner for SelfParam {}
2183 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2184 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2185 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2186 support::token(&self.syntax, T![lifetime])
2188 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2190 /// Parameter **declaration**.
2193 /// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
2196 /// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
2200 /// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2201 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2203 pub(crate) syntax: SyntaxNode,
2205 impl ast::TypeAscriptionOwner for Param {}
2206 impl ast::AttrsOwner for Param {}
2208 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2209 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2211 /// Use declaration.
2214 /// ❰ #[attr] pub use foo; ❱
2215 /// ❰ use bar as baz; ❱
2216 /// ❰ use bruh::{self, bruuh}; ❱
2217 /// ❰ use { blin::blen, blah::* };
2220 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2221 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2222 pub struct UseItem {
2223 pub(crate) syntax: SyntaxNode,
2225 impl ast::AttrsOwner for UseItem {}
2226 impl ast::VisibilityOwner for UseItem {}
2228 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2229 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2234 /// pub use ❰ foo::❰ * ❱ ❱;
2235 /// use ❰ bar as baz ❱;
2236 /// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
2237 /// use ❰ { ❰ blin::blen ❱ } ❱ // TODO: clarify if top-level curlies are `UseTree`
2240 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2241 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2242 pub struct UseTree {
2243 pub(crate) syntax: SyntaxNode,
2246 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2247 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2248 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2249 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2252 /// Note: this is not the type alias.
2255 /// use foo ❰ as bar ❱;
2256 /// use baz::{bruh ❰ as _ ❱};
2257 /// extern crate bruuh ❰ as blin ❱;
2260 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2261 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2263 pub(crate) syntax: SyntaxNode,
2265 impl ast::NameOwner for Alias {}
2267 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2269 /// Sublist of use trees.
2272 /// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
2273 /// use ❰ { blin::blen::❰ {} ❱ } ❱
2276 /// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2277 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2278 pub struct UseTreeList {
2279 pub(crate) syntax: SyntaxNode,
2282 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2283 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2284 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2286 /// Extern crate item.
2289 /// ❰ #[attr] pub extern crate foo; ❱
2290 /// ❰ extern crate self as bar; ❱
2293 /// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html)
2294 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2295 pub struct ExternCrateItem {
2296 pub(crate) syntax: SyntaxNode,
2298 impl ast::AttrsOwner for ExternCrateItem {}
2299 impl ast::VisibilityOwner for ExternCrateItem {}
2300 impl ExternCrateItem {
2301 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2302 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2303 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2304 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2306 /// Call site arguments list.
2309 /// foo::<T, U>❰ (42, true) ❱;
2312 /// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
2313 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2314 pub struct ArgList {
2315 pub(crate) syntax: SyntaxNode,
2318 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2319 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2320 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2322 /// Path to a symbol. Includes single identifier names and elaborate paths with
2323 /// generic parameters.
2326 /// (0..10).❰ collect ❰ ::<Vec<_>> ❱ ❱();
2327 /// ❰ Vec ❰ ::<u8> ❰ ::with_capacity ❱ ❱ ❱(1024);
2328 /// ❰ <Foo as Bar> ❰ ::baz ❱ ❱();
2329 /// ❰ <bruh> ❰ ::bruuh ❱ ❱();
2332 /// [Reference](https://doc.rust-lang.org/reference/paths.html)
2333 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2335 pub(crate) syntax: SyntaxNode,
2338 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2339 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2341 /// Segment of the path to a symbol.
2344 /// (0..10).❰ collect ❱ ❰ ::<Vec<_>> ❱();
2345 /// ❰ Vec >| ❰ ::<u8> ❱ ❰ ::with_capacity ❱(1024);
2346 /// ❰ <Foo as Bar> ❱ ❰ ::baz ❱();
2347 /// ❰ <bruh> ❱ ❰ ::bruuh ❱();
2350 /// [Reference](https://doc.rust-lang.org/reference/paths.html)
2351 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2352 pub struct PathSegment {
2353 pub(crate) syntax: SyntaxNode,
2356 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2357 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2358 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2359 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
2360 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2361 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2362 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
2363 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
2364 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
2365 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2366 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2368 /// List of type arguments that are passed at generic instantiation site.
2371 /// use foo ❰ ::<'a, u64, Item = Bar, 42, true> ❱::bar;
2373 /// Vec❰ ::<bool> ❱::();
2376 /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2377 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2378 pub struct TypeArgList {
2379 pub(crate) syntax: SyntaxNode,
2382 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2383 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2384 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2385 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2386 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2387 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2388 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2389 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2391 /// Type argument that is passed at generic instantiation site.
2394 /// use foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::baz;
2397 /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2398 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2399 pub struct TypeArg {
2400 pub(crate) syntax: SyntaxNode,
2403 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2405 /// Associated type argument that is passed at generic instantiation site.
2407 /// use foo::<'a, u64, bool, ❰ Item = Bar ❱, 42>::baz;
2409 /// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
2412 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2413 pub struct AssocTypeArg {
2414 pub(crate) syntax: SyntaxNode,
2416 impl ast::TypeBoundsOwner for AssocTypeArg {}
2418 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2419 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2420 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2422 /// Lifetime argument that is passed at generic instantiation site.
2425 /// fn foo<'a>(s: &'a str) {
2426 /// bar::<❰ 'a ❱>(s);
2430 /// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2431 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2432 pub struct LifetimeArg {
2433 pub(crate) syntax: SyntaxNode,
2436 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2437 support::token(&self.syntax, T![lifetime])
2440 /// Constant value argument that is passed at generic instantiation site.
2443 /// foo::<❰ u32 ❱, ❰ true ❱ >();
2445 /// bar::<❰ { 2 + 2} ❱>();
2448 /// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
2449 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2450 pub struct ConstArg {
2451 pub(crate) syntax: SyntaxNode,
2454 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2455 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2456 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2458 /// Macro items is a node that holds all the items created by expanding a macro.
2461 /// foo!(); // expands into some items -v
2462 /// // ❰ struct Foo; impl Bar for Foo; ❱
2465 /// [Reference](https://doc.rust-lang.org/reference/macros.html)
2466 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2467 pub struct MacroItems {
2468 pub(crate) syntax: SyntaxNode,
2470 impl ast::ModuleItemOwner for MacroItems {}
2472 /// List of items in an extern block.
2478 /// static var: u32;
2483 /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2484 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2485 pub struct ExternItemList {
2486 pub(crate) syntax: SyntaxNode,
2488 impl ast::ModuleItemOwner for ExternItemList {}
2489 impl ExternItemList {
2490 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2491 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2492 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2505 /// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2506 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2507 pub struct ExternBlock {
2508 pub(crate) syntax: SyntaxNode,
2511 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2512 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2514 /// Meta item in an attribute.
2517 /// #[❰ bar::baz = "42" ❱]
2518 /// #[❰ bruh(bruuh("true")) ❱]
2522 /// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2523 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2524 pub struct MetaItem {
2525 pub(crate) syntax: SyntaxNode,
2528 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2529 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2530 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2531 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2533 /// Macro definition.
2537 /// macro_rules! foo {
2538 /// ($bar:tt) => {$bar}
2543 /// [Reference](https://doc.rust-lang.org/reference/macros-by-example.html)
2544 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2545 pub struct MacroDef {
2546 pub(crate) syntax: SyntaxNode,
2549 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2550 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2552 /// Any kind of nominal type definition.
2553 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2554 pub enum NominalDef {
2555 StructDef(StructDef),
2559 impl ast::NameOwner for NominalDef {}
2560 impl ast::TypeParamsOwner for NominalDef {}
2561 impl ast::AttrsOwner for NominalDef {}
2562 /// Any kind of **declared** generic parameter
2563 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2564 pub enum GenericParam {
2565 LifetimeParam(LifetimeParam),
2566 TypeParam(TypeParam),
2567 ConstParam(ConstParam),
2569 /// Any kind of generic argument passed at instantiation site
2570 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2571 pub enum GenericArg {
2572 LifetimeArg(LifetimeArg),
2575 AssocTypeArg(AssocTypeArg),
2577 /// Any kind of construct valid in type context
2578 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2580 ParenType(ParenType),
2581 TupleType(TupleType),
2582 NeverType(NeverType),
2584 PointerType(PointerType),
2585 ArrayType(ArrayType),
2586 SliceType(SliceType),
2587 ReferenceType(ReferenceType),
2588 PlaceholderType(PlaceholderType),
2589 FnPointerType(FnPointerType),
2591 ImplTraitType(ImplTraitType),
2592 DynTraitType(DynTraitType),
2594 /// Any kind of top-level item that may appear in a module
2595 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2596 pub enum ModuleItem {
2597 StructDef(StructDef),
2602 TypeAliasDef(TypeAliasDef),
2605 ExternCrateItem(ExternCrateItem),
2607 StaticDef(StaticDef),
2609 MacroCall(MacroCall),
2610 ExternBlock(ExternBlock),
2612 impl ast::NameOwner for ModuleItem {}
2613 impl ast::AttrsOwner for ModuleItem {}
2614 impl ast::VisibilityOwner for ModuleItem {}
2615 /// Any kind of item that may appear in an impl block
2617 /// // TODO: is the following a fixme?
2618 /// impl blocks can also contain MacroCall
2619 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2620 pub enum AssocItem {
2622 TypeAliasDef(TypeAliasDef),
2625 impl ast::NameOwner for AssocItem {}
2626 impl ast::AttrsOwner for AssocItem {}
2627 /// Any kind of item that may appear in an extern block
2629 /// // TODO: is the following a fixme?
2630 /// extern blocks can also contain MacroCall
2631 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2632 pub enum ExternItem {
2634 StaticDef(StaticDef),
2636 impl ast::NameOwner for ExternItem {}
2637 impl ast::AttrsOwner for ExternItem {}
2638 impl ast::VisibilityOwner for ExternItem {}
2639 /// Any kind of expression
2640 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2642 TupleExpr(TupleExpr),
2643 ArrayExpr(ArrayExpr),
2644 ParenExpr(ParenExpr),
2646 LambdaExpr(LambdaExpr),
2650 WhileExpr(WhileExpr),
2651 ContinueExpr(ContinueExpr),
2652 BreakExpr(BreakExpr),
2654 BlockExpr(BlockExpr),
2655 ReturnExpr(ReturnExpr),
2656 MatchExpr(MatchExpr),
2657 RecordLit(RecordLit),
2659 IndexExpr(IndexExpr),
2660 MethodCallExpr(MethodCallExpr),
2661 FieldExpr(FieldExpr),
2662 AwaitExpr(AwaitExpr),
2664 EffectExpr(EffectExpr),
2667 PrefixExpr(PrefixExpr),
2668 RangeExpr(RangeExpr),
2671 MacroCall(MacroCall),
2674 impl ast::AttrsOwner for Expr {}
2675 /// Any kind of pattern
2676 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2683 PlaceholderPat(PlaceholderPat),
2684 DotDotPat(DotDotPat),
2686 RecordPat(RecordPat),
2687 TupleStructPat(TupleStructPat),
2691 LiteralPat(LiteralPat),
2694 /// Any kind of pattern that appears directly inside of the curly
2695 /// braces of a record pattern
2696 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2697 pub enum RecordInnerPat {
2698 RecordFieldPat(RecordFieldPat),
2701 /// Any kind of input to an attribute
2702 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2703 pub enum AttrInput {
2705 TokenTree(TokenTree),
2707 /// Any kind of statement
2708 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2713 /// Any kind of fields list (record or tuple field lists)
2714 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2715 pub enum FieldDefList {
2716 RecordFieldDefList(RecordFieldDefList),
2717 TupleFieldDefList(TupleFieldDefList),
2719 impl AstNode for SourceFile {
2720 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
2721 fn cast(syntax: SyntaxNode) -> Option<Self> {
2722 if Self::can_cast(syntax.kind()) {
2723 Some(Self { syntax })
2728 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2730 impl AstNode for FnDef {
2731 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF }
2732 fn cast(syntax: SyntaxNode) -> Option<Self> {
2733 if Self::can_cast(syntax.kind()) {
2734 Some(Self { syntax })
2739 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2741 impl AstNode for RetType {
2742 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
2743 fn cast(syntax: SyntaxNode) -> Option<Self> {
2744 if Self::can_cast(syntax.kind()) {
2745 Some(Self { syntax })
2750 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2752 impl AstNode for StructDef {
2753 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF }
2754 fn cast(syntax: SyntaxNode) -> Option<Self> {
2755 if Self::can_cast(syntax.kind()) {
2756 Some(Self { syntax })
2761 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2763 impl AstNode for UnionDef {
2764 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF }
2765 fn cast(syntax: SyntaxNode) -> Option<Self> {
2766 if Self::can_cast(syntax.kind()) {
2767 Some(Self { syntax })
2772 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2774 impl AstNode for RecordFieldDefList {
2775 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST }
2776 fn cast(syntax: SyntaxNode) -> Option<Self> {
2777 if Self::can_cast(syntax.kind()) {
2778 Some(Self { syntax })
2783 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2785 impl AstNode for RecordFieldDef {
2786 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF }
2787 fn cast(syntax: SyntaxNode) -> Option<Self> {
2788 if Self::can_cast(syntax.kind()) {
2789 Some(Self { syntax })
2794 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2796 impl AstNode for TupleFieldDefList {
2797 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST }
2798 fn cast(syntax: SyntaxNode) -> Option<Self> {
2799 if Self::can_cast(syntax.kind()) {
2800 Some(Self { syntax })
2805 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2807 impl AstNode for TupleFieldDef {
2808 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF }
2809 fn cast(syntax: SyntaxNode) -> Option<Self> {
2810 if Self::can_cast(syntax.kind()) {
2811 Some(Self { syntax })
2816 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2818 impl AstNode for EnumDef {
2819 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF }
2820 fn cast(syntax: SyntaxNode) -> Option<Self> {
2821 if Self::can_cast(syntax.kind()) {
2822 Some(Self { syntax })
2827 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2829 impl AstNode for EnumVariantList {
2830 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST }
2831 fn cast(syntax: SyntaxNode) -> Option<Self> {
2832 if Self::can_cast(syntax.kind()) {
2833 Some(Self { syntax })
2838 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2840 impl AstNode for EnumVariant {
2841 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT }
2842 fn cast(syntax: SyntaxNode) -> Option<Self> {
2843 if Self::can_cast(syntax.kind()) {
2844 Some(Self { syntax })
2849 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2851 impl AstNode for TraitDef {
2852 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF }
2853 fn cast(syntax: SyntaxNode) -> Option<Self> {
2854 if Self::can_cast(syntax.kind()) {
2855 Some(Self { syntax })
2860 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2862 impl AstNode for Module {
2863 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
2864 fn cast(syntax: SyntaxNode) -> Option<Self> {
2865 if Self::can_cast(syntax.kind()) {
2866 Some(Self { syntax })
2871 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2873 impl AstNode for ItemList {
2874 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
2875 fn cast(syntax: SyntaxNode) -> Option<Self> {
2876 if Self::can_cast(syntax.kind()) {
2877 Some(Self { syntax })
2882 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2884 impl AstNode for ConstDef {
2885 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF }
2886 fn cast(syntax: SyntaxNode) -> Option<Self> {
2887 if Self::can_cast(syntax.kind()) {
2888 Some(Self { syntax })
2893 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2895 impl AstNode for StaticDef {
2896 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF }
2897 fn cast(syntax: SyntaxNode) -> Option<Self> {
2898 if Self::can_cast(syntax.kind()) {
2899 Some(Self { syntax })
2904 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2906 impl AstNode for TypeAliasDef {
2907 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF }
2908 fn cast(syntax: SyntaxNode) -> Option<Self> {
2909 if Self::can_cast(syntax.kind()) {
2910 Some(Self { syntax })
2915 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2917 impl AstNode for ImplDef {
2918 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF }
2919 fn cast(syntax: SyntaxNode) -> Option<Self> {
2920 if Self::can_cast(syntax.kind()) {
2921 Some(Self { syntax })
2926 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2928 impl AstNode for ParenType {
2929 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE }
2930 fn cast(syntax: SyntaxNode) -> Option<Self> {
2931 if Self::can_cast(syntax.kind()) {
2932 Some(Self { syntax })
2937 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2939 impl AstNode for TupleType {
2940 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE }
2941 fn cast(syntax: SyntaxNode) -> Option<Self> {
2942 if Self::can_cast(syntax.kind()) {
2943 Some(Self { syntax })
2948 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2950 impl AstNode for NeverType {
2951 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
2952 fn cast(syntax: SyntaxNode) -> Option<Self> {
2953 if Self::can_cast(syntax.kind()) {
2954 Some(Self { syntax })
2959 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2961 impl AstNode for PathType {
2962 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE }
2963 fn cast(syntax: SyntaxNode) -> Option<Self> {
2964 if Self::can_cast(syntax.kind()) {
2965 Some(Self { syntax })
2970 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2972 impl AstNode for PointerType {
2973 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
2974 fn cast(syntax: SyntaxNode) -> Option<Self> {
2975 if Self::can_cast(syntax.kind()) {
2976 Some(Self { syntax })
2981 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2983 impl AstNode for ArrayType {
2984 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE }
2985 fn cast(syntax: SyntaxNode) -> Option<Self> {
2986 if Self::can_cast(syntax.kind()) {
2987 Some(Self { syntax })
2992 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2994 impl AstNode for SliceType {
2995 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE }
2996 fn cast(syntax: SyntaxNode) -> Option<Self> {
2997 if Self::can_cast(syntax.kind()) {
2998 Some(Self { syntax })
3003 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3005 impl AstNode for ReferenceType {
3006 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE }
3007 fn cast(syntax: SyntaxNode) -> Option<Self> {
3008 if Self::can_cast(syntax.kind()) {
3009 Some(Self { syntax })
3014 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3016 impl AstNode for PlaceholderType {
3017 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE }
3018 fn cast(syntax: SyntaxNode) -> Option<Self> {
3019 if Self::can_cast(syntax.kind()) {
3020 Some(Self { syntax })
3025 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3027 impl AstNode for FnPointerType {
3028 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE }
3029 fn cast(syntax: SyntaxNode) -> Option<Self> {
3030 if Self::can_cast(syntax.kind()) {
3031 Some(Self { syntax })
3036 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3038 impl AstNode for ForType {
3039 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE }
3040 fn cast(syntax: SyntaxNode) -> Option<Self> {
3041 if Self::can_cast(syntax.kind()) {
3042 Some(Self { syntax })
3047 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3049 impl AstNode for ImplTraitType {
3050 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE }
3051 fn cast(syntax: SyntaxNode) -> Option<Self> {
3052 if Self::can_cast(syntax.kind()) {
3053 Some(Self { syntax })
3058 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3060 impl AstNode for DynTraitType {
3061 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE }
3062 fn cast(syntax: SyntaxNode) -> Option<Self> {
3063 if Self::can_cast(syntax.kind()) {
3064 Some(Self { syntax })
3069 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3071 impl AstNode for TupleExpr {
3072 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR }
3073 fn cast(syntax: SyntaxNode) -> Option<Self> {
3074 if Self::can_cast(syntax.kind()) {
3075 Some(Self { syntax })
3080 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3082 impl AstNode for ArrayExpr {
3083 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR }
3084 fn cast(syntax: SyntaxNode) -> Option<Self> {
3085 if Self::can_cast(syntax.kind()) {
3086 Some(Self { syntax })
3091 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3093 impl AstNode for ParenExpr {
3094 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
3095 fn cast(syntax: SyntaxNode) -> Option<Self> {
3096 if Self::can_cast(syntax.kind()) {
3097 Some(Self { syntax })
3102 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3104 impl AstNode for PathExpr {
3105 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR }
3106 fn cast(syntax: SyntaxNode) -> Option<Self> {
3107 if Self::can_cast(syntax.kind()) {
3108 Some(Self { syntax })
3113 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3115 impl AstNode for LambdaExpr {
3116 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR }
3117 fn cast(syntax: SyntaxNode) -> Option<Self> {
3118 if Self::can_cast(syntax.kind()) {
3119 Some(Self { syntax })
3124 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3126 impl AstNode for IfExpr {
3127 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
3128 fn cast(syntax: SyntaxNode) -> Option<Self> {
3129 if Self::can_cast(syntax.kind()) {
3130 Some(Self { syntax })
3135 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3137 impl AstNode for LoopExpr {
3138 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
3139 fn cast(syntax: SyntaxNode) -> Option<Self> {
3140 if Self::can_cast(syntax.kind()) {
3141 Some(Self { syntax })
3146 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3148 impl AstNode for EffectExpr {
3149 fn can_cast(kind: SyntaxKind) -> bool { kind == EFFECT_EXPR }
3150 fn cast(syntax: SyntaxNode) -> Option<Self> {
3151 if Self::can_cast(syntax.kind()) {
3152 Some(Self { syntax })
3157 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3159 impl AstNode for ForExpr {
3160 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR }
3161 fn cast(syntax: SyntaxNode) -> Option<Self> {
3162 if Self::can_cast(syntax.kind()) {
3163 Some(Self { syntax })
3168 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3170 impl AstNode for WhileExpr {
3171 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR }
3172 fn cast(syntax: SyntaxNode) -> Option<Self> {
3173 if Self::can_cast(syntax.kind()) {
3174 Some(Self { syntax })
3179 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3181 impl AstNode for ContinueExpr {
3182 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR }
3183 fn cast(syntax: SyntaxNode) -> Option<Self> {
3184 if Self::can_cast(syntax.kind()) {
3185 Some(Self { syntax })
3190 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3192 impl AstNode for BreakExpr {
3193 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
3194 fn cast(syntax: SyntaxNode) -> Option<Self> {
3195 if Self::can_cast(syntax.kind()) {
3196 Some(Self { syntax })
3201 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3203 impl AstNode for Label {
3204 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
3205 fn cast(syntax: SyntaxNode) -> Option<Self> {
3206 if Self::can_cast(syntax.kind()) {
3207 Some(Self { syntax })
3212 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3214 impl AstNode for BlockExpr {
3215 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
3216 fn cast(syntax: SyntaxNode) -> Option<Self> {
3217 if Self::can_cast(syntax.kind()) {
3218 Some(Self { syntax })
3223 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3225 impl AstNode for ReturnExpr {
3226 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR }
3227 fn cast(syntax: SyntaxNode) -> Option<Self> {
3228 if Self::can_cast(syntax.kind()) {
3229 Some(Self { syntax })
3234 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3236 impl AstNode for CallExpr {
3237 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR }
3238 fn cast(syntax: SyntaxNode) -> Option<Self> {
3239 if Self::can_cast(syntax.kind()) {
3240 Some(Self { syntax })
3245 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3247 impl AstNode for MethodCallExpr {
3248 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR }
3249 fn cast(syntax: SyntaxNode) -> Option<Self> {
3250 if Self::can_cast(syntax.kind()) {
3251 Some(Self { syntax })
3256 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3258 impl AstNode for IndexExpr {
3259 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR }
3260 fn cast(syntax: SyntaxNode) -> Option<Self> {
3261 if Self::can_cast(syntax.kind()) {
3262 Some(Self { syntax })
3267 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3269 impl AstNode for FieldExpr {
3270 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR }
3271 fn cast(syntax: SyntaxNode) -> Option<Self> {
3272 if Self::can_cast(syntax.kind()) {
3273 Some(Self { syntax })
3278 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3280 impl AstNode for AwaitExpr {
3281 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
3282 fn cast(syntax: SyntaxNode) -> Option<Self> {
3283 if Self::can_cast(syntax.kind()) {
3284 Some(Self { syntax })
3289 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3291 impl AstNode for TryExpr {
3292 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR }
3293 fn cast(syntax: SyntaxNode) -> Option<Self> {
3294 if Self::can_cast(syntax.kind()) {
3295 Some(Self { syntax })
3300 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3302 impl AstNode for CastExpr {
3303 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR }
3304 fn cast(syntax: SyntaxNode) -> Option<Self> {
3305 if Self::can_cast(syntax.kind()) {
3306 Some(Self { syntax })
3311 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3313 impl AstNode for RefExpr {
3314 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR }
3315 fn cast(syntax: SyntaxNode) -> Option<Self> {
3316 if Self::can_cast(syntax.kind()) {
3317 Some(Self { syntax })
3322 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3324 impl AstNode for PrefixExpr {
3325 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR }
3326 fn cast(syntax: SyntaxNode) -> Option<Self> {
3327 if Self::can_cast(syntax.kind()) {
3328 Some(Self { syntax })
3333 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3335 impl AstNode for BoxExpr {
3336 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR }
3337 fn cast(syntax: SyntaxNode) -> Option<Self> {
3338 if Self::can_cast(syntax.kind()) {
3339 Some(Self { syntax })
3344 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3346 impl AstNode for RangeExpr {
3347 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR }
3348 fn cast(syntax: SyntaxNode) -> Option<Self> {
3349 if Self::can_cast(syntax.kind()) {
3350 Some(Self { syntax })
3355 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3357 impl AstNode for BinExpr {
3358 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR }
3359 fn cast(syntax: SyntaxNode) -> Option<Self> {
3360 if Self::can_cast(syntax.kind()) {
3361 Some(Self { syntax })
3366 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3368 impl AstNode for Literal {
3369 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
3370 fn cast(syntax: SyntaxNode) -> Option<Self> {
3371 if Self::can_cast(syntax.kind()) {
3372 Some(Self { syntax })
3377 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3379 impl AstNode for MatchExpr {
3380 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR }
3381 fn cast(syntax: SyntaxNode) -> Option<Self> {
3382 if Self::can_cast(syntax.kind()) {
3383 Some(Self { syntax })
3388 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3390 impl AstNode for MatchArmList {
3391 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST }
3392 fn cast(syntax: SyntaxNode) -> Option<Self> {
3393 if Self::can_cast(syntax.kind()) {
3394 Some(Self { syntax })
3399 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3401 impl AstNode for MatchArm {
3402 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM }
3403 fn cast(syntax: SyntaxNode) -> Option<Self> {
3404 if Self::can_cast(syntax.kind()) {
3405 Some(Self { syntax })
3410 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3412 impl AstNode for MatchGuard {
3413 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD }
3414 fn cast(syntax: SyntaxNode) -> Option<Self> {
3415 if Self::can_cast(syntax.kind()) {
3416 Some(Self { syntax })
3421 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3423 impl AstNode for RecordLit {
3424 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT }
3425 fn cast(syntax: SyntaxNode) -> Option<Self> {
3426 if Self::can_cast(syntax.kind()) {
3427 Some(Self { syntax })
3432 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3434 impl AstNode for RecordFieldList {
3435 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
3436 fn cast(syntax: SyntaxNode) -> Option<Self> {
3437 if Self::can_cast(syntax.kind()) {
3438 Some(Self { syntax })
3443 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3445 impl AstNode for RecordField {
3446 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
3447 fn cast(syntax: SyntaxNode) -> Option<Self> {
3448 if Self::can_cast(syntax.kind()) {
3449 Some(Self { syntax })
3454 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3456 impl AstNode for OrPat {
3457 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT }
3458 fn cast(syntax: SyntaxNode) -> Option<Self> {
3459 if Self::can_cast(syntax.kind()) {
3460 Some(Self { syntax })
3465 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3467 impl AstNode for ParenPat {
3468 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT }
3469 fn cast(syntax: SyntaxNode) -> Option<Self> {
3470 if Self::can_cast(syntax.kind()) {
3471 Some(Self { syntax })
3476 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3478 impl AstNode for RefPat {
3479 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT }
3480 fn cast(syntax: SyntaxNode) -> Option<Self> {
3481 if Self::can_cast(syntax.kind()) {
3482 Some(Self { syntax })
3487 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3489 impl AstNode for BoxPat {
3490 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT }
3491 fn cast(syntax: SyntaxNode) -> Option<Self> {
3492 if Self::can_cast(syntax.kind()) {
3493 Some(Self { syntax })
3498 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3500 impl AstNode for BindPat {
3501 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT }
3502 fn cast(syntax: SyntaxNode) -> Option<Self> {
3503 if Self::can_cast(syntax.kind()) {
3504 Some(Self { syntax })
3509 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3511 impl AstNode for PlaceholderPat {
3512 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT }
3513 fn cast(syntax: SyntaxNode) -> Option<Self> {
3514 if Self::can_cast(syntax.kind()) {
3515 Some(Self { syntax })
3520 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3522 impl AstNode for DotDotPat {
3523 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT }
3524 fn cast(syntax: SyntaxNode) -> Option<Self> {
3525 if Self::can_cast(syntax.kind()) {
3526 Some(Self { syntax })
3531 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3533 impl AstNode for PathPat {
3534 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT }
3535 fn cast(syntax: SyntaxNode) -> Option<Self> {
3536 if Self::can_cast(syntax.kind()) {
3537 Some(Self { syntax })
3542 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3544 impl AstNode for SlicePat {
3545 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT }
3546 fn cast(syntax: SyntaxNode) -> Option<Self> {
3547 if Self::can_cast(syntax.kind()) {
3548 Some(Self { syntax })
3553 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3555 impl AstNode for RangePat {
3556 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT }
3557 fn cast(syntax: SyntaxNode) -> Option<Self> {
3558 if Self::can_cast(syntax.kind()) {
3559 Some(Self { syntax })
3564 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3566 impl AstNode for LiteralPat {
3567 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
3568 fn cast(syntax: SyntaxNode) -> Option<Self> {
3569 if Self::can_cast(syntax.kind()) {
3570 Some(Self { syntax })
3575 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3577 impl AstNode for MacroPat {
3578 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
3579 fn cast(syntax: SyntaxNode) -> Option<Self> {
3580 if Self::can_cast(syntax.kind()) {
3581 Some(Self { syntax })
3586 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3588 impl AstNode for RecordPat {
3589 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
3590 fn cast(syntax: SyntaxNode) -> Option<Self> {
3591 if Self::can_cast(syntax.kind()) {
3592 Some(Self { syntax })
3597 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3599 impl AstNode for RecordFieldPatList {
3600 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST }
3601 fn cast(syntax: SyntaxNode) -> Option<Self> {
3602 if Self::can_cast(syntax.kind()) {
3603 Some(Self { syntax })
3608 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3610 impl AstNode for RecordFieldPat {
3611 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT }
3612 fn cast(syntax: SyntaxNode) -> Option<Self> {
3613 if Self::can_cast(syntax.kind()) {
3614 Some(Self { syntax })
3619 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3621 impl AstNode for TupleStructPat {
3622 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT }
3623 fn cast(syntax: SyntaxNode) -> Option<Self> {
3624 if Self::can_cast(syntax.kind()) {
3625 Some(Self { syntax })
3630 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3632 impl AstNode for TuplePat {
3633 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT }
3634 fn cast(syntax: SyntaxNode) -> Option<Self> {
3635 if Self::can_cast(syntax.kind()) {
3636 Some(Self { syntax })
3641 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3643 impl AstNode for Visibility {
3644 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
3645 fn cast(syntax: SyntaxNode) -> Option<Self> {
3646 if Self::can_cast(syntax.kind()) {
3647 Some(Self { syntax })
3652 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3654 impl AstNode for Name {
3655 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
3656 fn cast(syntax: SyntaxNode) -> Option<Self> {
3657 if Self::can_cast(syntax.kind()) {
3658 Some(Self { syntax })
3663 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3665 impl AstNode for NameRef {
3666 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
3667 fn cast(syntax: SyntaxNode) -> Option<Self> {
3668 if Self::can_cast(syntax.kind()) {
3669 Some(Self { syntax })
3674 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3676 impl AstNode for MacroCall {
3677 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
3678 fn cast(syntax: SyntaxNode) -> Option<Self> {
3679 if Self::can_cast(syntax.kind()) {
3680 Some(Self { syntax })
3685 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3687 impl AstNode for Attr {
3688 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
3689 fn cast(syntax: SyntaxNode) -> Option<Self> {
3690 if Self::can_cast(syntax.kind()) {
3691 Some(Self { syntax })
3696 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3698 impl AstNode for TokenTree {
3699 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
3700 fn cast(syntax: SyntaxNode) -> Option<Self> {
3701 if Self::can_cast(syntax.kind()) {
3702 Some(Self { syntax })
3707 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3709 impl AstNode for TypeParamList {
3710 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST }
3711 fn cast(syntax: SyntaxNode) -> Option<Self> {
3712 if Self::can_cast(syntax.kind()) {
3713 Some(Self { syntax })
3718 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3720 impl AstNode for TypeParam {
3721 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM }
3722 fn cast(syntax: SyntaxNode) -> Option<Self> {
3723 if Self::can_cast(syntax.kind()) {
3724 Some(Self { syntax })
3729 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3731 impl AstNode for ConstParam {
3732 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
3733 fn cast(syntax: SyntaxNode) -> Option<Self> {
3734 if Self::can_cast(syntax.kind()) {
3735 Some(Self { syntax })
3740 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3742 impl AstNode for LifetimeParam {
3743 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM }
3744 fn cast(syntax: SyntaxNode) -> Option<Self> {
3745 if Self::can_cast(syntax.kind()) {
3746 Some(Self { syntax })
3751 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3753 impl AstNode for TypeBound {
3754 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND }
3755 fn cast(syntax: SyntaxNode) -> Option<Self> {
3756 if Self::can_cast(syntax.kind()) {
3757 Some(Self { syntax })
3762 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3764 impl AstNode for TypeBoundList {
3765 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
3766 fn cast(syntax: SyntaxNode) -> Option<Self> {
3767 if Self::can_cast(syntax.kind()) {
3768 Some(Self { syntax })
3773 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3775 impl AstNode for WherePred {
3776 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED }
3777 fn cast(syntax: SyntaxNode) -> Option<Self> {
3778 if Self::can_cast(syntax.kind()) {
3779 Some(Self { syntax })
3784 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3786 impl AstNode for WhereClause {
3787 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
3788 fn cast(syntax: SyntaxNode) -> Option<Self> {
3789 if Self::can_cast(syntax.kind()) {
3790 Some(Self { syntax })
3795 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3797 impl AstNode for Abi {
3798 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
3799 fn cast(syntax: SyntaxNode) -> Option<Self> {
3800 if Self::can_cast(syntax.kind()) {
3801 Some(Self { syntax })
3806 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3808 impl AstNode for ExprStmt {
3809 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT }
3810 fn cast(syntax: SyntaxNode) -> Option<Self> {
3811 if Self::can_cast(syntax.kind()) {
3812 Some(Self { syntax })
3817 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3819 impl AstNode for LetStmt {
3820 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT }
3821 fn cast(syntax: SyntaxNode) -> Option<Self> {
3822 if Self::can_cast(syntax.kind()) {
3823 Some(Self { syntax })
3828 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3830 impl AstNode for Condition {
3831 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
3832 fn cast(syntax: SyntaxNode) -> Option<Self> {
3833 if Self::can_cast(syntax.kind()) {
3834 Some(Self { syntax })
3839 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3841 impl AstNode for ParamList {
3842 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
3843 fn cast(syntax: SyntaxNode) -> Option<Self> {
3844 if Self::can_cast(syntax.kind()) {
3845 Some(Self { syntax })
3850 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3852 impl AstNode for SelfParam {
3853 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
3854 fn cast(syntax: SyntaxNode) -> Option<Self> {
3855 if Self::can_cast(syntax.kind()) {
3856 Some(Self { syntax })
3861 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3863 impl AstNode for Param {
3864 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
3865 fn cast(syntax: SyntaxNode) -> Option<Self> {
3866 if Self::can_cast(syntax.kind()) {
3867 Some(Self { syntax })
3872 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3874 impl AstNode for UseItem {
3875 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM }
3876 fn cast(syntax: SyntaxNode) -> Option<Self> {
3877 if Self::can_cast(syntax.kind()) {
3878 Some(Self { syntax })
3883 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3885 impl AstNode for UseTree {
3886 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
3887 fn cast(syntax: SyntaxNode) -> Option<Self> {
3888 if Self::can_cast(syntax.kind()) {
3889 Some(Self { syntax })
3894 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3896 impl AstNode for Alias {
3897 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS }
3898 fn cast(syntax: SyntaxNode) -> Option<Self> {
3899 if Self::can_cast(syntax.kind()) {
3900 Some(Self { syntax })
3905 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3907 impl AstNode for UseTreeList {
3908 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
3909 fn cast(syntax: SyntaxNode) -> Option<Self> {
3910 if Self::can_cast(syntax.kind()) {
3911 Some(Self { syntax })
3916 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3918 impl AstNode for ExternCrateItem {
3919 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM }
3920 fn cast(syntax: SyntaxNode) -> Option<Self> {
3921 if Self::can_cast(syntax.kind()) {
3922 Some(Self { syntax })
3927 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3929 impl AstNode for ArgList {
3930 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
3931 fn cast(syntax: SyntaxNode) -> Option<Self> {
3932 if Self::can_cast(syntax.kind()) {
3933 Some(Self { syntax })
3938 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3940 impl AstNode for Path {
3941 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
3942 fn cast(syntax: SyntaxNode) -> Option<Self> {
3943 if Self::can_cast(syntax.kind()) {
3944 Some(Self { syntax })
3949 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3951 impl AstNode for PathSegment {
3952 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
3953 fn cast(syntax: SyntaxNode) -> Option<Self> {
3954 if Self::can_cast(syntax.kind()) {
3955 Some(Self { syntax })
3960 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3962 impl AstNode for TypeArgList {
3963 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST }
3964 fn cast(syntax: SyntaxNode) -> Option<Self> {
3965 if Self::can_cast(syntax.kind()) {
3966 Some(Self { syntax })
3971 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3973 impl AstNode for TypeArg {
3974 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG }
3975 fn cast(syntax: SyntaxNode) -> Option<Self> {
3976 if Self::can_cast(syntax.kind()) {
3977 Some(Self { syntax })
3982 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3984 impl AstNode for AssocTypeArg {
3985 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG }
3986 fn cast(syntax: SyntaxNode) -> Option<Self> {
3987 if Self::can_cast(syntax.kind()) {
3988 Some(Self { syntax })
3993 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3995 impl AstNode for LifetimeArg {
3996 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG }
3997 fn cast(syntax: SyntaxNode) -> Option<Self> {
3998 if Self::can_cast(syntax.kind()) {
3999 Some(Self { syntax })
4004 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4006 impl AstNode for ConstArg {
4007 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG }
4008 fn cast(syntax: SyntaxNode) -> Option<Self> {
4009 if Self::can_cast(syntax.kind()) {
4010 Some(Self { syntax })
4015 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4017 impl AstNode for MacroItems {
4018 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS }
4019 fn cast(syntax: SyntaxNode) -> Option<Self> {
4020 if Self::can_cast(syntax.kind()) {
4021 Some(Self { syntax })
4026 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4028 impl AstNode for ExternItemList {
4029 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
4030 fn cast(syntax: SyntaxNode) -> Option<Self> {
4031 if Self::can_cast(syntax.kind()) {
4032 Some(Self { syntax })
4037 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4039 impl AstNode for ExternBlock {
4040 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
4041 fn cast(syntax: SyntaxNode) -> Option<Self> {
4042 if Self::can_cast(syntax.kind()) {
4043 Some(Self { syntax })
4048 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4050 impl AstNode for MetaItem {
4051 fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM }
4052 fn cast(syntax: SyntaxNode) -> Option<Self> {
4053 if Self::can_cast(syntax.kind()) {
4054 Some(Self { syntax })
4059 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4061 impl AstNode for MacroDef {
4062 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF }
4063 fn cast(syntax: SyntaxNode) -> Option<Self> {
4064 if Self::can_cast(syntax.kind()) {
4065 Some(Self { syntax })
4070 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4072 impl From<StructDef> for NominalDef {
4073 fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) }
4075 impl From<EnumDef> for NominalDef {
4076 fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) }
4078 impl From<UnionDef> for NominalDef {
4079 fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) }
4081 impl AstNode for NominalDef {
4082 fn can_cast(kind: SyntaxKind) -> bool {
4084 STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
4088 fn cast(syntax: SyntaxNode) -> Option<Self> {
4089 let res = match syntax.kind() {
4090 STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
4091 ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
4092 UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
4097 fn syntax(&self) -> &SyntaxNode {
4099 NominalDef::StructDef(it) => &it.syntax,
4100 NominalDef::EnumDef(it) => &it.syntax,
4101 NominalDef::UnionDef(it) => &it.syntax,
4105 impl From<LifetimeParam> for GenericParam {
4106 fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) }
4108 impl From<TypeParam> for GenericParam {
4109 fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) }
4111 impl From<ConstParam> for GenericParam {
4112 fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) }
4114 impl AstNode for GenericParam {
4115 fn can_cast(kind: SyntaxKind) -> bool {
4117 LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
4121 fn cast(syntax: SyntaxNode) -> Option<Self> {
4122 let res = match syntax.kind() {
4123 LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
4124 TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
4125 CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
4130 fn syntax(&self) -> &SyntaxNode {
4132 GenericParam::LifetimeParam(it) => &it.syntax,
4133 GenericParam::TypeParam(it) => &it.syntax,
4134 GenericParam::ConstParam(it) => &it.syntax,
4138 impl From<LifetimeArg> for GenericArg {
4139 fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) }
4141 impl From<TypeArg> for GenericArg {
4142 fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) }
4144 impl From<ConstArg> for GenericArg {
4145 fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) }
4147 impl From<AssocTypeArg> for GenericArg {
4148 fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) }
4150 impl AstNode for GenericArg {
4151 fn can_cast(kind: SyntaxKind) -> bool {
4153 LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true,
4157 fn cast(syntax: SyntaxNode) -> Option<Self> {
4158 let res = match syntax.kind() {
4159 LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
4160 TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
4161 CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
4162 ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
4167 fn syntax(&self) -> &SyntaxNode {
4169 GenericArg::LifetimeArg(it) => &it.syntax,
4170 GenericArg::TypeArg(it) => &it.syntax,
4171 GenericArg::ConstArg(it) => &it.syntax,
4172 GenericArg::AssocTypeArg(it) => &it.syntax,
4176 impl From<ParenType> for TypeRef {
4177 fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) }
4179 impl From<TupleType> for TypeRef {
4180 fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) }
4182 impl From<NeverType> for TypeRef {
4183 fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) }
4185 impl From<PathType> for TypeRef {
4186 fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) }
4188 impl From<PointerType> for TypeRef {
4189 fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) }
4191 impl From<ArrayType> for TypeRef {
4192 fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) }
4194 impl From<SliceType> for TypeRef {
4195 fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) }
4197 impl From<ReferenceType> for TypeRef {
4198 fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) }
4200 impl From<PlaceholderType> for TypeRef {
4201 fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) }
4203 impl From<FnPointerType> for TypeRef {
4204 fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) }
4206 impl From<ForType> for TypeRef {
4207 fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) }
4209 impl From<ImplTraitType> for TypeRef {
4210 fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) }
4212 impl From<DynTraitType> for TypeRef {
4213 fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) }
4215 impl AstNode for TypeRef {
4216 fn can_cast(kind: SyntaxKind) -> bool {
4218 PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
4219 | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
4220 | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
4224 fn cast(syntax: SyntaxNode) -> Option<Self> {
4225 let res = match syntax.kind() {
4226 PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
4227 TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
4228 NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
4229 PATH_TYPE => TypeRef::PathType(PathType { syntax }),
4230 POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
4231 ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
4232 SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
4233 REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
4234 PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
4235 FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
4236 FOR_TYPE => TypeRef::ForType(ForType { syntax }),
4237 IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
4238 DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
4243 fn syntax(&self) -> &SyntaxNode {
4245 TypeRef::ParenType(it) => &it.syntax,
4246 TypeRef::TupleType(it) => &it.syntax,
4247 TypeRef::NeverType(it) => &it.syntax,
4248 TypeRef::PathType(it) => &it.syntax,
4249 TypeRef::PointerType(it) => &it.syntax,
4250 TypeRef::ArrayType(it) => &it.syntax,
4251 TypeRef::SliceType(it) => &it.syntax,
4252 TypeRef::ReferenceType(it) => &it.syntax,
4253 TypeRef::PlaceholderType(it) => &it.syntax,
4254 TypeRef::FnPointerType(it) => &it.syntax,
4255 TypeRef::ForType(it) => &it.syntax,
4256 TypeRef::ImplTraitType(it) => &it.syntax,
4257 TypeRef::DynTraitType(it) => &it.syntax,
4261 impl From<StructDef> for ModuleItem {
4262 fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) }
4264 impl From<UnionDef> for ModuleItem {
4265 fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) }
4267 impl From<EnumDef> for ModuleItem {
4268 fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) }
4270 impl From<FnDef> for ModuleItem {
4271 fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) }
4273 impl From<TraitDef> for ModuleItem {
4274 fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) }
4276 impl From<TypeAliasDef> for ModuleItem {
4277 fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) }
4279 impl From<ImplDef> for ModuleItem {
4280 fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) }
4282 impl From<UseItem> for ModuleItem {
4283 fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) }
4285 impl From<ExternCrateItem> for ModuleItem {
4286 fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) }
4288 impl From<ConstDef> for ModuleItem {
4289 fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) }
4291 impl From<StaticDef> for ModuleItem {
4292 fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) }
4294 impl From<Module> for ModuleItem {
4295 fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) }
4297 impl From<MacroCall> for ModuleItem {
4298 fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) }
4300 impl From<ExternBlock> for ModuleItem {
4301 fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) }
4303 impl AstNode for ModuleItem {
4304 fn can_cast(kind: SyntaxKind) -> bool {
4306 STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
4307 | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
4308 | EXTERN_BLOCK => true,
4312 fn cast(syntax: SyntaxNode) -> Option<Self> {
4313 let res = match syntax.kind() {
4314 STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
4315 UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
4316 ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
4317 FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
4318 TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
4319 TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
4320 IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
4321 USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
4322 EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
4323 CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
4324 STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
4325 MODULE => ModuleItem::Module(Module { syntax }),
4326 MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
4327 EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
4332 fn syntax(&self) -> &SyntaxNode {
4334 ModuleItem::StructDef(it) => &it.syntax,
4335 ModuleItem::UnionDef(it) => &it.syntax,
4336 ModuleItem::EnumDef(it) => &it.syntax,
4337 ModuleItem::FnDef(it) => &it.syntax,
4338 ModuleItem::TraitDef(it) => &it.syntax,
4339 ModuleItem::TypeAliasDef(it) => &it.syntax,
4340 ModuleItem::ImplDef(it) => &it.syntax,
4341 ModuleItem::UseItem(it) => &it.syntax,
4342 ModuleItem::ExternCrateItem(it) => &it.syntax,
4343 ModuleItem::ConstDef(it) => &it.syntax,
4344 ModuleItem::StaticDef(it) => &it.syntax,
4345 ModuleItem::Module(it) => &it.syntax,
4346 ModuleItem::MacroCall(it) => &it.syntax,
4347 ModuleItem::ExternBlock(it) => &it.syntax,
4351 impl From<FnDef> for AssocItem {
4352 fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) }
4354 impl From<TypeAliasDef> for AssocItem {
4355 fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) }
4357 impl From<ConstDef> for AssocItem {
4358 fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) }
4360 impl AstNode for AssocItem {
4361 fn can_cast(kind: SyntaxKind) -> bool {
4363 FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
4367 fn cast(syntax: SyntaxNode) -> Option<Self> {
4368 let res = match syntax.kind() {
4369 FN_DEF => AssocItem::FnDef(FnDef { syntax }),
4370 TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }),
4371 CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }),
4376 fn syntax(&self) -> &SyntaxNode {
4378 AssocItem::FnDef(it) => &it.syntax,
4379 AssocItem::TypeAliasDef(it) => &it.syntax,
4380 AssocItem::ConstDef(it) => &it.syntax,
4384 impl From<FnDef> for ExternItem {
4385 fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) }
4387 impl From<StaticDef> for ExternItem {
4388 fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) }
4390 impl AstNode for ExternItem {
4391 fn can_cast(kind: SyntaxKind) -> bool {
4393 FN_DEF | STATIC_DEF => true,
4397 fn cast(syntax: SyntaxNode) -> Option<Self> {
4398 let res = match syntax.kind() {
4399 FN_DEF => ExternItem::FnDef(FnDef { syntax }),
4400 STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
4405 fn syntax(&self) -> &SyntaxNode {
4407 ExternItem::FnDef(it) => &it.syntax,
4408 ExternItem::StaticDef(it) => &it.syntax,
4412 impl From<TupleExpr> for Expr {
4413 fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) }
4415 impl From<ArrayExpr> for Expr {
4416 fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) }
4418 impl From<ParenExpr> for Expr {
4419 fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) }
4421 impl From<PathExpr> for Expr {
4422 fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) }
4424 impl From<LambdaExpr> for Expr {
4425 fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) }
4427 impl From<IfExpr> for Expr {
4428 fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) }
4430 impl From<LoopExpr> for Expr {
4431 fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) }
4433 impl From<ForExpr> for Expr {
4434 fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) }
4436 impl From<WhileExpr> for Expr {
4437 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) }
4439 impl From<ContinueExpr> for Expr {
4440 fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) }
4442 impl From<BreakExpr> for Expr {
4443 fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) }
4445 impl From<Label> for Expr {
4446 fn from(node: Label) -> Expr { Expr::Label(node) }
4448 impl From<BlockExpr> for Expr {
4449 fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) }
4451 impl From<ReturnExpr> for Expr {
4452 fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) }
4454 impl From<MatchExpr> for Expr {
4455 fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) }
4457 impl From<RecordLit> for Expr {
4458 fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) }
4460 impl From<CallExpr> for Expr {
4461 fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) }
4463 impl From<IndexExpr> for Expr {
4464 fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) }
4466 impl From<MethodCallExpr> for Expr {
4467 fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) }
4469 impl From<FieldExpr> for Expr {
4470 fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) }
4472 impl From<AwaitExpr> for Expr {
4473 fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) }
4475 impl From<TryExpr> for Expr {
4476 fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) }
4478 impl From<EffectExpr> for Expr {
4479 fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) }
4481 impl From<CastExpr> for Expr {
4482 fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) }
4484 impl From<RefExpr> for Expr {
4485 fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) }
4487 impl From<PrefixExpr> for Expr {
4488 fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) }
4490 impl From<RangeExpr> for Expr {
4491 fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) }
4493 impl From<BinExpr> for Expr {
4494 fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) }
4496 impl From<Literal> for Expr {
4497 fn from(node: Literal) -> Expr { Expr::Literal(node) }
4499 impl From<MacroCall> for Expr {
4500 fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) }
4502 impl From<BoxExpr> for Expr {
4503 fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) }
4505 impl AstNode for Expr {
4506 fn can_cast(kind: SyntaxKind) -> bool {
4508 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
4509 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
4510 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
4511 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR
4512 | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => {
4518 fn cast(syntax: SyntaxNode) -> Option<Self> {
4519 let res = match syntax.kind() {
4520 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
4521 ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
4522 PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
4523 PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
4524 LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
4525 IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
4526 LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
4527 FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
4528 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
4529 CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
4530 BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
4531 LABEL => Expr::Label(Label { syntax }),
4532 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
4533 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
4534 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
4535 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
4536 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
4537 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
4538 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
4539 FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
4540 AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
4541 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
4542 EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }),
4543 CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
4544 REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
4545 PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
4546 RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
4547 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
4548 LITERAL => Expr::Literal(Literal { syntax }),
4549 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
4550 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
4555 fn syntax(&self) -> &SyntaxNode {
4557 Expr::TupleExpr(it) => &it.syntax,
4558 Expr::ArrayExpr(it) => &it.syntax,
4559 Expr::ParenExpr(it) => &it.syntax,
4560 Expr::PathExpr(it) => &it.syntax,
4561 Expr::LambdaExpr(it) => &it.syntax,
4562 Expr::IfExpr(it) => &it.syntax,
4563 Expr::LoopExpr(it) => &it.syntax,
4564 Expr::ForExpr(it) => &it.syntax,
4565 Expr::WhileExpr(it) => &it.syntax,
4566 Expr::ContinueExpr(it) => &it.syntax,
4567 Expr::BreakExpr(it) => &it.syntax,
4568 Expr::Label(it) => &it.syntax,
4569 Expr::BlockExpr(it) => &it.syntax,
4570 Expr::ReturnExpr(it) => &it.syntax,
4571 Expr::MatchExpr(it) => &it.syntax,
4572 Expr::RecordLit(it) => &it.syntax,
4573 Expr::CallExpr(it) => &it.syntax,
4574 Expr::IndexExpr(it) => &it.syntax,
4575 Expr::MethodCallExpr(it) => &it.syntax,
4576 Expr::FieldExpr(it) => &it.syntax,
4577 Expr::AwaitExpr(it) => &it.syntax,
4578 Expr::TryExpr(it) => &it.syntax,
4579 Expr::EffectExpr(it) => &it.syntax,
4580 Expr::CastExpr(it) => &it.syntax,
4581 Expr::RefExpr(it) => &it.syntax,
4582 Expr::PrefixExpr(it) => &it.syntax,
4583 Expr::RangeExpr(it) => &it.syntax,
4584 Expr::BinExpr(it) => &it.syntax,
4585 Expr::Literal(it) => &it.syntax,
4586 Expr::MacroCall(it) => &it.syntax,
4587 Expr::BoxExpr(it) => &it.syntax,
4591 impl From<OrPat> for Pat {
4592 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
4594 impl From<ParenPat> for Pat {
4595 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
4597 impl From<RefPat> for Pat {
4598 fn from(node: RefPat) -> Pat { Pat::RefPat(node) }
4600 impl From<BoxPat> for Pat {
4601 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
4603 impl From<BindPat> for Pat {
4604 fn from(node: BindPat) -> Pat { Pat::BindPat(node) }
4606 impl From<PlaceholderPat> for Pat {
4607 fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) }
4609 impl From<DotDotPat> for Pat {
4610 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) }
4612 impl From<PathPat> for Pat {
4613 fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
4615 impl From<RecordPat> for Pat {
4616 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
4618 impl From<TupleStructPat> for Pat {
4619 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
4621 impl From<TuplePat> for Pat {
4622 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
4624 impl From<SlicePat> for Pat {
4625 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
4627 impl From<RangePat> for Pat {
4628 fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
4630 impl From<LiteralPat> for Pat {
4631 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
4633 impl From<MacroPat> for Pat {
4634 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
4636 impl AstNode for Pat {
4637 fn can_cast(kind: SyntaxKind) -> bool {
4639 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
4640 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
4641 | LITERAL_PAT | MACRO_PAT => true,
4645 fn cast(syntax: SyntaxNode) -> Option<Self> {
4646 let res = match syntax.kind() {
4647 OR_PAT => Pat::OrPat(OrPat { syntax }),
4648 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
4649 REF_PAT => Pat::RefPat(RefPat { syntax }),
4650 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
4651 BIND_PAT => Pat::BindPat(BindPat { syntax }),
4652 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
4653 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
4654 PATH_PAT => Pat::PathPat(PathPat { syntax }),
4655 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
4656 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
4657 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
4658 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
4659 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
4660 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
4661 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
4666 fn syntax(&self) -> &SyntaxNode {
4668 Pat::OrPat(it) => &it.syntax,
4669 Pat::ParenPat(it) => &it.syntax,
4670 Pat::RefPat(it) => &it.syntax,
4671 Pat::BoxPat(it) => &it.syntax,
4672 Pat::BindPat(it) => &it.syntax,
4673 Pat::PlaceholderPat(it) => &it.syntax,
4674 Pat::DotDotPat(it) => &it.syntax,
4675 Pat::PathPat(it) => &it.syntax,
4676 Pat::RecordPat(it) => &it.syntax,
4677 Pat::TupleStructPat(it) => &it.syntax,
4678 Pat::TuplePat(it) => &it.syntax,
4679 Pat::SlicePat(it) => &it.syntax,
4680 Pat::RangePat(it) => &it.syntax,
4681 Pat::LiteralPat(it) => &it.syntax,
4682 Pat::MacroPat(it) => &it.syntax,
4686 impl From<RecordFieldPat> for RecordInnerPat {
4687 fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) }
4689 impl From<BindPat> for RecordInnerPat {
4690 fn from(node: BindPat) -> RecordInnerPat { RecordInnerPat::BindPat(node) }
4692 impl AstNode for RecordInnerPat {
4693 fn can_cast(kind: SyntaxKind) -> bool {
4695 RECORD_FIELD_PAT | BIND_PAT => true,
4699 fn cast(syntax: SyntaxNode) -> Option<Self> {
4700 let res = match syntax.kind() {
4701 RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }),
4702 BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }),
4707 fn syntax(&self) -> &SyntaxNode {
4709 RecordInnerPat::RecordFieldPat(it) => &it.syntax,
4710 RecordInnerPat::BindPat(it) => &it.syntax,
4714 impl From<Literal> for AttrInput {
4715 fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) }
4717 impl From<TokenTree> for AttrInput {
4718 fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) }
4720 impl AstNode for AttrInput {
4721 fn can_cast(kind: SyntaxKind) -> bool {
4723 LITERAL | TOKEN_TREE => true,
4727 fn cast(syntax: SyntaxNode) -> Option<Self> {
4728 let res = match syntax.kind() {
4729 LITERAL => AttrInput::Literal(Literal { syntax }),
4730 TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
4735 fn syntax(&self) -> &SyntaxNode {
4737 AttrInput::Literal(it) => &it.syntax,
4738 AttrInput::TokenTree(it) => &it.syntax,
4742 impl From<LetStmt> for Stmt {
4743 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
4745 impl From<ExprStmt> for Stmt {
4746 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
4748 impl AstNode for Stmt {
4749 fn can_cast(kind: SyntaxKind) -> bool {
4751 LET_STMT | EXPR_STMT => true,
4755 fn cast(syntax: SyntaxNode) -> Option<Self> {
4756 let res = match syntax.kind() {
4757 LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
4758 EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
4763 fn syntax(&self) -> &SyntaxNode {
4765 Stmt::LetStmt(it) => &it.syntax,
4766 Stmt::ExprStmt(it) => &it.syntax,
4770 impl From<RecordFieldDefList> for FieldDefList {
4771 fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) }
4773 impl From<TupleFieldDefList> for FieldDefList {
4774 fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) }
4776 impl AstNode for FieldDefList {
4777 fn can_cast(kind: SyntaxKind) -> bool {
4779 RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
4783 fn cast(syntax: SyntaxNode) -> Option<Self> {
4784 let res = match syntax.kind() {
4785 RECORD_FIELD_DEF_LIST => {
4786 FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
4788 TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
4793 fn syntax(&self) -> &SyntaxNode {
4795 FieldDefList::RecordFieldDefList(it) => &it.syntax,
4796 FieldDefList::TupleFieldDefList(it) => &it.syntax,
4800 impl std::fmt::Display for NominalDef {
4801 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4802 std::fmt::Display::fmt(self.syntax(), f)
4805 impl std::fmt::Display for GenericParam {
4806 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4807 std::fmt::Display::fmt(self.syntax(), f)
4810 impl std::fmt::Display for GenericArg {
4811 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4812 std::fmt::Display::fmt(self.syntax(), f)
4815 impl std::fmt::Display for TypeRef {
4816 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4817 std::fmt::Display::fmt(self.syntax(), f)
4820 impl std::fmt::Display for ModuleItem {
4821 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4822 std::fmt::Display::fmt(self.syntax(), f)
4825 impl std::fmt::Display for AssocItem {
4826 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4827 std::fmt::Display::fmt(self.syntax(), f)
4830 impl std::fmt::Display for ExternItem {
4831 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4832 std::fmt::Display::fmt(self.syntax(), f)
4835 impl std::fmt::Display for Expr {
4836 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4837 std::fmt::Display::fmt(self.syntax(), f)
4840 impl std::fmt::Display for Pat {
4841 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4842 std::fmt::Display::fmt(self.syntax(), f)
4845 impl std::fmt::Display for RecordInnerPat {
4846 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4847 std::fmt::Display::fmt(self.syntax(), f)
4850 impl std::fmt::Display for AttrInput {
4851 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4852 std::fmt::Display::fmt(self.syntax(), f)
4855 impl std::fmt::Display for Stmt {
4856 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4857 std::fmt::Display::fmt(self.syntax(), f)
4860 impl std::fmt::Display for FieldDefList {
4861 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4862 std::fmt::Display::fmt(self.syntax(), f)
4865 impl std::fmt::Display for SourceFile {
4866 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4867 std::fmt::Display::fmt(self.syntax(), f)
4870 impl std::fmt::Display for FnDef {
4871 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4872 std::fmt::Display::fmt(self.syntax(), f)
4875 impl std::fmt::Display for RetType {
4876 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4877 std::fmt::Display::fmt(self.syntax(), f)
4880 impl std::fmt::Display for StructDef {
4881 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4882 std::fmt::Display::fmt(self.syntax(), f)
4885 impl std::fmt::Display for UnionDef {
4886 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4887 std::fmt::Display::fmt(self.syntax(), f)
4890 impl std::fmt::Display for RecordFieldDefList {
4891 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4892 std::fmt::Display::fmt(self.syntax(), f)
4895 impl std::fmt::Display for RecordFieldDef {
4896 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4897 std::fmt::Display::fmt(self.syntax(), f)
4900 impl std::fmt::Display for TupleFieldDefList {
4901 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4902 std::fmt::Display::fmt(self.syntax(), f)
4905 impl std::fmt::Display for TupleFieldDef {
4906 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4907 std::fmt::Display::fmt(self.syntax(), f)
4910 impl std::fmt::Display for EnumDef {
4911 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4912 std::fmt::Display::fmt(self.syntax(), f)
4915 impl std::fmt::Display for EnumVariantList {
4916 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4917 std::fmt::Display::fmt(self.syntax(), f)
4920 impl std::fmt::Display for EnumVariant {
4921 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4922 std::fmt::Display::fmt(self.syntax(), f)
4925 impl std::fmt::Display for TraitDef {
4926 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4927 std::fmt::Display::fmt(self.syntax(), f)
4930 impl std::fmt::Display for Module {
4931 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4932 std::fmt::Display::fmt(self.syntax(), f)
4935 impl std::fmt::Display for ItemList {
4936 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4937 std::fmt::Display::fmt(self.syntax(), f)
4940 impl std::fmt::Display for ConstDef {
4941 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4942 std::fmt::Display::fmt(self.syntax(), f)
4945 impl std::fmt::Display for StaticDef {
4946 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4947 std::fmt::Display::fmt(self.syntax(), f)
4950 impl std::fmt::Display for TypeAliasDef {
4951 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4952 std::fmt::Display::fmt(self.syntax(), f)
4955 impl std::fmt::Display for ImplDef {
4956 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4957 std::fmt::Display::fmt(self.syntax(), f)
4960 impl std::fmt::Display for ParenType {
4961 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4962 std::fmt::Display::fmt(self.syntax(), f)
4965 impl std::fmt::Display for TupleType {
4966 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4967 std::fmt::Display::fmt(self.syntax(), f)
4970 impl std::fmt::Display for NeverType {
4971 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4972 std::fmt::Display::fmt(self.syntax(), f)
4975 impl std::fmt::Display for PathType {
4976 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4977 std::fmt::Display::fmt(self.syntax(), f)
4980 impl std::fmt::Display for PointerType {
4981 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4982 std::fmt::Display::fmt(self.syntax(), f)
4985 impl std::fmt::Display for ArrayType {
4986 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4987 std::fmt::Display::fmt(self.syntax(), f)
4990 impl std::fmt::Display for SliceType {
4991 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4992 std::fmt::Display::fmt(self.syntax(), f)
4995 impl std::fmt::Display for ReferenceType {
4996 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4997 std::fmt::Display::fmt(self.syntax(), f)
5000 impl std::fmt::Display for PlaceholderType {
5001 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5002 std::fmt::Display::fmt(self.syntax(), f)
5005 impl std::fmt::Display for FnPointerType {
5006 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5007 std::fmt::Display::fmt(self.syntax(), f)
5010 impl std::fmt::Display for ForType {
5011 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5012 std::fmt::Display::fmt(self.syntax(), f)
5015 impl std::fmt::Display for ImplTraitType {
5016 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5017 std::fmt::Display::fmt(self.syntax(), f)
5020 impl std::fmt::Display for DynTraitType {
5021 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5022 std::fmt::Display::fmt(self.syntax(), f)
5025 impl std::fmt::Display for TupleExpr {
5026 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5027 std::fmt::Display::fmt(self.syntax(), f)
5030 impl std::fmt::Display for ArrayExpr {
5031 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5032 std::fmt::Display::fmt(self.syntax(), f)
5035 impl std::fmt::Display for ParenExpr {
5036 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5037 std::fmt::Display::fmt(self.syntax(), f)
5040 impl std::fmt::Display for PathExpr {
5041 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5042 std::fmt::Display::fmt(self.syntax(), f)
5045 impl std::fmt::Display for LambdaExpr {
5046 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5047 std::fmt::Display::fmt(self.syntax(), f)
5050 impl std::fmt::Display for IfExpr {
5051 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5052 std::fmt::Display::fmt(self.syntax(), f)
5055 impl std::fmt::Display for LoopExpr {
5056 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5057 std::fmt::Display::fmt(self.syntax(), f)
5060 impl std::fmt::Display for EffectExpr {
5061 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5062 std::fmt::Display::fmt(self.syntax(), f)
5065 impl std::fmt::Display for ForExpr {
5066 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5067 std::fmt::Display::fmt(self.syntax(), f)
5070 impl std::fmt::Display for WhileExpr {
5071 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5072 std::fmt::Display::fmt(self.syntax(), f)
5075 impl std::fmt::Display for ContinueExpr {
5076 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5077 std::fmt::Display::fmt(self.syntax(), f)
5080 impl std::fmt::Display for BreakExpr {
5081 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5082 std::fmt::Display::fmt(self.syntax(), f)
5085 impl std::fmt::Display for Label {
5086 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5087 std::fmt::Display::fmt(self.syntax(), f)
5090 impl std::fmt::Display for BlockExpr {
5091 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5092 std::fmt::Display::fmt(self.syntax(), f)
5095 impl std::fmt::Display for ReturnExpr {
5096 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5097 std::fmt::Display::fmt(self.syntax(), f)
5100 impl std::fmt::Display for CallExpr {
5101 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5102 std::fmt::Display::fmt(self.syntax(), f)
5105 impl std::fmt::Display for MethodCallExpr {
5106 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5107 std::fmt::Display::fmt(self.syntax(), f)
5110 impl std::fmt::Display for IndexExpr {
5111 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5112 std::fmt::Display::fmt(self.syntax(), f)
5115 impl std::fmt::Display for FieldExpr {
5116 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5117 std::fmt::Display::fmt(self.syntax(), f)
5120 impl std::fmt::Display for AwaitExpr {
5121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5122 std::fmt::Display::fmt(self.syntax(), f)
5125 impl std::fmt::Display for TryExpr {
5126 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5127 std::fmt::Display::fmt(self.syntax(), f)
5130 impl std::fmt::Display for CastExpr {
5131 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5132 std::fmt::Display::fmt(self.syntax(), f)
5135 impl std::fmt::Display for RefExpr {
5136 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5137 std::fmt::Display::fmt(self.syntax(), f)
5140 impl std::fmt::Display for PrefixExpr {
5141 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5142 std::fmt::Display::fmt(self.syntax(), f)
5145 impl std::fmt::Display for BoxExpr {
5146 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5147 std::fmt::Display::fmt(self.syntax(), f)
5150 impl std::fmt::Display for RangeExpr {
5151 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5152 std::fmt::Display::fmt(self.syntax(), f)
5155 impl std::fmt::Display for BinExpr {
5156 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5157 std::fmt::Display::fmt(self.syntax(), f)
5160 impl std::fmt::Display for Literal {
5161 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5162 std::fmt::Display::fmt(self.syntax(), f)
5165 impl std::fmt::Display for MatchExpr {
5166 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5167 std::fmt::Display::fmt(self.syntax(), f)
5170 impl std::fmt::Display for MatchArmList {
5171 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5172 std::fmt::Display::fmt(self.syntax(), f)
5175 impl std::fmt::Display for MatchArm {
5176 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5177 std::fmt::Display::fmt(self.syntax(), f)
5180 impl std::fmt::Display for MatchGuard {
5181 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5182 std::fmt::Display::fmt(self.syntax(), f)
5185 impl std::fmt::Display for RecordLit {
5186 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5187 std::fmt::Display::fmt(self.syntax(), f)
5190 impl std::fmt::Display for RecordFieldList {
5191 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5192 std::fmt::Display::fmt(self.syntax(), f)
5195 impl std::fmt::Display for RecordField {
5196 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5197 std::fmt::Display::fmt(self.syntax(), f)
5200 impl std::fmt::Display for OrPat {
5201 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5202 std::fmt::Display::fmt(self.syntax(), f)
5205 impl std::fmt::Display for ParenPat {
5206 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5207 std::fmt::Display::fmt(self.syntax(), f)
5210 impl std::fmt::Display for RefPat {
5211 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5212 std::fmt::Display::fmt(self.syntax(), f)
5215 impl std::fmt::Display for BoxPat {
5216 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5217 std::fmt::Display::fmt(self.syntax(), f)
5220 impl std::fmt::Display for BindPat {
5221 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5222 std::fmt::Display::fmt(self.syntax(), f)
5225 impl std::fmt::Display for PlaceholderPat {
5226 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5227 std::fmt::Display::fmt(self.syntax(), f)
5230 impl std::fmt::Display for DotDotPat {
5231 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5232 std::fmt::Display::fmt(self.syntax(), f)
5235 impl std::fmt::Display for PathPat {
5236 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5237 std::fmt::Display::fmt(self.syntax(), f)
5240 impl std::fmt::Display for SlicePat {
5241 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5242 std::fmt::Display::fmt(self.syntax(), f)
5245 impl std::fmt::Display for RangePat {
5246 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5247 std::fmt::Display::fmt(self.syntax(), f)
5250 impl std::fmt::Display for LiteralPat {
5251 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5252 std::fmt::Display::fmt(self.syntax(), f)
5255 impl std::fmt::Display for MacroPat {
5256 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5257 std::fmt::Display::fmt(self.syntax(), f)
5260 impl std::fmt::Display for RecordPat {
5261 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5262 std::fmt::Display::fmt(self.syntax(), f)
5265 impl std::fmt::Display for RecordFieldPatList {
5266 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5267 std::fmt::Display::fmt(self.syntax(), f)
5270 impl std::fmt::Display for RecordFieldPat {
5271 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5272 std::fmt::Display::fmt(self.syntax(), f)
5275 impl std::fmt::Display for TupleStructPat {
5276 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5277 std::fmt::Display::fmt(self.syntax(), f)
5280 impl std::fmt::Display for TuplePat {
5281 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5282 std::fmt::Display::fmt(self.syntax(), f)
5285 impl std::fmt::Display for Visibility {
5286 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5287 std::fmt::Display::fmt(self.syntax(), f)
5290 impl std::fmt::Display for Name {
5291 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5292 std::fmt::Display::fmt(self.syntax(), f)
5295 impl std::fmt::Display for NameRef {
5296 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5297 std::fmt::Display::fmt(self.syntax(), f)
5300 impl std::fmt::Display for MacroCall {
5301 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5302 std::fmt::Display::fmt(self.syntax(), f)
5305 impl std::fmt::Display for Attr {
5306 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5307 std::fmt::Display::fmt(self.syntax(), f)
5310 impl std::fmt::Display for TokenTree {
5311 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5312 std::fmt::Display::fmt(self.syntax(), f)
5315 impl std::fmt::Display for TypeParamList {
5316 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5317 std::fmt::Display::fmt(self.syntax(), f)
5320 impl std::fmt::Display for TypeParam {
5321 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5322 std::fmt::Display::fmt(self.syntax(), f)
5325 impl std::fmt::Display for ConstParam {
5326 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5327 std::fmt::Display::fmt(self.syntax(), f)
5330 impl std::fmt::Display for LifetimeParam {
5331 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5332 std::fmt::Display::fmt(self.syntax(), f)
5335 impl std::fmt::Display for TypeBound {
5336 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5337 std::fmt::Display::fmt(self.syntax(), f)
5340 impl std::fmt::Display for TypeBoundList {
5341 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5342 std::fmt::Display::fmt(self.syntax(), f)
5345 impl std::fmt::Display for WherePred {
5346 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5347 std::fmt::Display::fmt(self.syntax(), f)
5350 impl std::fmt::Display for WhereClause {
5351 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5352 std::fmt::Display::fmt(self.syntax(), f)
5355 impl std::fmt::Display for Abi {
5356 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5357 std::fmt::Display::fmt(self.syntax(), f)
5360 impl std::fmt::Display for ExprStmt {
5361 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5362 std::fmt::Display::fmt(self.syntax(), f)
5365 impl std::fmt::Display for LetStmt {
5366 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5367 std::fmt::Display::fmt(self.syntax(), f)
5370 impl std::fmt::Display for Condition {
5371 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5372 std::fmt::Display::fmt(self.syntax(), f)
5375 impl std::fmt::Display for ParamList {
5376 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5377 std::fmt::Display::fmt(self.syntax(), f)
5380 impl std::fmt::Display for SelfParam {
5381 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5382 std::fmt::Display::fmt(self.syntax(), f)
5385 impl std::fmt::Display for Param {
5386 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5387 std::fmt::Display::fmt(self.syntax(), f)
5390 impl std::fmt::Display for UseItem {
5391 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5392 std::fmt::Display::fmt(self.syntax(), f)
5395 impl std::fmt::Display for UseTree {
5396 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5397 std::fmt::Display::fmt(self.syntax(), f)
5400 impl std::fmt::Display for Alias {
5401 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5402 std::fmt::Display::fmt(self.syntax(), f)
5405 impl std::fmt::Display for UseTreeList {
5406 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5407 std::fmt::Display::fmt(self.syntax(), f)
5410 impl std::fmt::Display for ExternCrateItem {
5411 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5412 std::fmt::Display::fmt(self.syntax(), f)
5415 impl std::fmt::Display for ArgList {
5416 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5417 std::fmt::Display::fmt(self.syntax(), f)
5420 impl std::fmt::Display for Path {
5421 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5422 std::fmt::Display::fmt(self.syntax(), f)
5425 impl std::fmt::Display for PathSegment {
5426 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5427 std::fmt::Display::fmt(self.syntax(), f)
5430 impl std::fmt::Display for TypeArgList {
5431 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5432 std::fmt::Display::fmt(self.syntax(), f)
5435 impl std::fmt::Display for TypeArg {
5436 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5437 std::fmt::Display::fmt(self.syntax(), f)
5440 impl std::fmt::Display for AssocTypeArg {
5441 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5442 std::fmt::Display::fmt(self.syntax(), f)
5445 impl std::fmt::Display for LifetimeArg {
5446 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5447 std::fmt::Display::fmt(self.syntax(), f)
5450 impl std::fmt::Display for ConstArg {
5451 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5452 std::fmt::Display::fmt(self.syntax(), f)
5455 impl std::fmt::Display for MacroItems {
5456 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5457 std::fmt::Display::fmt(self.syntax(), f)
5460 impl std::fmt::Display for ExternItemList {
5461 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5462 std::fmt::Display::fmt(self.syntax(), f)
5465 impl std::fmt::Display for ExternBlock {
5466 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5467 std::fmt::Display::fmt(self.syntax(), f)
5470 impl std::fmt::Display for MetaItem {
5471 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5472 std::fmt::Display::fmt(self.syntax(), f)
5475 impl std::fmt::Display for MacroDef {
5476 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
5477 std::fmt::Display::fmt(self.syntax(), f)