aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated.rs635
-rw-r--r--crates/ra_syntax/src/parsing/lexer.rs4
-rw-r--r--crates/ra_syntax/src/tests.rs11
4 files changed, 644 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 4a70c712f..26fafb469 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -30,7 +30,7 @@ pub use self::{
30/// conversion itself has zero runtime cost: ast and syntax nodes have exactly 30/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
31/// the same representation: a pointer to the tree root and a pointer to the 31/// the same representation: a pointer to the tree root and a pointer to the
32/// node itself. 32/// node itself.
33pub trait AstNode { 33pub trait AstNode: std::fmt::Display {
34 fn can_cast(kind: SyntaxKind) -> bool 34 fn can_cast(kind: SyntaxKind) -> bool
35 where 35 where
36 Self: Sized; 36 Self: Sized;
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 150893e39..002f453cd 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -9,6 +9,11 @@ use crate::{
9pub struct SourceFile { 9pub struct SourceFile {
10 pub(crate) syntax: SyntaxNode, 10 pub(crate) syntax: SyntaxNode,
11} 11}
12impl std::fmt::Display for SourceFile {
13 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
14 std::fmt::Display::fmt(self.syntax(), f)
15 }
16}
12impl AstNode for SourceFile { 17impl AstNode for SourceFile {
13 fn can_cast(kind: SyntaxKind) -> bool { 18 fn can_cast(kind: SyntaxKind) -> bool {
14 match kind { 19 match kind {
@@ -38,6 +43,11 @@ impl SourceFile {
38pub struct FnDef { 43pub struct FnDef {
39 pub(crate) syntax: SyntaxNode, 44 pub(crate) syntax: SyntaxNode,
40} 45}
46impl std::fmt::Display for FnDef {
47 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
48 std::fmt::Display::fmt(self.syntax(), f)
49 }
50}
41impl AstNode for FnDef { 51impl AstNode for FnDef {
42 fn can_cast(kind: SyntaxKind) -> bool { 52 fn can_cast(kind: SyntaxKind) -> bool {
43 match kind { 53 match kind {
@@ -76,6 +86,11 @@ impl FnDef {
76pub struct RetType { 86pub struct RetType {
77 pub(crate) syntax: SyntaxNode, 87 pub(crate) syntax: SyntaxNode,
78} 88}
89impl std::fmt::Display for RetType {
90 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
91 std::fmt::Display::fmt(self.syntax(), f)
92 }
93}
79impl AstNode for RetType { 94impl AstNode for RetType {
80 fn can_cast(kind: SyntaxKind) -> bool { 95 fn can_cast(kind: SyntaxKind) -> bool {
81 match kind { 96 match kind {
@@ -103,6 +118,11 @@ impl RetType {
103pub struct StructDef { 118pub struct StructDef {
104 pub(crate) syntax: SyntaxNode, 119 pub(crate) syntax: SyntaxNode,
105} 120}
121impl std::fmt::Display for StructDef {
122 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
123 std::fmt::Display::fmt(self.syntax(), f)
124 }
125}
106impl AstNode for StructDef { 126impl AstNode for StructDef {
107 fn can_cast(kind: SyntaxKind) -> bool { 127 fn can_cast(kind: SyntaxKind) -> bool {
108 match kind { 128 match kind {
@@ -131,6 +151,11 @@ impl StructDef {}
131pub struct UnionDef { 151pub struct UnionDef {
132 pub(crate) syntax: SyntaxNode, 152 pub(crate) syntax: SyntaxNode,
133} 153}
154impl std::fmt::Display for UnionDef {
155 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
156 std::fmt::Display::fmt(self.syntax(), f)
157 }
158}
134impl AstNode for UnionDef { 159impl AstNode for UnionDef {
135 fn can_cast(kind: SyntaxKind) -> bool { 160 fn can_cast(kind: SyntaxKind) -> bool {
136 match kind { 161 match kind {
@@ -163,6 +188,11 @@ impl UnionDef {
163pub struct RecordFieldDefList { 188pub struct RecordFieldDefList {
164 pub(crate) syntax: SyntaxNode, 189 pub(crate) syntax: SyntaxNode,
165} 190}
191impl std::fmt::Display for RecordFieldDefList {
192 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
193 std::fmt::Display::fmt(self.syntax(), f)
194 }
195}
166impl AstNode for RecordFieldDefList { 196impl AstNode for RecordFieldDefList {
167 fn can_cast(kind: SyntaxKind) -> bool { 197 fn can_cast(kind: SyntaxKind) -> bool {
168 match kind { 198 match kind {
@@ -190,6 +220,11 @@ impl RecordFieldDefList {
190pub struct RecordFieldDef { 220pub struct RecordFieldDef {
191 pub(crate) syntax: SyntaxNode, 221 pub(crate) syntax: SyntaxNode,
192} 222}
223impl std::fmt::Display for RecordFieldDef {
224 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
225 std::fmt::Display::fmt(self.syntax(), f)
226 }
227}
193impl AstNode for RecordFieldDef { 228impl AstNode for RecordFieldDef {
194 fn can_cast(kind: SyntaxKind) -> bool { 229 fn can_cast(kind: SyntaxKind) -> bool {
195 match kind { 230 match kind {
@@ -218,6 +253,11 @@ impl RecordFieldDef {}
218pub struct TupleFieldDefList { 253pub struct TupleFieldDefList {
219 pub(crate) syntax: SyntaxNode, 254 pub(crate) syntax: SyntaxNode,
220} 255}
256impl std::fmt::Display for TupleFieldDefList {
257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
258 std::fmt::Display::fmt(self.syntax(), f)
259 }
260}
221impl AstNode for TupleFieldDefList { 261impl AstNode for TupleFieldDefList {
222 fn can_cast(kind: SyntaxKind) -> bool { 262 fn can_cast(kind: SyntaxKind) -> bool {
223 match kind { 263 match kind {
@@ -245,6 +285,11 @@ impl TupleFieldDefList {
245pub struct TupleFieldDef { 285pub struct TupleFieldDef {
246 pub(crate) syntax: SyntaxNode, 286 pub(crate) syntax: SyntaxNode,
247} 287}
288impl std::fmt::Display for TupleFieldDef {
289 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
290 std::fmt::Display::fmt(self.syntax(), f)
291 }
292}
248impl AstNode for TupleFieldDef { 293impl AstNode for TupleFieldDef {
249 fn can_cast(kind: SyntaxKind) -> bool { 294 fn can_cast(kind: SyntaxKind) -> bool {
250 match kind { 295 match kind {
@@ -274,6 +319,11 @@ impl TupleFieldDef {
274pub struct EnumDef { 319pub struct EnumDef {
275 pub(crate) syntax: SyntaxNode, 320 pub(crate) syntax: SyntaxNode,
276} 321}
322impl std::fmt::Display for EnumDef {
323 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
324 std::fmt::Display::fmt(self.syntax(), f)
325 }
326}
277impl AstNode for EnumDef { 327impl AstNode for EnumDef {
278 fn can_cast(kind: SyntaxKind) -> bool { 328 fn can_cast(kind: SyntaxKind) -> bool {
279 match kind { 329 match kind {
@@ -306,6 +356,11 @@ impl EnumDef {
306pub struct EnumVariantList { 356pub struct EnumVariantList {
307 pub(crate) syntax: SyntaxNode, 357 pub(crate) syntax: SyntaxNode,
308} 358}
359impl std::fmt::Display for EnumVariantList {
360 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
361 std::fmt::Display::fmt(self.syntax(), f)
362 }
363}
309impl AstNode for EnumVariantList { 364impl AstNode for EnumVariantList {
310 fn can_cast(kind: SyntaxKind) -> bool { 365 fn can_cast(kind: SyntaxKind) -> bool {
311 match kind { 366 match kind {
@@ -333,6 +388,11 @@ impl EnumVariantList {
333pub struct EnumVariant { 388pub struct EnumVariant {
334 pub(crate) syntax: SyntaxNode, 389 pub(crate) syntax: SyntaxNode,
335} 390}
391impl std::fmt::Display for EnumVariant {
392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
393 std::fmt::Display::fmt(self.syntax(), f)
394 }
395}
336impl AstNode for EnumVariant { 396impl AstNode for EnumVariant {
337 fn can_cast(kind: SyntaxKind) -> bool { 397 fn can_cast(kind: SyntaxKind) -> bool {
338 match kind { 398 match kind {
@@ -363,6 +423,11 @@ impl EnumVariant {
363pub struct TraitDef { 423pub struct TraitDef {
364 pub(crate) syntax: SyntaxNode, 424 pub(crate) syntax: SyntaxNode,
365} 425}
426impl std::fmt::Display for TraitDef {
427 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
428 std::fmt::Display::fmt(self.syntax(), f)
429 }
430}
366impl AstNode for TraitDef { 431impl AstNode for TraitDef {
367 fn can_cast(kind: SyntaxKind) -> bool { 432 fn can_cast(kind: SyntaxKind) -> bool {
368 match kind { 433 match kind {
@@ -396,6 +461,11 @@ impl TraitDef {
396pub struct Module { 461pub struct Module {
397 pub(crate) syntax: SyntaxNode, 462 pub(crate) syntax: SyntaxNode,
398} 463}
464impl std::fmt::Display for Module {
465 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
466 std::fmt::Display::fmt(self.syntax(), f)
467 }
468}
399impl AstNode for Module { 469impl AstNode for Module {
400 fn can_cast(kind: SyntaxKind) -> bool { 470 fn can_cast(kind: SyntaxKind) -> bool {
401 match kind { 471 match kind {
@@ -427,6 +497,11 @@ impl Module {
427pub struct ItemList { 497pub struct ItemList {
428 pub(crate) syntax: SyntaxNode, 498 pub(crate) syntax: SyntaxNode,
429} 499}
500impl std::fmt::Display for ItemList {
501 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
502 std::fmt::Display::fmt(self.syntax(), f)
503 }
504}
430impl AstNode for ItemList { 505impl AstNode for ItemList {
431 fn can_cast(kind: SyntaxKind) -> bool { 506 fn can_cast(kind: SyntaxKind) -> bool {
432 match kind { 507 match kind {
@@ -456,6 +531,11 @@ impl ItemList {
456pub struct ConstDef { 531pub struct ConstDef {
457 pub(crate) syntax: SyntaxNode, 532 pub(crate) syntax: SyntaxNode,
458} 533}
534impl std::fmt::Display for ConstDef {
535 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
536 std::fmt::Display::fmt(self.syntax(), f)
537 }
538}
459impl AstNode for ConstDef { 539impl AstNode for ConstDef {
460 fn can_cast(kind: SyntaxKind) -> bool { 540 fn can_cast(kind: SyntaxKind) -> bool {
461 match kind { 541 match kind {
@@ -489,6 +569,11 @@ impl ConstDef {
489pub struct StaticDef { 569pub struct StaticDef {
490 pub(crate) syntax: SyntaxNode, 570 pub(crate) syntax: SyntaxNode,
491} 571}
572impl std::fmt::Display for StaticDef {
573 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
574 std::fmt::Display::fmt(self.syntax(), f)
575 }
576}
492impl AstNode for StaticDef { 577impl AstNode for StaticDef {
493 fn can_cast(kind: SyntaxKind) -> bool { 578 fn can_cast(kind: SyntaxKind) -> bool {
494 match kind { 579 match kind {
@@ -522,6 +607,11 @@ impl StaticDef {
522pub struct TypeAliasDef { 607pub struct TypeAliasDef {
523 pub(crate) syntax: SyntaxNode, 608 pub(crate) syntax: SyntaxNode,
524} 609}
610impl std::fmt::Display for TypeAliasDef {
611 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
612 std::fmt::Display::fmt(self.syntax(), f)
613 }
614}
525impl AstNode for TypeAliasDef { 615impl AstNode for TypeAliasDef {
526 fn can_cast(kind: SyntaxKind) -> bool { 616 fn can_cast(kind: SyntaxKind) -> bool {
527 match kind { 617 match kind {
@@ -555,6 +645,11 @@ impl TypeAliasDef {
555pub struct ImplDef { 645pub struct ImplDef {
556 pub(crate) syntax: SyntaxNode, 646 pub(crate) syntax: SyntaxNode,
557} 647}
648impl std::fmt::Display for ImplDef {
649 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
650 std::fmt::Display::fmt(self.syntax(), f)
651 }
652}
558impl AstNode for ImplDef { 653impl AstNode for ImplDef {
559 fn can_cast(kind: SyntaxKind) -> bool { 654 fn can_cast(kind: SyntaxKind) -> bool {
560 match kind { 655 match kind {
@@ -584,6 +679,11 @@ impl ImplDef {
584pub struct ParenType { 679pub struct ParenType {
585 pub(crate) syntax: SyntaxNode, 680 pub(crate) syntax: SyntaxNode,
586} 681}
682impl std::fmt::Display for ParenType {
683 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
684 std::fmt::Display::fmt(self.syntax(), f)
685 }
686}
587impl AstNode for ParenType { 687impl AstNode for ParenType {
588 fn can_cast(kind: SyntaxKind) -> bool { 688 fn can_cast(kind: SyntaxKind) -> bool {
589 match kind { 689 match kind {
@@ -611,6 +711,11 @@ impl ParenType {
611pub struct TupleType { 711pub struct TupleType {
612 pub(crate) syntax: SyntaxNode, 712 pub(crate) syntax: SyntaxNode,
613} 713}
714impl std::fmt::Display for TupleType {
715 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
716 std::fmt::Display::fmt(self.syntax(), f)
717 }
718}
614impl AstNode for TupleType { 719impl AstNode for TupleType {
615 fn can_cast(kind: SyntaxKind) -> bool { 720 fn can_cast(kind: SyntaxKind) -> bool {
616 match kind { 721 match kind {
@@ -638,6 +743,11 @@ impl TupleType {
638pub struct NeverType { 743pub struct NeverType {
639 pub(crate) syntax: SyntaxNode, 744 pub(crate) syntax: SyntaxNode,
640} 745}
746impl std::fmt::Display for NeverType {
747 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
748 std::fmt::Display::fmt(self.syntax(), f)
749 }
750}
641impl AstNode for NeverType { 751impl AstNode for NeverType {
642 fn can_cast(kind: SyntaxKind) -> bool { 752 fn can_cast(kind: SyntaxKind) -> bool {
643 match kind { 753 match kind {
@@ -661,6 +771,11 @@ impl NeverType {}
661pub struct PathType { 771pub struct PathType {
662 pub(crate) syntax: SyntaxNode, 772 pub(crate) syntax: SyntaxNode,
663} 773}
774impl std::fmt::Display for PathType {
775 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
776 std::fmt::Display::fmt(self.syntax(), f)
777 }
778}
664impl AstNode for PathType { 779impl AstNode for PathType {
665 fn can_cast(kind: SyntaxKind) -> bool { 780 fn can_cast(kind: SyntaxKind) -> bool {
666 match kind { 781 match kind {
@@ -688,6 +803,11 @@ impl PathType {
688pub struct PointerType { 803pub struct PointerType {
689 pub(crate) syntax: SyntaxNode, 804 pub(crate) syntax: SyntaxNode,
690} 805}
806impl std::fmt::Display for PointerType {
807 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
808 std::fmt::Display::fmt(self.syntax(), f)
809 }
810}
691impl AstNode for PointerType { 811impl AstNode for PointerType {
692 fn can_cast(kind: SyntaxKind) -> bool { 812 fn can_cast(kind: SyntaxKind) -> bool {
693 match kind { 813 match kind {
@@ -715,6 +835,11 @@ impl PointerType {
715pub struct ArrayType { 835pub struct ArrayType {
716 pub(crate) syntax: SyntaxNode, 836 pub(crate) syntax: SyntaxNode,
717} 837}
838impl std::fmt::Display for ArrayType {
839 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
840 std::fmt::Display::fmt(self.syntax(), f)
841 }
842}
718impl AstNode for ArrayType { 843impl AstNode for ArrayType {
719 fn can_cast(kind: SyntaxKind) -> bool { 844 fn can_cast(kind: SyntaxKind) -> bool {
720 match kind { 845 match kind {
@@ -745,6 +870,11 @@ impl ArrayType {
745pub struct SliceType { 870pub struct SliceType {
746 pub(crate) syntax: SyntaxNode, 871 pub(crate) syntax: SyntaxNode,
747} 872}
873impl std::fmt::Display for SliceType {
874 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
875 std::fmt::Display::fmt(self.syntax(), f)
876 }
877}
748impl AstNode for SliceType { 878impl AstNode for SliceType {
749 fn can_cast(kind: SyntaxKind) -> bool { 879 fn can_cast(kind: SyntaxKind) -> bool {
750 match kind { 880 match kind {
@@ -772,6 +902,11 @@ impl SliceType {
772pub struct ReferenceType { 902pub struct ReferenceType {
773 pub(crate) syntax: SyntaxNode, 903 pub(crate) syntax: SyntaxNode,
774} 904}
905impl std::fmt::Display for ReferenceType {
906 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
907 std::fmt::Display::fmt(self.syntax(), f)
908 }
909}
775impl AstNode for ReferenceType { 910impl AstNode for ReferenceType {
776 fn can_cast(kind: SyntaxKind) -> bool { 911 fn can_cast(kind: SyntaxKind) -> bool {
777 match kind { 912 match kind {
@@ -799,6 +934,11 @@ impl ReferenceType {
799pub struct PlaceholderType { 934pub struct PlaceholderType {
800 pub(crate) syntax: SyntaxNode, 935 pub(crate) syntax: SyntaxNode,
801} 936}
937impl std::fmt::Display for PlaceholderType {
938 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
939 std::fmt::Display::fmt(self.syntax(), f)
940 }
941}
802impl AstNode for PlaceholderType { 942impl AstNode for PlaceholderType {
803 fn can_cast(kind: SyntaxKind) -> bool { 943 fn can_cast(kind: SyntaxKind) -> bool {
804 match kind { 944 match kind {
@@ -822,6 +962,11 @@ impl PlaceholderType {}
822pub struct FnPointerType { 962pub struct FnPointerType {
823 pub(crate) syntax: SyntaxNode, 963 pub(crate) syntax: SyntaxNode,
824} 964}
965impl std::fmt::Display for FnPointerType {
966 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
967 std::fmt::Display::fmt(self.syntax(), f)
968 }
969}
825impl AstNode for FnPointerType { 970impl AstNode for FnPointerType {
826 fn can_cast(kind: SyntaxKind) -> bool { 971 fn can_cast(kind: SyntaxKind) -> bool {
827 match kind { 972 match kind {
@@ -852,6 +997,11 @@ impl FnPointerType {
852pub struct ForType { 997pub struct ForType {
853 pub(crate) syntax: SyntaxNode, 998 pub(crate) syntax: SyntaxNode,
854} 999}
1000impl std::fmt::Display for ForType {
1001 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1002 std::fmt::Display::fmt(self.syntax(), f)
1003 }
1004}
855impl AstNode for ForType { 1005impl AstNode for ForType {
856 fn can_cast(kind: SyntaxKind) -> bool { 1006 fn can_cast(kind: SyntaxKind) -> bool {
857 match kind { 1007 match kind {
@@ -879,6 +1029,11 @@ impl ForType {
879pub struct ImplTraitType { 1029pub struct ImplTraitType {
880 pub(crate) syntax: SyntaxNode, 1030 pub(crate) syntax: SyntaxNode,
881} 1031}
1032impl std::fmt::Display for ImplTraitType {
1033 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1034 std::fmt::Display::fmt(self.syntax(), f)
1035 }
1036}
882impl AstNode for ImplTraitType { 1037impl AstNode for ImplTraitType {
883 fn can_cast(kind: SyntaxKind) -> bool { 1038 fn can_cast(kind: SyntaxKind) -> bool {
884 match kind { 1039 match kind {
@@ -903,6 +1058,11 @@ impl ImplTraitType {}
903pub struct DynTraitType { 1058pub struct DynTraitType {
904 pub(crate) syntax: SyntaxNode, 1059 pub(crate) syntax: SyntaxNode,
905} 1060}
1061impl std::fmt::Display for DynTraitType {
1062 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1063 std::fmt::Display::fmt(self.syntax(), f)
1064 }
1065}
906impl AstNode for DynTraitType { 1066impl AstNode for DynTraitType {
907 fn can_cast(kind: SyntaxKind) -> bool { 1067 fn can_cast(kind: SyntaxKind) -> bool {
908 match kind { 1068 match kind {
@@ -927,6 +1087,11 @@ impl DynTraitType {}
927pub struct TupleExpr { 1087pub struct TupleExpr {
928 pub(crate) syntax: SyntaxNode, 1088 pub(crate) syntax: SyntaxNode,
929} 1089}
1090impl std::fmt::Display for TupleExpr {
1091 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1092 std::fmt::Display::fmt(self.syntax(), f)
1093 }
1094}
930impl AstNode for TupleExpr { 1095impl AstNode for TupleExpr {
931 fn can_cast(kind: SyntaxKind) -> bool { 1096 fn can_cast(kind: SyntaxKind) -> bool {
932 match kind { 1097 match kind {
@@ -954,6 +1119,11 @@ impl TupleExpr {
954pub struct ArrayExpr { 1119pub struct ArrayExpr {
955 pub(crate) syntax: SyntaxNode, 1120 pub(crate) syntax: SyntaxNode,
956} 1121}
1122impl std::fmt::Display for ArrayExpr {
1123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1124 std::fmt::Display::fmt(self.syntax(), f)
1125 }
1126}
957impl AstNode for ArrayExpr { 1127impl AstNode for ArrayExpr {
958 fn can_cast(kind: SyntaxKind) -> bool { 1128 fn can_cast(kind: SyntaxKind) -> bool {
959 match kind { 1129 match kind {
@@ -981,6 +1151,11 @@ impl ArrayExpr {
981pub struct ParenExpr { 1151pub struct ParenExpr {
982 pub(crate) syntax: SyntaxNode, 1152 pub(crate) syntax: SyntaxNode,
983} 1153}
1154impl std::fmt::Display for ParenExpr {
1155 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1156 std::fmt::Display::fmt(self.syntax(), f)
1157 }
1158}
984impl AstNode for ParenExpr { 1159impl AstNode for ParenExpr {
985 fn can_cast(kind: SyntaxKind) -> bool { 1160 fn can_cast(kind: SyntaxKind) -> bool {
986 match kind { 1161 match kind {
@@ -1008,6 +1183,11 @@ impl ParenExpr {
1008pub struct PathExpr { 1183pub struct PathExpr {
1009 pub(crate) syntax: SyntaxNode, 1184 pub(crate) syntax: SyntaxNode,
1010} 1185}
1186impl std::fmt::Display for PathExpr {
1187 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1188 std::fmt::Display::fmt(self.syntax(), f)
1189 }
1190}
1011impl AstNode for PathExpr { 1191impl AstNode for PathExpr {
1012 fn can_cast(kind: SyntaxKind) -> bool { 1192 fn can_cast(kind: SyntaxKind) -> bool {
1013 match kind { 1193 match kind {
@@ -1035,6 +1215,11 @@ impl PathExpr {
1035pub struct LambdaExpr { 1215pub struct LambdaExpr {
1036 pub(crate) syntax: SyntaxNode, 1216 pub(crate) syntax: SyntaxNode,
1037} 1217}
1218impl std::fmt::Display for LambdaExpr {
1219 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1220 std::fmt::Display::fmt(self.syntax(), f)
1221 }
1222}
1038impl AstNode for LambdaExpr { 1223impl AstNode for LambdaExpr {
1039 fn can_cast(kind: SyntaxKind) -> bool { 1224 fn can_cast(kind: SyntaxKind) -> bool {
1040 match kind { 1225 match kind {
@@ -1068,6 +1253,11 @@ impl LambdaExpr {
1068pub struct IfExpr { 1253pub struct IfExpr {
1069 pub(crate) syntax: SyntaxNode, 1254 pub(crate) syntax: SyntaxNode,
1070} 1255}
1256impl std::fmt::Display for IfExpr {
1257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1258 std::fmt::Display::fmt(self.syntax(), f)
1259 }
1260}
1071impl AstNode for IfExpr { 1261impl AstNode for IfExpr {
1072 fn can_cast(kind: SyntaxKind) -> bool { 1262 fn can_cast(kind: SyntaxKind) -> bool {
1073 match kind { 1263 match kind {
@@ -1095,6 +1285,11 @@ impl IfExpr {
1095pub struct LoopExpr { 1285pub struct LoopExpr {
1096 pub(crate) syntax: SyntaxNode, 1286 pub(crate) syntax: SyntaxNode,
1097} 1287}
1288impl std::fmt::Display for LoopExpr {
1289 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1290 std::fmt::Display::fmt(self.syntax(), f)
1291 }
1292}
1098impl AstNode for LoopExpr { 1293impl AstNode for LoopExpr {
1099 fn can_cast(kind: SyntaxKind) -> bool { 1294 fn can_cast(kind: SyntaxKind) -> bool {
1100 match kind { 1295 match kind {
@@ -1119,6 +1314,11 @@ impl LoopExpr {}
1119pub struct TryBlockExpr { 1314pub struct TryBlockExpr {
1120 pub(crate) syntax: SyntaxNode, 1315 pub(crate) syntax: SyntaxNode,
1121} 1316}
1317impl std::fmt::Display for TryBlockExpr {
1318 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1319 std::fmt::Display::fmt(self.syntax(), f)
1320 }
1321}
1122impl AstNode for TryBlockExpr { 1322impl AstNode for TryBlockExpr {
1123 fn can_cast(kind: SyntaxKind) -> bool { 1323 fn can_cast(kind: SyntaxKind) -> bool {
1124 match kind { 1324 match kind {
@@ -1146,6 +1346,11 @@ impl TryBlockExpr {
1146pub struct ForExpr { 1346pub struct ForExpr {
1147 pub(crate) syntax: SyntaxNode, 1347 pub(crate) syntax: SyntaxNode,
1148} 1348}
1349impl std::fmt::Display for ForExpr {
1350 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1351 std::fmt::Display::fmt(self.syntax(), f)
1352 }
1353}
1149impl AstNode for ForExpr { 1354impl AstNode for ForExpr {
1150 fn can_cast(kind: SyntaxKind) -> bool { 1355 fn can_cast(kind: SyntaxKind) -> bool {
1151 match kind { 1356 match kind {
@@ -1177,6 +1382,11 @@ impl ForExpr {
1177pub struct WhileExpr { 1382pub struct WhileExpr {
1178 pub(crate) syntax: SyntaxNode, 1383 pub(crate) syntax: SyntaxNode,
1179} 1384}
1385impl std::fmt::Display for WhileExpr {
1386 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1387 std::fmt::Display::fmt(self.syntax(), f)
1388 }
1389}
1180impl AstNode for WhileExpr { 1390impl AstNode for WhileExpr {
1181 fn can_cast(kind: SyntaxKind) -> bool { 1391 fn can_cast(kind: SyntaxKind) -> bool {
1182 match kind { 1392 match kind {
@@ -1205,6 +1415,11 @@ impl WhileExpr {
1205pub struct ContinueExpr { 1415pub struct ContinueExpr {
1206 pub(crate) syntax: SyntaxNode, 1416 pub(crate) syntax: SyntaxNode,
1207} 1417}
1418impl std::fmt::Display for ContinueExpr {
1419 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1420 std::fmt::Display::fmt(self.syntax(), f)
1421 }
1422}
1208impl AstNode for ContinueExpr { 1423impl AstNode for ContinueExpr {
1209 fn can_cast(kind: SyntaxKind) -> bool { 1424 fn can_cast(kind: SyntaxKind) -> bool {
1210 match kind { 1425 match kind {
@@ -1228,6 +1443,11 @@ impl ContinueExpr {}
1228pub struct BreakExpr { 1443pub struct BreakExpr {
1229 pub(crate) syntax: SyntaxNode, 1444 pub(crate) syntax: SyntaxNode,
1230} 1445}
1446impl std::fmt::Display for BreakExpr {
1447 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1448 std::fmt::Display::fmt(self.syntax(), f)
1449 }
1450}
1231impl AstNode for BreakExpr { 1451impl AstNode for BreakExpr {
1232 fn can_cast(kind: SyntaxKind) -> bool { 1452 fn can_cast(kind: SyntaxKind) -> bool {
1233 match kind { 1453 match kind {
@@ -1255,6 +1475,11 @@ impl BreakExpr {
1255pub struct Label { 1475pub struct Label {
1256 pub(crate) syntax: SyntaxNode, 1476 pub(crate) syntax: SyntaxNode,
1257} 1477}
1478impl std::fmt::Display for Label {
1479 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1480 std::fmt::Display::fmt(self.syntax(), f)
1481 }
1482}
1258impl AstNode for Label { 1483impl AstNode for Label {
1259 fn can_cast(kind: SyntaxKind) -> bool { 1484 fn can_cast(kind: SyntaxKind) -> bool {
1260 match kind { 1485 match kind {
@@ -1278,6 +1503,11 @@ impl Label {}
1278pub struct BlockExpr { 1503pub struct BlockExpr {
1279 pub(crate) syntax: SyntaxNode, 1504 pub(crate) syntax: SyntaxNode,
1280} 1505}
1506impl std::fmt::Display for BlockExpr {
1507 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1508 std::fmt::Display::fmt(self.syntax(), f)
1509 }
1510}
1281impl AstNode for BlockExpr { 1511impl AstNode for BlockExpr {
1282 fn can_cast(kind: SyntaxKind) -> bool { 1512 fn can_cast(kind: SyntaxKind) -> bool {
1283 match kind { 1513 match kind {
@@ -1305,6 +1535,11 @@ impl BlockExpr {
1305pub struct ReturnExpr { 1535pub struct ReturnExpr {
1306 pub(crate) syntax: SyntaxNode, 1536 pub(crate) syntax: SyntaxNode,
1307} 1537}
1538impl std::fmt::Display for ReturnExpr {
1539 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1540 std::fmt::Display::fmt(self.syntax(), f)
1541 }
1542}
1308impl AstNode for ReturnExpr { 1543impl AstNode for ReturnExpr {
1309 fn can_cast(kind: SyntaxKind) -> bool { 1544 fn can_cast(kind: SyntaxKind) -> bool {
1310 match kind { 1545 match kind {
@@ -1332,6 +1567,11 @@ impl ReturnExpr {
1332pub struct CallExpr { 1567pub struct CallExpr {
1333 pub(crate) syntax: SyntaxNode, 1568 pub(crate) syntax: SyntaxNode,
1334} 1569}
1570impl std::fmt::Display for CallExpr {
1571 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1572 std::fmt::Display::fmt(self.syntax(), f)
1573 }
1574}
1335impl AstNode for CallExpr { 1575impl AstNode for CallExpr {
1336 fn can_cast(kind: SyntaxKind) -> bool { 1576 fn can_cast(kind: SyntaxKind) -> bool {
1337 match kind { 1577 match kind {
@@ -1360,6 +1600,11 @@ impl CallExpr {
1360pub struct MethodCallExpr { 1600pub struct MethodCallExpr {
1361 pub(crate) syntax: SyntaxNode, 1601 pub(crate) syntax: SyntaxNode,
1362} 1602}
1603impl std::fmt::Display for MethodCallExpr {
1604 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1605 std::fmt::Display::fmt(self.syntax(), f)
1606 }
1607}
1363impl AstNode for MethodCallExpr { 1608impl AstNode for MethodCallExpr {
1364 fn can_cast(kind: SyntaxKind) -> bool { 1609 fn can_cast(kind: SyntaxKind) -> bool {
1365 match kind { 1610 match kind {
@@ -1394,6 +1639,11 @@ impl MethodCallExpr {
1394pub struct IndexExpr { 1639pub struct IndexExpr {
1395 pub(crate) syntax: SyntaxNode, 1640 pub(crate) syntax: SyntaxNode,
1396} 1641}
1642impl std::fmt::Display for IndexExpr {
1643 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1644 std::fmt::Display::fmt(self.syntax(), f)
1645 }
1646}
1397impl AstNode for IndexExpr { 1647impl AstNode for IndexExpr {
1398 fn can_cast(kind: SyntaxKind) -> bool { 1648 fn can_cast(kind: SyntaxKind) -> bool {
1399 match kind { 1649 match kind {
@@ -1417,6 +1667,11 @@ impl IndexExpr {}
1417pub struct FieldExpr { 1667pub struct FieldExpr {
1418 pub(crate) syntax: SyntaxNode, 1668 pub(crate) syntax: SyntaxNode,
1419} 1669}
1670impl std::fmt::Display for FieldExpr {
1671 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1672 std::fmt::Display::fmt(self.syntax(), f)
1673 }
1674}
1420impl AstNode for FieldExpr { 1675impl AstNode for FieldExpr {
1421 fn can_cast(kind: SyntaxKind) -> bool { 1676 fn can_cast(kind: SyntaxKind) -> bool {
1422 match kind { 1677 match kind {
@@ -1447,6 +1702,11 @@ impl FieldExpr {
1447pub struct AwaitExpr { 1702pub struct AwaitExpr {
1448 pub(crate) syntax: SyntaxNode, 1703 pub(crate) syntax: SyntaxNode,
1449} 1704}
1705impl std::fmt::Display for AwaitExpr {
1706 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1707 std::fmt::Display::fmt(self.syntax(), f)
1708 }
1709}
1450impl AstNode for AwaitExpr { 1710impl AstNode for AwaitExpr {
1451 fn can_cast(kind: SyntaxKind) -> bool { 1711 fn can_cast(kind: SyntaxKind) -> bool {
1452 match kind { 1712 match kind {
@@ -1474,6 +1734,11 @@ impl AwaitExpr {
1474pub struct TryExpr { 1734pub struct TryExpr {
1475 pub(crate) syntax: SyntaxNode, 1735 pub(crate) syntax: SyntaxNode,
1476} 1736}
1737impl std::fmt::Display for TryExpr {
1738 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1739 std::fmt::Display::fmt(self.syntax(), f)
1740 }
1741}
1477impl AstNode for TryExpr { 1742impl AstNode for TryExpr {
1478 fn can_cast(kind: SyntaxKind) -> bool { 1743 fn can_cast(kind: SyntaxKind) -> bool {
1479 match kind { 1744 match kind {
@@ -1501,6 +1766,11 @@ impl TryExpr {
1501pub struct CastExpr { 1766pub struct CastExpr {
1502 pub(crate) syntax: SyntaxNode, 1767 pub(crate) syntax: SyntaxNode,
1503} 1768}
1769impl std::fmt::Display for CastExpr {
1770 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1771 std::fmt::Display::fmt(self.syntax(), f)
1772 }
1773}
1504impl AstNode for CastExpr { 1774impl AstNode for CastExpr {
1505 fn can_cast(kind: SyntaxKind) -> bool { 1775 fn can_cast(kind: SyntaxKind) -> bool {
1506 match kind { 1776 match kind {
@@ -1531,6 +1801,11 @@ impl CastExpr {
1531pub struct RefExpr { 1801pub struct RefExpr {
1532 pub(crate) syntax: SyntaxNode, 1802 pub(crate) syntax: SyntaxNode,
1533} 1803}
1804impl std::fmt::Display for RefExpr {
1805 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1806 std::fmt::Display::fmt(self.syntax(), f)
1807 }
1808}
1534impl AstNode for RefExpr { 1809impl AstNode for RefExpr {
1535 fn can_cast(kind: SyntaxKind) -> bool { 1810 fn can_cast(kind: SyntaxKind) -> bool {
1536 match kind { 1811 match kind {
@@ -1558,6 +1833,11 @@ impl RefExpr {
1558pub struct PrefixExpr { 1833pub struct PrefixExpr {
1559 pub(crate) syntax: SyntaxNode, 1834 pub(crate) syntax: SyntaxNode,
1560} 1835}
1836impl std::fmt::Display for PrefixExpr {
1837 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1838 std::fmt::Display::fmt(self.syntax(), f)
1839 }
1840}
1561impl AstNode for PrefixExpr { 1841impl AstNode for PrefixExpr {
1562 fn can_cast(kind: SyntaxKind) -> bool { 1842 fn can_cast(kind: SyntaxKind) -> bool {
1563 match kind { 1843 match kind {
@@ -1585,6 +1865,11 @@ impl PrefixExpr {
1585pub struct BoxExpr { 1865pub struct BoxExpr {
1586 pub(crate) syntax: SyntaxNode, 1866 pub(crate) syntax: SyntaxNode,
1587} 1867}
1868impl std::fmt::Display for BoxExpr {
1869 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1870 std::fmt::Display::fmt(self.syntax(), f)
1871 }
1872}
1588impl AstNode for BoxExpr { 1873impl AstNode for BoxExpr {
1589 fn can_cast(kind: SyntaxKind) -> bool { 1874 fn can_cast(kind: SyntaxKind) -> bool {
1590 match kind { 1875 match kind {
@@ -1612,6 +1897,11 @@ impl BoxExpr {
1612pub struct RangeExpr { 1897pub struct RangeExpr {
1613 pub(crate) syntax: SyntaxNode, 1898 pub(crate) syntax: SyntaxNode,
1614} 1899}
1900impl std::fmt::Display for RangeExpr {
1901 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1902 std::fmt::Display::fmt(self.syntax(), f)
1903 }
1904}
1615impl AstNode for RangeExpr { 1905impl AstNode for RangeExpr {
1616 fn can_cast(kind: SyntaxKind) -> bool { 1906 fn can_cast(kind: SyntaxKind) -> bool {
1617 match kind { 1907 match kind {
@@ -1635,6 +1925,11 @@ impl RangeExpr {}
1635pub struct BinExpr { 1925pub struct BinExpr {
1636 pub(crate) syntax: SyntaxNode, 1926 pub(crate) syntax: SyntaxNode,
1637} 1927}
1928impl std::fmt::Display for BinExpr {
1929 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1930 std::fmt::Display::fmt(self.syntax(), f)
1931 }
1932}
1638impl AstNode for BinExpr { 1933impl AstNode for BinExpr {
1639 fn can_cast(kind: SyntaxKind) -> bool { 1934 fn can_cast(kind: SyntaxKind) -> bool {
1640 match kind { 1935 match kind {
@@ -1658,6 +1953,11 @@ impl BinExpr {}
1658pub struct Literal { 1953pub struct Literal {
1659 pub(crate) syntax: SyntaxNode, 1954 pub(crate) syntax: SyntaxNode,
1660} 1955}
1956impl std::fmt::Display for Literal {
1957 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1958 std::fmt::Display::fmt(self.syntax(), f)
1959 }
1960}
1661impl AstNode for Literal { 1961impl AstNode for Literal {
1662 fn can_cast(kind: SyntaxKind) -> bool { 1962 fn can_cast(kind: SyntaxKind) -> bool {
1663 match kind { 1963 match kind {
@@ -1681,6 +1981,11 @@ impl Literal {}
1681pub struct MatchExpr { 1981pub struct MatchExpr {
1682 pub(crate) syntax: SyntaxNode, 1982 pub(crate) syntax: SyntaxNode,
1683} 1983}
1984impl std::fmt::Display for MatchExpr {
1985 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1986 std::fmt::Display::fmt(self.syntax(), f)
1987 }
1988}
1684impl AstNode for MatchExpr { 1989impl AstNode for MatchExpr {
1685 fn can_cast(kind: SyntaxKind) -> bool { 1990 fn can_cast(kind: SyntaxKind) -> bool {
1686 match kind { 1991 match kind {
@@ -1711,6 +2016,11 @@ impl MatchExpr {
1711pub struct MatchArmList { 2016pub struct MatchArmList {
1712 pub(crate) syntax: SyntaxNode, 2017 pub(crate) syntax: SyntaxNode,
1713} 2018}
2019impl std::fmt::Display for MatchArmList {
2020 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2021 std::fmt::Display::fmt(self.syntax(), f)
2022 }
2023}
1714impl AstNode for MatchArmList { 2024impl AstNode for MatchArmList {
1715 fn can_cast(kind: SyntaxKind) -> bool { 2025 fn can_cast(kind: SyntaxKind) -> bool {
1716 match kind { 2026 match kind {
@@ -1739,6 +2049,11 @@ impl MatchArmList {
1739pub struct MatchArm { 2049pub struct MatchArm {
1740 pub(crate) syntax: SyntaxNode, 2050 pub(crate) syntax: SyntaxNode,
1741} 2051}
2052impl std::fmt::Display for MatchArm {
2053 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2054 std::fmt::Display::fmt(self.syntax(), f)
2055 }
2056}
1742impl AstNode for MatchArm { 2057impl AstNode for MatchArm {
1743 fn can_cast(kind: SyntaxKind) -> bool { 2058 fn can_cast(kind: SyntaxKind) -> bool {
1744 match kind { 2059 match kind {
@@ -1773,6 +2088,11 @@ impl MatchArm {
1773pub struct MatchGuard { 2088pub struct MatchGuard {
1774 pub(crate) syntax: SyntaxNode, 2089 pub(crate) syntax: SyntaxNode,
1775} 2090}
2091impl std::fmt::Display for MatchGuard {
2092 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2093 std::fmt::Display::fmt(self.syntax(), f)
2094 }
2095}
1776impl AstNode for MatchGuard { 2096impl AstNode for MatchGuard {
1777 fn can_cast(kind: SyntaxKind) -> bool { 2097 fn can_cast(kind: SyntaxKind) -> bool {
1778 match kind { 2098 match kind {
@@ -1800,6 +2120,11 @@ impl MatchGuard {
1800pub struct RecordLit { 2120pub struct RecordLit {
1801 pub(crate) syntax: SyntaxNode, 2121 pub(crate) syntax: SyntaxNode,
1802} 2122}
2123impl std::fmt::Display for RecordLit {
2124 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2125 std::fmt::Display::fmt(self.syntax(), f)
2126 }
2127}
1803impl AstNode for RecordLit { 2128impl AstNode for RecordLit {
1804 fn can_cast(kind: SyntaxKind) -> bool { 2129 fn can_cast(kind: SyntaxKind) -> bool {
1805 match kind { 2130 match kind {
@@ -1830,6 +2155,11 @@ impl RecordLit {
1830pub struct RecordFieldList { 2155pub struct RecordFieldList {
1831 pub(crate) syntax: SyntaxNode, 2156 pub(crate) syntax: SyntaxNode,
1832} 2157}
2158impl std::fmt::Display for RecordFieldList {
2159 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2160 std::fmt::Display::fmt(self.syntax(), f)
2161 }
2162}
1833impl AstNode for RecordFieldList { 2163impl AstNode for RecordFieldList {
1834 fn can_cast(kind: SyntaxKind) -> bool { 2164 fn can_cast(kind: SyntaxKind) -> bool {
1835 match kind { 2165 match kind {
@@ -1860,6 +2190,11 @@ impl RecordFieldList {
1860pub struct RecordField { 2190pub struct RecordField {
1861 pub(crate) syntax: SyntaxNode, 2191 pub(crate) syntax: SyntaxNode,
1862} 2192}
2193impl std::fmt::Display for RecordField {
2194 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2195 std::fmt::Display::fmt(self.syntax(), f)
2196 }
2197}
1863impl AstNode for RecordField { 2198impl AstNode for RecordField {
1864 fn can_cast(kind: SyntaxKind) -> bool { 2199 fn can_cast(kind: SyntaxKind) -> bool {
1865 match kind { 2200 match kind {
@@ -1890,6 +2225,11 @@ impl RecordField {
1890pub struct OrPat { 2225pub struct OrPat {
1891 pub(crate) syntax: SyntaxNode, 2226 pub(crate) syntax: SyntaxNode,
1892} 2227}
2228impl std::fmt::Display for OrPat {
2229 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2230 std::fmt::Display::fmt(self.syntax(), f)
2231 }
2232}
1893impl AstNode for OrPat { 2233impl AstNode for OrPat {
1894 fn can_cast(kind: SyntaxKind) -> bool { 2234 fn can_cast(kind: SyntaxKind) -> bool {
1895 match kind { 2235 match kind {
@@ -1917,6 +2257,11 @@ impl OrPat {
1917pub struct ParenPat { 2257pub struct ParenPat {
1918 pub(crate) syntax: SyntaxNode, 2258 pub(crate) syntax: SyntaxNode,
1919} 2259}
2260impl std::fmt::Display for ParenPat {
2261 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2262 std::fmt::Display::fmt(self.syntax(), f)
2263 }
2264}
1920impl AstNode for ParenPat { 2265impl AstNode for ParenPat {
1921 fn can_cast(kind: SyntaxKind) -> bool { 2266 fn can_cast(kind: SyntaxKind) -> bool {
1922 match kind { 2267 match kind {
@@ -1944,6 +2289,11 @@ impl ParenPat {
1944pub struct RefPat { 2289pub struct RefPat {
1945 pub(crate) syntax: SyntaxNode, 2290 pub(crate) syntax: SyntaxNode,
1946} 2291}
2292impl std::fmt::Display for RefPat {
2293 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2294 std::fmt::Display::fmt(self.syntax(), f)
2295 }
2296}
1947impl AstNode for RefPat { 2297impl AstNode for RefPat {
1948 fn can_cast(kind: SyntaxKind) -> bool { 2298 fn can_cast(kind: SyntaxKind) -> bool {
1949 match kind { 2299 match kind {
@@ -1971,6 +2321,11 @@ impl RefPat {
1971pub struct BoxPat { 2321pub struct BoxPat {
1972 pub(crate) syntax: SyntaxNode, 2322 pub(crate) syntax: SyntaxNode,
1973} 2323}
2324impl std::fmt::Display for BoxPat {
2325 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2326 std::fmt::Display::fmt(self.syntax(), f)
2327 }
2328}
1974impl AstNode for BoxPat { 2329impl AstNode for BoxPat {
1975 fn can_cast(kind: SyntaxKind) -> bool { 2330 fn can_cast(kind: SyntaxKind) -> bool {
1976 match kind { 2331 match kind {
@@ -1998,6 +2353,11 @@ impl BoxPat {
1998pub struct BindPat { 2353pub struct BindPat {
1999 pub(crate) syntax: SyntaxNode, 2354 pub(crate) syntax: SyntaxNode,
2000} 2355}
2356impl std::fmt::Display for BindPat {
2357 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2358 std::fmt::Display::fmt(self.syntax(), f)
2359 }
2360}
2001impl AstNode for BindPat { 2361impl AstNode for BindPat {
2002 fn can_cast(kind: SyntaxKind) -> bool { 2362 fn can_cast(kind: SyntaxKind) -> bool {
2003 match kind { 2363 match kind {
@@ -2026,6 +2386,11 @@ impl BindPat {
2026pub struct PlaceholderPat { 2386pub struct PlaceholderPat {
2027 pub(crate) syntax: SyntaxNode, 2387 pub(crate) syntax: SyntaxNode,
2028} 2388}
2389impl std::fmt::Display for PlaceholderPat {
2390 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2391 std::fmt::Display::fmt(self.syntax(), f)
2392 }
2393}
2029impl AstNode for PlaceholderPat { 2394impl AstNode for PlaceholderPat {
2030 fn can_cast(kind: SyntaxKind) -> bool { 2395 fn can_cast(kind: SyntaxKind) -> bool {
2031 match kind { 2396 match kind {
@@ -2049,6 +2414,11 @@ impl PlaceholderPat {}
2049pub struct DotDotPat { 2414pub struct DotDotPat {
2050 pub(crate) syntax: SyntaxNode, 2415 pub(crate) syntax: SyntaxNode,
2051} 2416}
2417impl std::fmt::Display for DotDotPat {
2418 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2419 std::fmt::Display::fmt(self.syntax(), f)
2420 }
2421}
2052impl AstNode for DotDotPat { 2422impl AstNode for DotDotPat {
2053 fn can_cast(kind: SyntaxKind) -> bool { 2423 fn can_cast(kind: SyntaxKind) -> bool {
2054 match kind { 2424 match kind {
@@ -2072,6 +2442,11 @@ impl DotDotPat {}
2072pub struct PathPat { 2442pub struct PathPat {
2073 pub(crate) syntax: SyntaxNode, 2443 pub(crate) syntax: SyntaxNode,
2074} 2444}
2445impl std::fmt::Display for PathPat {
2446 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2447 std::fmt::Display::fmt(self.syntax(), f)
2448 }
2449}
2075impl AstNode for PathPat { 2450impl AstNode for PathPat {
2076 fn can_cast(kind: SyntaxKind) -> bool { 2451 fn can_cast(kind: SyntaxKind) -> bool {
2077 match kind { 2452 match kind {
@@ -2099,6 +2474,11 @@ impl PathPat {
2099pub struct SlicePat { 2474pub struct SlicePat {
2100 pub(crate) syntax: SyntaxNode, 2475 pub(crate) syntax: SyntaxNode,
2101} 2476}
2477impl std::fmt::Display for SlicePat {
2478 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2479 std::fmt::Display::fmt(self.syntax(), f)
2480 }
2481}
2102impl AstNode for SlicePat { 2482impl AstNode for SlicePat {
2103 fn can_cast(kind: SyntaxKind) -> bool { 2483 fn can_cast(kind: SyntaxKind) -> bool {
2104 match kind { 2484 match kind {
@@ -2126,6 +2506,11 @@ impl SlicePat {
2126pub struct RangePat { 2506pub struct RangePat {
2127 pub(crate) syntax: SyntaxNode, 2507 pub(crate) syntax: SyntaxNode,
2128} 2508}
2509impl std::fmt::Display for RangePat {
2510 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2511 std::fmt::Display::fmt(self.syntax(), f)
2512 }
2513}
2129impl AstNode for RangePat { 2514impl AstNode for RangePat {
2130 fn can_cast(kind: SyntaxKind) -> bool { 2515 fn can_cast(kind: SyntaxKind) -> bool {
2131 match kind { 2516 match kind {
@@ -2149,6 +2534,11 @@ impl RangePat {}
2149pub struct LiteralPat { 2534pub struct LiteralPat {
2150 pub(crate) syntax: SyntaxNode, 2535 pub(crate) syntax: SyntaxNode,
2151} 2536}
2537impl std::fmt::Display for LiteralPat {
2538 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2539 std::fmt::Display::fmt(self.syntax(), f)
2540 }
2541}
2152impl AstNode for LiteralPat { 2542impl AstNode for LiteralPat {
2153 fn can_cast(kind: SyntaxKind) -> bool { 2543 fn can_cast(kind: SyntaxKind) -> bool {
2154 match kind { 2544 match kind {
@@ -2176,6 +2566,11 @@ impl LiteralPat {
2176pub struct RecordPat { 2566pub struct RecordPat {
2177 pub(crate) syntax: SyntaxNode, 2567 pub(crate) syntax: SyntaxNode,
2178} 2568}
2569impl std::fmt::Display for RecordPat {
2570 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2571 std::fmt::Display::fmt(self.syntax(), f)
2572 }
2573}
2179impl AstNode for RecordPat { 2574impl AstNode for RecordPat {
2180 fn can_cast(kind: SyntaxKind) -> bool { 2575 fn can_cast(kind: SyntaxKind) -> bool {
2181 match kind { 2576 match kind {
@@ -2206,6 +2601,11 @@ impl RecordPat {
2206pub struct RecordFieldPatList { 2601pub struct RecordFieldPatList {
2207 pub(crate) syntax: SyntaxNode, 2602 pub(crate) syntax: SyntaxNode,
2208} 2603}
2604impl std::fmt::Display for RecordFieldPatList {
2605 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2606 std::fmt::Display::fmt(self.syntax(), f)
2607 }
2608}
2209impl AstNode for RecordFieldPatList { 2609impl AstNode for RecordFieldPatList {
2210 fn can_cast(kind: SyntaxKind) -> bool { 2610 fn can_cast(kind: SyntaxKind) -> bool {
2211 match kind { 2611 match kind {
@@ -2236,6 +2636,11 @@ impl RecordFieldPatList {
2236pub struct RecordFieldPat { 2636pub struct RecordFieldPat {
2237 pub(crate) syntax: SyntaxNode, 2637 pub(crate) syntax: SyntaxNode,
2238} 2638}
2639impl std::fmt::Display for RecordFieldPat {
2640 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2641 std::fmt::Display::fmt(self.syntax(), f)
2642 }
2643}
2239impl AstNode for RecordFieldPat { 2644impl AstNode for RecordFieldPat {
2240 fn can_cast(kind: SyntaxKind) -> bool { 2645 fn can_cast(kind: SyntaxKind) -> bool {
2241 match kind { 2646 match kind {
@@ -2264,6 +2669,11 @@ impl RecordFieldPat {
2264pub struct TupleStructPat { 2669pub struct TupleStructPat {
2265 pub(crate) syntax: SyntaxNode, 2670 pub(crate) syntax: SyntaxNode,
2266} 2671}
2672impl std::fmt::Display for TupleStructPat {
2673 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2674 std::fmt::Display::fmt(self.syntax(), f)
2675 }
2676}
2267impl AstNode for TupleStructPat { 2677impl AstNode for TupleStructPat {
2268 fn can_cast(kind: SyntaxKind) -> bool { 2678 fn can_cast(kind: SyntaxKind) -> bool {
2269 match kind { 2679 match kind {
@@ -2294,6 +2704,11 @@ impl TupleStructPat {
2294pub struct TuplePat { 2704pub struct TuplePat {
2295 pub(crate) syntax: SyntaxNode, 2705 pub(crate) syntax: SyntaxNode,
2296} 2706}
2707impl std::fmt::Display for TuplePat {
2708 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2709 std::fmt::Display::fmt(self.syntax(), f)
2710 }
2711}
2297impl AstNode for TuplePat { 2712impl AstNode for TuplePat {
2298 fn can_cast(kind: SyntaxKind) -> bool { 2713 fn can_cast(kind: SyntaxKind) -> bool {
2299 match kind { 2714 match kind {
@@ -2321,6 +2736,11 @@ impl TuplePat {
2321pub struct Visibility { 2736pub struct Visibility {
2322 pub(crate) syntax: SyntaxNode, 2737 pub(crate) syntax: SyntaxNode,
2323} 2738}
2739impl std::fmt::Display for Visibility {
2740 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2741 std::fmt::Display::fmt(self.syntax(), f)
2742 }
2743}
2324impl AstNode for Visibility { 2744impl AstNode for Visibility {
2325 fn can_cast(kind: SyntaxKind) -> bool { 2745 fn can_cast(kind: SyntaxKind) -> bool {
2326 match kind { 2746 match kind {
@@ -2344,6 +2764,11 @@ impl Visibility {}
2344pub struct Name { 2764pub struct Name {
2345 pub(crate) syntax: SyntaxNode, 2765 pub(crate) syntax: SyntaxNode,
2346} 2766}
2767impl std::fmt::Display for Name {
2768 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2769 std::fmt::Display::fmt(self.syntax(), f)
2770 }
2771}
2347impl AstNode for Name { 2772impl AstNode for Name {
2348 fn can_cast(kind: SyntaxKind) -> bool { 2773 fn can_cast(kind: SyntaxKind) -> bool {
2349 match kind { 2774 match kind {
@@ -2367,6 +2792,11 @@ impl Name {}
2367pub struct NameRef { 2792pub struct NameRef {
2368 pub(crate) syntax: SyntaxNode, 2793 pub(crate) syntax: SyntaxNode,
2369} 2794}
2795impl std::fmt::Display for NameRef {
2796 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2797 std::fmt::Display::fmt(self.syntax(), f)
2798 }
2799}
2370impl AstNode for NameRef { 2800impl AstNode for NameRef {
2371 fn can_cast(kind: SyntaxKind) -> bool { 2801 fn can_cast(kind: SyntaxKind) -> bool {
2372 match kind { 2802 match kind {
@@ -2390,6 +2820,11 @@ impl NameRef {}
2390pub struct MacroCall { 2820pub struct MacroCall {
2391 pub(crate) syntax: SyntaxNode, 2821 pub(crate) syntax: SyntaxNode,
2392} 2822}
2823impl std::fmt::Display for MacroCall {
2824 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2825 std::fmt::Display::fmt(self.syntax(), f)
2826 }
2827}
2393impl AstNode for MacroCall { 2828impl AstNode for MacroCall {
2394 fn can_cast(kind: SyntaxKind) -> bool { 2829 fn can_cast(kind: SyntaxKind) -> bool {
2395 match kind { 2830 match kind {
@@ -2423,6 +2858,11 @@ impl MacroCall {
2423pub struct Attr { 2858pub struct Attr {
2424 pub(crate) syntax: SyntaxNode, 2859 pub(crate) syntax: SyntaxNode,
2425} 2860}
2861impl std::fmt::Display for Attr {
2862 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2863 std::fmt::Display::fmt(self.syntax(), f)
2864 }
2865}
2426impl AstNode for Attr { 2866impl AstNode for Attr {
2427 fn can_cast(kind: SyntaxKind) -> bool { 2867 fn can_cast(kind: SyntaxKind) -> bool {
2428 match kind { 2868 match kind {
@@ -2453,6 +2893,11 @@ impl Attr {
2453pub struct TokenTree { 2893pub struct TokenTree {
2454 pub(crate) syntax: SyntaxNode, 2894 pub(crate) syntax: SyntaxNode,
2455} 2895}
2896impl std::fmt::Display for TokenTree {
2897 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2898 std::fmt::Display::fmt(self.syntax(), f)
2899 }
2900}
2456impl AstNode for TokenTree { 2901impl AstNode for TokenTree {
2457 fn can_cast(kind: SyntaxKind) -> bool { 2902 fn can_cast(kind: SyntaxKind) -> bool {
2458 match kind { 2903 match kind {
@@ -2476,6 +2921,11 @@ impl TokenTree {}
2476pub struct TypeParamList { 2921pub struct TypeParamList {
2477 pub(crate) syntax: SyntaxNode, 2922 pub(crate) syntax: SyntaxNode,
2478} 2923}
2924impl std::fmt::Display for TypeParamList {
2925 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2926 std::fmt::Display::fmt(self.syntax(), f)
2927 }
2928}
2479impl AstNode for TypeParamList { 2929impl AstNode for TypeParamList {
2480 fn can_cast(kind: SyntaxKind) -> bool { 2930 fn can_cast(kind: SyntaxKind) -> bool {
2481 match kind { 2931 match kind {
@@ -2506,6 +2956,11 @@ impl TypeParamList {
2506pub struct TypeParam { 2956pub struct TypeParam {
2507 pub(crate) syntax: SyntaxNode, 2957 pub(crate) syntax: SyntaxNode,
2508} 2958}
2959impl std::fmt::Display for TypeParam {
2960 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2961 std::fmt::Display::fmt(self.syntax(), f)
2962 }
2963}
2509impl AstNode for TypeParam { 2964impl AstNode for TypeParam {
2510 fn can_cast(kind: SyntaxKind) -> bool { 2965 fn can_cast(kind: SyntaxKind) -> bool {
2511 match kind { 2966 match kind {
@@ -2536,6 +2991,11 @@ impl TypeParam {
2536pub struct ConstParam { 2991pub struct ConstParam {
2537 pub(crate) syntax: SyntaxNode, 2992 pub(crate) syntax: SyntaxNode,
2538} 2993}
2994impl std::fmt::Display for ConstParam {
2995 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2996 std::fmt::Display::fmt(self.syntax(), f)
2997 }
2998}
2539impl AstNode for ConstParam { 2999impl AstNode for ConstParam {
2540 fn can_cast(kind: SyntaxKind) -> bool { 3000 fn can_cast(kind: SyntaxKind) -> bool {
2541 match kind { 3001 match kind {
@@ -2566,6 +3026,11 @@ impl ConstParam {
2566pub struct LifetimeParam { 3026pub struct LifetimeParam {
2567 pub(crate) syntax: SyntaxNode, 3027 pub(crate) syntax: SyntaxNode,
2568} 3028}
3029impl std::fmt::Display for LifetimeParam {
3030 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3031 std::fmt::Display::fmt(self.syntax(), f)
3032 }
3033}
2569impl AstNode for LifetimeParam { 3034impl AstNode for LifetimeParam {
2570 fn can_cast(kind: SyntaxKind) -> bool { 3035 fn can_cast(kind: SyntaxKind) -> bool {
2571 match kind { 3036 match kind {
@@ -2590,6 +3055,11 @@ impl LifetimeParam {}
2590pub struct TypeBound { 3055pub struct TypeBound {
2591 pub(crate) syntax: SyntaxNode, 3056 pub(crate) syntax: SyntaxNode,
2592} 3057}
3058impl std::fmt::Display for TypeBound {
3059 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3060 std::fmt::Display::fmt(self.syntax(), f)
3061 }
3062}
2593impl AstNode for TypeBound { 3063impl AstNode for TypeBound {
2594 fn can_cast(kind: SyntaxKind) -> bool { 3064 fn can_cast(kind: SyntaxKind) -> bool {
2595 match kind { 3065 match kind {
@@ -2617,6 +3087,11 @@ impl TypeBound {
2617pub struct TypeBoundList { 3087pub struct TypeBoundList {
2618 pub(crate) syntax: SyntaxNode, 3088 pub(crate) syntax: SyntaxNode,
2619} 3089}
3090impl std::fmt::Display for TypeBoundList {
3091 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3092 std::fmt::Display::fmt(self.syntax(), f)
3093 }
3094}
2620impl AstNode for TypeBoundList { 3095impl AstNode for TypeBoundList {
2621 fn can_cast(kind: SyntaxKind) -> bool { 3096 fn can_cast(kind: SyntaxKind) -> bool {
2622 match kind { 3097 match kind {
@@ -2644,6 +3119,11 @@ impl TypeBoundList {
2644pub struct WherePred { 3119pub struct WherePred {
2645 pub(crate) syntax: SyntaxNode, 3120 pub(crate) syntax: SyntaxNode,
2646} 3121}
3122impl std::fmt::Display for WherePred {
3123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3124 std::fmt::Display::fmt(self.syntax(), f)
3125 }
3126}
2647impl AstNode for WherePred { 3127impl AstNode for WherePred {
2648 fn can_cast(kind: SyntaxKind) -> bool { 3128 fn can_cast(kind: SyntaxKind) -> bool {
2649 match kind { 3129 match kind {
@@ -2672,6 +3152,11 @@ impl WherePred {
2672pub struct WhereClause { 3152pub struct WhereClause {
2673 pub(crate) syntax: SyntaxNode, 3153 pub(crate) syntax: SyntaxNode,
2674} 3154}
3155impl std::fmt::Display for WhereClause {
3156 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3157 std::fmt::Display::fmt(self.syntax(), f)
3158 }
3159}
2675impl AstNode for WhereClause { 3160impl AstNode for WhereClause {
2676 fn can_cast(kind: SyntaxKind) -> bool { 3161 fn can_cast(kind: SyntaxKind) -> bool {
2677 match kind { 3162 match kind {
@@ -2699,6 +3184,11 @@ impl WhereClause {
2699pub struct ExprStmt { 3184pub struct ExprStmt {
2700 pub(crate) syntax: SyntaxNode, 3185 pub(crate) syntax: SyntaxNode,
2701} 3186}
3187impl std::fmt::Display for ExprStmt {
3188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3189 std::fmt::Display::fmt(self.syntax(), f)
3190 }
3191}
2702impl AstNode for ExprStmt { 3192impl AstNode for ExprStmt {
2703 fn can_cast(kind: SyntaxKind) -> bool { 3193 fn can_cast(kind: SyntaxKind) -> bool {
2704 match kind { 3194 match kind {
@@ -2726,6 +3216,11 @@ impl ExprStmt {
2726pub struct LetStmt { 3216pub struct LetStmt {
2727 pub(crate) syntax: SyntaxNode, 3217 pub(crate) syntax: SyntaxNode,
2728} 3218}
3219impl std::fmt::Display for LetStmt {
3220 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3221 std::fmt::Display::fmt(self.syntax(), f)
3222 }
3223}
2729impl AstNode for LetStmt { 3224impl AstNode for LetStmt {
2730 fn can_cast(kind: SyntaxKind) -> bool { 3225 fn can_cast(kind: SyntaxKind) -> bool {
2731 match kind { 3226 match kind {
@@ -2757,6 +3252,11 @@ impl LetStmt {
2757pub struct Condition { 3252pub struct Condition {
2758 pub(crate) syntax: SyntaxNode, 3253 pub(crate) syntax: SyntaxNode,
2759} 3254}
3255impl std::fmt::Display for Condition {
3256 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3257 std::fmt::Display::fmt(self.syntax(), f)
3258 }
3259}
2760impl AstNode for Condition { 3260impl AstNode for Condition {
2761 fn can_cast(kind: SyntaxKind) -> bool { 3261 fn can_cast(kind: SyntaxKind) -> bool {
2762 match kind { 3262 match kind {
@@ -2787,6 +3287,11 @@ impl Condition {
2787pub struct Block { 3287pub struct Block {
2788 pub(crate) syntax: SyntaxNode, 3288 pub(crate) syntax: SyntaxNode,
2789} 3289}
3290impl std::fmt::Display for Block {
3291 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3292 std::fmt::Display::fmt(self.syntax(), f)
3293 }
3294}
2790impl AstNode for Block { 3295impl AstNode for Block {
2791 fn can_cast(kind: SyntaxKind) -> bool { 3296 fn can_cast(kind: SyntaxKind) -> bool {
2792 match kind { 3297 match kind {
@@ -2819,6 +3324,11 @@ impl Block {
2819pub struct ParamList { 3324pub struct ParamList {
2820 pub(crate) syntax: SyntaxNode, 3325 pub(crate) syntax: SyntaxNode,
2821} 3326}
3327impl std::fmt::Display for ParamList {
3328 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3329 std::fmt::Display::fmt(self.syntax(), f)
3330 }
3331}
2822impl AstNode for ParamList { 3332impl AstNode for ParamList {
2823 fn can_cast(kind: SyntaxKind) -> bool { 3333 fn can_cast(kind: SyntaxKind) -> bool {
2824 match kind { 3334 match kind {
@@ -2849,6 +3359,11 @@ impl ParamList {
2849pub struct SelfParam { 3359pub struct SelfParam {
2850 pub(crate) syntax: SyntaxNode, 3360 pub(crate) syntax: SyntaxNode,
2851} 3361}
3362impl std::fmt::Display for SelfParam {
3363 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3364 std::fmt::Display::fmt(self.syntax(), f)
3365 }
3366}
2852impl AstNode for SelfParam { 3367impl AstNode for SelfParam {
2853 fn can_cast(kind: SyntaxKind) -> bool { 3368 fn can_cast(kind: SyntaxKind) -> bool {
2854 match kind { 3369 match kind {
@@ -2874,6 +3389,11 @@ impl SelfParam {}
2874pub struct Param { 3389pub struct Param {
2875 pub(crate) syntax: SyntaxNode, 3390 pub(crate) syntax: SyntaxNode,
2876} 3391}
3392impl std::fmt::Display for Param {
3393 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3394 std::fmt::Display::fmt(self.syntax(), f)
3395 }
3396}
2877impl AstNode for Param { 3397impl AstNode for Param {
2878 fn can_cast(kind: SyntaxKind) -> bool { 3398 fn can_cast(kind: SyntaxKind) -> bool {
2879 match kind { 3399 match kind {
@@ -2903,6 +3423,11 @@ impl Param {
2903pub struct UseItem { 3423pub struct UseItem {
2904 pub(crate) syntax: SyntaxNode, 3424 pub(crate) syntax: SyntaxNode,
2905} 3425}
3426impl std::fmt::Display for UseItem {
3427 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3428 std::fmt::Display::fmt(self.syntax(), f)
3429 }
3430}
2906impl AstNode for UseItem { 3431impl AstNode for UseItem {
2907 fn can_cast(kind: SyntaxKind) -> bool { 3432 fn can_cast(kind: SyntaxKind) -> bool {
2908 match kind { 3433 match kind {
@@ -2932,6 +3457,11 @@ impl UseItem {
2932pub struct UseTree { 3457pub struct UseTree {
2933 pub(crate) syntax: SyntaxNode, 3458 pub(crate) syntax: SyntaxNode,
2934} 3459}
3460impl std::fmt::Display for UseTree {
3461 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3462 std::fmt::Display::fmt(self.syntax(), f)
3463 }
3464}
2935impl AstNode for UseTree { 3465impl AstNode for UseTree {
2936 fn can_cast(kind: SyntaxKind) -> bool { 3466 fn can_cast(kind: SyntaxKind) -> bool {
2937 match kind { 3467 match kind {
@@ -2965,6 +3495,11 @@ impl UseTree {
2965pub struct Alias { 3495pub struct Alias {
2966 pub(crate) syntax: SyntaxNode, 3496 pub(crate) syntax: SyntaxNode,
2967} 3497}
3498impl std::fmt::Display for Alias {
3499 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3500 std::fmt::Display::fmt(self.syntax(), f)
3501 }
3502}
2968impl AstNode for Alias { 3503impl AstNode for Alias {
2969 fn can_cast(kind: SyntaxKind) -> bool { 3504 fn can_cast(kind: SyntaxKind) -> bool {
2970 match kind { 3505 match kind {
@@ -2989,6 +3524,11 @@ impl Alias {}
2989pub struct UseTreeList { 3524pub struct UseTreeList {
2990 pub(crate) syntax: SyntaxNode, 3525 pub(crate) syntax: SyntaxNode,
2991} 3526}
3527impl std::fmt::Display for UseTreeList {
3528 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3529 std::fmt::Display::fmt(self.syntax(), f)
3530 }
3531}
2992impl AstNode for UseTreeList { 3532impl AstNode for UseTreeList {
2993 fn can_cast(kind: SyntaxKind) -> bool { 3533 fn can_cast(kind: SyntaxKind) -> bool {
2994 match kind { 3534 match kind {
@@ -3016,6 +3556,11 @@ impl UseTreeList {
3016pub struct ExternCrateItem { 3556pub struct ExternCrateItem {
3017 pub(crate) syntax: SyntaxNode, 3557 pub(crate) syntax: SyntaxNode,
3018} 3558}
3559impl std::fmt::Display for ExternCrateItem {
3560 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3561 std::fmt::Display::fmt(self.syntax(), f)
3562 }
3563}
3019impl AstNode for ExternCrateItem { 3564impl AstNode for ExternCrateItem {
3020 fn can_cast(kind: SyntaxKind) -> bool { 3565 fn can_cast(kind: SyntaxKind) -> bool {
3021 match kind { 3566 match kind {
@@ -3048,6 +3593,11 @@ impl ExternCrateItem {
3048pub struct ArgList { 3593pub struct ArgList {
3049 pub(crate) syntax: SyntaxNode, 3594 pub(crate) syntax: SyntaxNode,
3050} 3595}
3596impl std::fmt::Display for ArgList {
3597 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3598 std::fmt::Display::fmt(self.syntax(), f)
3599 }
3600}
3051impl AstNode for ArgList { 3601impl AstNode for ArgList {
3052 fn can_cast(kind: SyntaxKind) -> bool { 3602 fn can_cast(kind: SyntaxKind) -> bool {
3053 match kind { 3603 match kind {
@@ -3075,6 +3625,11 @@ impl ArgList {
3075pub struct Path { 3625pub struct Path {
3076 pub(crate) syntax: SyntaxNode, 3626 pub(crate) syntax: SyntaxNode,
3077} 3627}
3628impl std::fmt::Display for Path {
3629 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3630 std::fmt::Display::fmt(self.syntax(), f)
3631 }
3632}
3078impl AstNode for Path { 3633impl AstNode for Path {
3079 fn can_cast(kind: SyntaxKind) -> bool { 3634 fn can_cast(kind: SyntaxKind) -> bool {
3080 match kind { 3635 match kind {
@@ -3105,6 +3660,11 @@ impl Path {
3105pub struct PathSegment { 3660pub struct PathSegment {
3106 pub(crate) syntax: SyntaxNode, 3661 pub(crate) syntax: SyntaxNode,
3107} 3662}
3663impl std::fmt::Display for PathSegment {
3664 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3665 std::fmt::Display::fmt(self.syntax(), f)
3666 }
3667}
3108impl AstNode for PathSegment { 3668impl AstNode for PathSegment {
3109 fn can_cast(kind: SyntaxKind) -> bool { 3669 fn can_cast(kind: SyntaxKind) -> bool {
3110 match kind { 3670 match kind {
@@ -3144,6 +3704,11 @@ impl PathSegment {
3144pub struct TypeArgList { 3704pub struct TypeArgList {
3145 pub(crate) syntax: SyntaxNode, 3705 pub(crate) syntax: SyntaxNode,
3146} 3706}
3707impl std::fmt::Display for TypeArgList {
3708 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3709 std::fmt::Display::fmt(self.syntax(), f)
3710 }
3711}
3147impl AstNode for TypeArgList { 3712impl AstNode for TypeArgList {
3148 fn can_cast(kind: SyntaxKind) -> bool { 3713 fn can_cast(kind: SyntaxKind) -> bool {
3149 match kind { 3714 match kind {
@@ -3180,6 +3745,11 @@ impl TypeArgList {
3180pub struct TypeArg { 3745pub struct TypeArg {
3181 pub(crate) syntax: SyntaxNode, 3746 pub(crate) syntax: SyntaxNode,
3182} 3747}
3748impl std::fmt::Display for TypeArg {
3749 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3750 std::fmt::Display::fmt(self.syntax(), f)
3751 }
3752}
3183impl AstNode for TypeArg { 3753impl AstNode for TypeArg {
3184 fn can_cast(kind: SyntaxKind) -> bool { 3754 fn can_cast(kind: SyntaxKind) -> bool {
3185 match kind { 3755 match kind {
@@ -3207,6 +3777,11 @@ impl TypeArg {
3207pub struct AssocTypeArg { 3777pub struct AssocTypeArg {
3208 pub(crate) syntax: SyntaxNode, 3778 pub(crate) syntax: SyntaxNode,
3209} 3779}
3780impl std::fmt::Display for AssocTypeArg {
3781 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3782 std::fmt::Display::fmt(self.syntax(), f)
3783 }
3784}
3210impl AstNode for AssocTypeArg { 3785impl AstNode for AssocTypeArg {
3211 fn can_cast(kind: SyntaxKind) -> bool { 3786 fn can_cast(kind: SyntaxKind) -> bool {
3212 match kind { 3787 match kind {
@@ -3237,6 +3812,11 @@ impl AssocTypeArg {
3237pub struct LifetimeArg { 3812pub struct LifetimeArg {
3238 pub(crate) syntax: SyntaxNode, 3813 pub(crate) syntax: SyntaxNode,
3239} 3814}
3815impl std::fmt::Display for LifetimeArg {
3816 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3817 std::fmt::Display::fmt(self.syntax(), f)
3818 }
3819}
3240impl AstNode for LifetimeArg { 3820impl AstNode for LifetimeArg {
3241 fn can_cast(kind: SyntaxKind) -> bool { 3821 fn can_cast(kind: SyntaxKind) -> bool {
3242 match kind { 3822 match kind {
@@ -3260,6 +3840,11 @@ impl LifetimeArg {}
3260pub struct ConstArg { 3840pub struct ConstArg {
3261 pub(crate) syntax: SyntaxNode, 3841 pub(crate) syntax: SyntaxNode,
3262} 3842}
3843impl std::fmt::Display for ConstArg {
3844 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3845 std::fmt::Display::fmt(self.syntax(), f)
3846 }
3847}
3263impl AstNode for ConstArg { 3848impl AstNode for ConstArg {
3264 fn can_cast(kind: SyntaxKind) -> bool { 3849 fn can_cast(kind: SyntaxKind) -> bool {
3265 match kind { 3850 match kind {
@@ -3290,6 +3875,11 @@ impl ConstArg {
3290pub struct MacroItems { 3875pub struct MacroItems {
3291 pub(crate) syntax: SyntaxNode, 3876 pub(crate) syntax: SyntaxNode,
3292} 3877}
3878impl std::fmt::Display for MacroItems {
3879 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3880 std::fmt::Display::fmt(self.syntax(), f)
3881 }
3882}
3293impl AstNode for MacroItems { 3883impl AstNode for MacroItems {
3294 fn can_cast(kind: SyntaxKind) -> bool { 3884 fn can_cast(kind: SyntaxKind) -> bool {
3295 match kind { 3885 match kind {
@@ -3315,6 +3905,11 @@ impl MacroItems {}
3315pub struct MacroStmts { 3905pub struct MacroStmts {
3316 pub(crate) syntax: SyntaxNode, 3906 pub(crate) syntax: SyntaxNode,
3317} 3907}
3908impl std::fmt::Display for MacroStmts {
3909 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3910 std::fmt::Display::fmt(self.syntax(), f)
3911 }
3912}
3318impl AstNode for MacroStmts { 3913impl AstNode for MacroStmts {
3319 fn can_cast(kind: SyntaxKind) -> bool { 3914 fn can_cast(kind: SyntaxKind) -> bool {
3320 match kind { 3915 match kind {
@@ -3362,6 +3957,11 @@ impl From<UnionDef> for NominalDef {
3362 NominalDef::UnionDef(node) 3957 NominalDef::UnionDef(node)
3363 } 3958 }
3364} 3959}
3960impl std::fmt::Display for NominalDef {
3961 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
3962 std::fmt::Display::fmt(self.syntax(), f)
3963 }
3964}
3365impl AstNode for NominalDef { 3965impl AstNode for NominalDef {
3366 fn can_cast(kind: SyntaxKind) -> bool { 3966 fn can_cast(kind: SyntaxKind) -> bool {
3367 match kind { 3967 match kind {
@@ -3470,6 +4070,11 @@ impl From<DynTraitType> for TypeRef {
3470 TypeRef::DynTraitType(node) 4070 TypeRef::DynTraitType(node)
3471 } 4071 }
3472} 4072}
4073impl std::fmt::Display for TypeRef {
4074 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4075 std::fmt::Display::fmt(self.syntax(), f)
4076 }
4077}
3473impl AstNode for TypeRef { 4078impl AstNode for TypeRef {
3474 fn can_cast(kind: SyntaxKind) -> bool { 4079 fn can_cast(kind: SyntaxKind) -> bool {
3475 match kind { 4080 match kind {
@@ -3591,6 +4196,11 @@ impl From<Module> for ModuleItem {
3591 ModuleItem::Module(node) 4196 ModuleItem::Module(node)
3592 } 4197 }
3593} 4198}
4199impl std::fmt::Display for ModuleItem {
4200 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4201 std::fmt::Display::fmt(self.syntax(), f)
4202 }
4203}
3594impl AstNode for ModuleItem { 4204impl AstNode for ModuleItem {
3595 fn can_cast(kind: SyntaxKind) -> bool { 4205 fn can_cast(kind: SyntaxKind) -> bool {
3596 match kind { 4206 match kind {
@@ -3657,6 +4267,11 @@ impl From<ConstDef> for ImplItem {
3657 ImplItem::ConstDef(node) 4267 ImplItem::ConstDef(node)
3658 } 4268 }
3659} 4269}
4270impl std::fmt::Display for ImplItem {
4271 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4272 std::fmt::Display::fmt(self.syntax(), f)
4273 }
4274}
3660impl AstNode for ImplItem { 4275impl AstNode for ImplItem {
3661 fn can_cast(kind: SyntaxKind) -> bool { 4276 fn can_cast(kind: SyntaxKind) -> bool {
3662 match kind { 4277 match kind {
@@ -3871,6 +4486,11 @@ impl From<BoxExpr> for Expr {
3871 Expr::BoxExpr(node) 4486 Expr::BoxExpr(node)
3872 } 4487 }
3873} 4488}
4489impl std::fmt::Display for Expr {
4490 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4491 std::fmt::Display::fmt(self.syntax(), f)
4492 }
4493}
3874impl AstNode for Expr { 4494impl AstNode for Expr {
3875 fn can_cast(kind: SyntaxKind) -> bool { 4495 fn can_cast(kind: SyntaxKind) -> bool {
3876 match kind { 4496 match kind {
@@ -4043,6 +4663,11 @@ impl From<LiteralPat> for Pat {
4043 Pat::LiteralPat(node) 4663 Pat::LiteralPat(node)
4044 } 4664 }
4045} 4665}
4666impl std::fmt::Display for Pat {
4667 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4668 std::fmt::Display::fmt(self.syntax(), f)
4669 }
4670}
4046impl AstNode for Pat { 4671impl AstNode for Pat {
4047 fn can_cast(kind: SyntaxKind) -> bool { 4672 fn can_cast(kind: SyntaxKind) -> bool {
4048 match kind { 4673 match kind {
@@ -4106,6 +4731,11 @@ impl From<TokenTree> for AttrInput {
4106 AttrInput::TokenTree(node) 4731 AttrInput::TokenTree(node)
4107 } 4732 }
4108} 4733}
4734impl std::fmt::Display for AttrInput {
4735 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4736 std::fmt::Display::fmt(self.syntax(), f)
4737 }
4738}
4109impl AstNode for AttrInput { 4739impl AstNode for AttrInput {
4110 fn can_cast(kind: SyntaxKind) -> bool { 4740 fn can_cast(kind: SyntaxKind) -> bool {
4111 match kind { 4741 match kind {
@@ -4143,6 +4773,11 @@ impl From<LetStmt> for Stmt {
4143 Stmt::LetStmt(node) 4773 Stmt::LetStmt(node)
4144 } 4774 }
4145} 4775}
4776impl std::fmt::Display for Stmt {
4777 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
4778 std::fmt::Display::fmt(self.syntax(), f)
4779 }
4780}
4146impl AstNode for Stmt { 4781impl AstNode for Stmt {
4147 fn can_cast(kind: SyntaxKind) -> bool { 4782 fn can_cast(kind: SyntaxKind) -> bool {
4148 match kind { 4783 match kind {
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs
index f2684c852..d1baaa607 100644
--- a/crates/ra_syntax/src/parsing/lexer.rs
+++ b/crates/ra_syntax/src/parsing/lexer.rs
@@ -65,7 +65,7 @@ pub fn tokenize(text: &str) -> (Vec<Token>, Vec<SyntaxError>) {
65/// Beware that unescape errors are not checked at tokenization time. 65/// Beware that unescape errors are not checked at tokenization time.
66pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxError>)> { 66pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxError>)> {
67 lex_first_token(text) 67 lex_first_token(text)
68 .filter(|(token, _)| token.len.to_usize() == text.len()) 68 .filter(|(token, _)| token.len == TextUnit::of_str(text))
69 .map(|(token, error)| (token.kind, error)) 69 .map(|(token, error)| (token.kind, error))
70} 70}
71 71
@@ -75,7 +75,7 @@ pub fn lex_single_syntax_kind(text: &str) -> Option<(SyntaxKind, Option<SyntaxEr
75/// Beware that unescape errors are not checked at tokenization time. 75/// Beware that unescape errors are not checked at tokenization time.
76pub fn lex_single_valid_syntax_kind(text: &str) -> Option<SyntaxKind> { 76pub fn lex_single_valid_syntax_kind(text: &str) -> Option<SyntaxKind> {
77 lex_first_token(text) 77 lex_first_token(text)
78 .filter(|(token, error)| !error.is_some() && token.len.to_usize() == text.len()) 78 .filter(|(token, error)| !error.is_some() && token.len == TextUnit::of_str(text))
79 .map(|(token, _error)| token.kind) 79 .map(|(token, _error)| token.kind)
80} 80}
81 81
diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs
index 912e6aec0..6a8cb6bb5 100644
--- a/crates/ra_syntax/src/tests.rs
+++ b/crates/ra_syntax/src/tests.rs
@@ -5,7 +5,7 @@ use std::{
5 5
6use test_utils::{collect_tests, dir_tests, project_dir, read_text}; 6use test_utils::{collect_tests, dir_tests, project_dir, read_text};
7 7
8use crate::{fuzz, tokenize, SourceFile, SyntaxError, Token}; 8use crate::{fuzz, tokenize, SourceFile, SyntaxError, TextRange, TextUnit, Token};
9 9
10#[test] 10#[test]
11fn lexer_tests() { 11fn lexer_tests() {
@@ -34,6 +34,7 @@ fn main() {
34 "##; 34 "##;
35 35
36 let parse = SourceFile::parse(code); 36 let parse = SourceFile::parse(code);
37 // eprintln!("{:#?}", parse.syntax_node());
37 assert!(parse.ok().is_ok()); 38 assert!(parse.ok().is_ok());
38} 39}
39 40
@@ -120,11 +121,11 @@ fn assert_errors_are_absent(errors: &[SyntaxError], path: &Path) {
120 121
121fn dump_tokens_and_errors(tokens: &[Token], errors: &[SyntaxError], text: &str) -> String { 122fn dump_tokens_and_errors(tokens: &[Token], errors: &[SyntaxError], text: &str) -> String {
122 let mut acc = String::new(); 123 let mut acc = String::new();
123 let mut offset = 0; 124 let mut offset = TextUnit::from_usize(0);
124 for token in tokens { 125 for token in tokens {
125 let token_len = token.len.to_usize(); 126 let token_len = token.len;
126 let token_text = &text[offset..offset + token_len]; 127 let token_text = &text[TextRange::offset_len(offset, token.len)];
127 offset += token_len; 128 offset += token.len;
128 writeln!(acc, "{:?} {} {:?}", token.kind, token_len, token_text).unwrap(); 129 writeln!(acc, "{:?} {} {:?}", token.kind, token_len, token_text).unwrap();
129 } 130 }
130 for err in errors { 131 for err in errors {