aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-24 23:09:31 +0000
committerAleksey Kladov <[email protected]>2019-01-24 23:09:31 +0000
commit2e354f480b0b83debc06a4311a9709cd8c0df305 (patch)
tree31b772e764f8889ca5d77add0cc3a98e85f92335 /crates/ra_syntax/src
parentb308375b82a33687f93468d75c7cc628b83a1351 (diff)
use ToOwned trait instead of inherent method
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs5
-rw-r--r--crates/ra_syntax/src/ast/generated.rs496
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera8
-rw-r--r--crates/ra_syntax/src/yellow.rs22
4 files changed, 523 insertions, 8 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index bcbd4c60c..b92cc082e 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -15,12 +15,13 @@ use crate::{
15/// conversion itself has zero runtime cost: ast and syntax nodes have exactly 15/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
16/// the same representation: a pointer to the tree root and a pointer to the 16/// the same representation: a pointer to the tree root and a pointer to the
17/// node itself. 17/// node itself.
18pub trait AstNode: rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> { 18pub trait AstNode:
19 rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> + ToOwned<Owned = TreeArc<Self>>
20{
19 fn cast(syntax: &SyntaxNode) -> Option<&Self> 21 fn cast(syntax: &SyntaxNode) -> Option<&Self>
20 where 22 where
21 Self: Sized; 23 Self: Sized;
22 fn syntax(&self) -> &SyntaxNode; 24 fn syntax(&self) -> &SyntaxNode;
23 fn to_owned(&self) -> TreeArc<Self>;
24} 25}
25 26
26pub trait AstToken: AstNode { 27pub trait AstToken: AstNode {
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index ac6c8a835..e39b58827 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -35,6 +35,10 @@ impl AstNode for ArgList {
35 } 35 }
36 } 36 }
37 fn syntax(&self) -> &SyntaxNode { &self.syntax } 37 fn syntax(&self) -> &SyntaxNode { &self.syntax }
38}
39
40impl ToOwned for ArgList {
41 type Owned = TreeArc<ArgList>;
38 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) } 42 fn to_owned(&self) -> TreeArc<ArgList> { TreeArc::cast(self.syntax.to_owned()) }
39} 43}
40 44
@@ -63,6 +67,10 @@ impl AstNode for ArrayExpr {
63 } 67 }
64 } 68 }
65 fn syntax(&self) -> &SyntaxNode { &self.syntax } 69 fn syntax(&self) -> &SyntaxNode { &self.syntax }
70}
71
72impl ToOwned for ArrayExpr {
73 type Owned = TreeArc<ArrayExpr>;
66 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) } 74 fn to_owned(&self) -> TreeArc<ArrayExpr> { TreeArc::cast(self.syntax.to_owned()) }
67} 75}
68 76
@@ -91,6 +99,10 @@ impl AstNode for ArrayType {
91 } 99 }
92 } 100 }
93 fn syntax(&self) -> &SyntaxNode { &self.syntax } 101 fn syntax(&self) -> &SyntaxNode { &self.syntax }
102}
103
104impl ToOwned for ArrayType {
105 type Owned = TreeArc<ArrayType>;
94 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) } 106 fn to_owned(&self) -> TreeArc<ArrayType> { TreeArc::cast(self.syntax.to_owned()) }
95} 107}
96 108
@@ -123,6 +135,10 @@ impl AstNode for AssocTypeArg {
123 } 135 }
124 } 136 }
125 fn syntax(&self) -> &SyntaxNode { &self.syntax } 137 fn syntax(&self) -> &SyntaxNode { &self.syntax }
138}
139
140impl ToOwned for AssocTypeArg {
141 type Owned = TreeArc<AssocTypeArg>;
126 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) } 142 fn to_owned(&self) -> TreeArc<AssocTypeArg> { TreeArc::cast(self.syntax.to_owned()) }
127} 143}
128 144
@@ -155,6 +171,10 @@ impl AstNode for Attr {
155 } 171 }
156 } 172 }
157 fn syntax(&self) -> &SyntaxNode { &self.syntax } 173 fn syntax(&self) -> &SyntaxNode { &self.syntax }
174}
175
176impl ToOwned for Attr {
177 type Owned = TreeArc<Attr>;
158 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) } 178 fn to_owned(&self) -> TreeArc<Attr> { TreeArc::cast(self.syntax.to_owned()) }
159} 179}
160 180
@@ -183,6 +203,10 @@ impl AstNode for BinExpr {
183 } 203 }
184 } 204 }
185 fn syntax(&self) -> &SyntaxNode { &self.syntax } 205 fn syntax(&self) -> &SyntaxNode { &self.syntax }
206}
207
208impl ToOwned for BinExpr {
209 type Owned = TreeArc<BinExpr>;
186 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) } 210 fn to_owned(&self) -> TreeArc<BinExpr> { TreeArc::cast(self.syntax.to_owned()) }
187} 211}
188 212
@@ -207,6 +231,10 @@ impl AstNode for BindPat {
207 } 231 }
208 } 232 }
209 fn syntax(&self) -> &SyntaxNode { &self.syntax } 233 fn syntax(&self) -> &SyntaxNode { &self.syntax }
234}
235
236impl ToOwned for BindPat {
237 type Owned = TreeArc<BindPat>;
210 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) } 238 fn to_owned(&self) -> TreeArc<BindPat> { TreeArc::cast(self.syntax.to_owned()) }
211} 239}
212 240
@@ -236,6 +264,10 @@ impl AstNode for Block {
236 } 264 }
237 } 265 }
238 fn syntax(&self) -> &SyntaxNode { &self.syntax } 266 fn syntax(&self) -> &SyntaxNode { &self.syntax }
267}
268
269impl ToOwned for Block {
270 type Owned = TreeArc<Block>;
239 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) } 271 fn to_owned(&self) -> TreeArc<Block> { TreeArc::cast(self.syntax.to_owned()) }
240} 272}
241 273
@@ -268,6 +300,10 @@ impl AstNode for BlockExpr {
268 } 300 }
269 } 301 }
270 fn syntax(&self) -> &SyntaxNode { &self.syntax } 302 fn syntax(&self) -> &SyntaxNode { &self.syntax }
303}
304
305impl ToOwned for BlockExpr {
306 type Owned = TreeArc<BlockExpr>;
271 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) } 307 fn to_owned(&self) -> TreeArc<BlockExpr> { TreeArc::cast(self.syntax.to_owned()) }
272} 308}
273 309
@@ -296,6 +332,10 @@ impl AstNode for BreakExpr {
296 } 332 }
297 } 333 }
298 fn syntax(&self) -> &SyntaxNode { &self.syntax } 334 fn syntax(&self) -> &SyntaxNode { &self.syntax }
335}
336
337impl ToOwned for BreakExpr {
338 type Owned = TreeArc<BreakExpr>;
299 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) } 339 fn to_owned(&self) -> TreeArc<BreakExpr> { TreeArc::cast(self.syntax.to_owned()) }
300} 340}
301 341
@@ -324,6 +364,10 @@ impl AstNode for Byte {
324 } 364 }
325 } 365 }
326 fn syntax(&self) -> &SyntaxNode { &self.syntax } 366 fn syntax(&self) -> &SyntaxNode { &self.syntax }
367}
368
369impl ToOwned for Byte {
370 type Owned = TreeArc<Byte>;
327 fn to_owned(&self) -> TreeArc<Byte> { TreeArc::cast(self.syntax.to_owned()) } 371 fn to_owned(&self) -> TreeArc<Byte> { TreeArc::cast(self.syntax.to_owned()) }
328} 372}
329 373
@@ -349,6 +393,10 @@ impl AstNode for ByteString {
349 } 393 }
350 } 394 }
351 fn syntax(&self) -> &SyntaxNode { &self.syntax } 395 fn syntax(&self) -> &SyntaxNode { &self.syntax }
396}
397
398impl ToOwned for ByteString {
399 type Owned = TreeArc<ByteString>;
352 fn to_owned(&self) -> TreeArc<ByteString> { TreeArc::cast(self.syntax.to_owned()) } 400 fn to_owned(&self) -> TreeArc<ByteString> { TreeArc::cast(self.syntax.to_owned()) }
353} 401}
354 402
@@ -374,6 +422,10 @@ impl AstNode for CallExpr {
374 } 422 }
375 } 423 }
376 fn syntax(&self) -> &SyntaxNode { &self.syntax } 424 fn syntax(&self) -> &SyntaxNode { &self.syntax }
425}
426
427impl ToOwned for CallExpr {
428 type Owned = TreeArc<CallExpr>;
377 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) } 429 fn to_owned(&self) -> TreeArc<CallExpr> { TreeArc::cast(self.syntax.to_owned()) }
378} 430}
379 431
@@ -403,6 +455,10 @@ impl AstNode for CastExpr {
403 } 455 }
404 } 456 }
405 fn syntax(&self) -> &SyntaxNode { &self.syntax } 457 fn syntax(&self) -> &SyntaxNode { &self.syntax }
458}
459
460impl ToOwned for CastExpr {
461 type Owned = TreeArc<CastExpr>;
406 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) } 462 fn to_owned(&self) -> TreeArc<CastExpr> { TreeArc::cast(self.syntax.to_owned()) }
407} 463}
408 464
@@ -435,6 +491,10 @@ impl AstNode for Char {
435 } 491 }
436 } 492 }
437 fn syntax(&self) -> &SyntaxNode { &self.syntax } 493 fn syntax(&self) -> &SyntaxNode { &self.syntax }
494}
495
496impl ToOwned for Char {
497 type Owned = TreeArc<Char>;
438 fn to_owned(&self) -> TreeArc<Char> { TreeArc::cast(self.syntax.to_owned()) } 498 fn to_owned(&self) -> TreeArc<Char> { TreeArc::cast(self.syntax.to_owned()) }
439} 499}
440 500
@@ -460,6 +520,10 @@ impl AstNode for Comment {
460 } 520 }
461 } 521 }
462 fn syntax(&self) -> &SyntaxNode { &self.syntax } 522 fn syntax(&self) -> &SyntaxNode { &self.syntax }
523}
524
525impl ToOwned for Comment {
526 type Owned = TreeArc<Comment>;
463 fn to_owned(&self) -> TreeArc<Comment> { TreeArc::cast(self.syntax.to_owned()) } 527 fn to_owned(&self) -> TreeArc<Comment> { TreeArc::cast(self.syntax.to_owned()) }
464} 528}
465 529
@@ -485,6 +549,10 @@ impl AstNode for Condition {
485 } 549 }
486 } 550 }
487 fn syntax(&self) -> &SyntaxNode { &self.syntax } 551 fn syntax(&self) -> &SyntaxNode { &self.syntax }
552}
553
554impl ToOwned for Condition {
555 type Owned = TreeArc<Condition>;
488 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) } 556 fn to_owned(&self) -> TreeArc<Condition> { TreeArc::cast(self.syntax.to_owned()) }
489} 557}
490 558
@@ -517,6 +585,10 @@ impl AstNode for ConstDef {
517 } 585 }
518 } 586 }
519 fn syntax(&self) -> &SyntaxNode { &self.syntax } 587 fn syntax(&self) -> &SyntaxNode { &self.syntax }
588}
589
590impl ToOwned for ConstDef {
591 type Owned = TreeArc<ConstDef>;
520 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) } 592 fn to_owned(&self) -> TreeArc<ConstDef> { TreeArc::cast(self.syntax.to_owned()) }
521} 593}
522 594
@@ -546,6 +618,10 @@ impl AstNode for ContinueExpr {
546 } 618 }
547 } 619 }
548 fn syntax(&self) -> &SyntaxNode { &self.syntax } 620 fn syntax(&self) -> &SyntaxNode { &self.syntax }
621}
622
623impl ToOwned for ContinueExpr {
624 type Owned = TreeArc<ContinueExpr>;
549 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) } 625 fn to_owned(&self) -> TreeArc<ContinueExpr> { TreeArc::cast(self.syntax.to_owned()) }
550} 626}
551 627
@@ -570,6 +646,10 @@ impl AstNode for DynTraitType {
570 } 646 }
571 } 647 }
572 fn syntax(&self) -> &SyntaxNode { &self.syntax } 648 fn syntax(&self) -> &SyntaxNode { &self.syntax }
649}
650
651impl ToOwned for DynTraitType {
652 type Owned = TreeArc<DynTraitType>;
573 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) } 653 fn to_owned(&self) -> TreeArc<DynTraitType> { TreeArc::cast(self.syntax.to_owned()) }
574} 654}
575 655
@@ -594,6 +674,10 @@ impl AstNode for EnumDef {
594 } 674 }
595 } 675 }
596 fn syntax(&self) -> &SyntaxNode { &self.syntax } 676 fn syntax(&self) -> &SyntaxNode { &self.syntax }
677}
678
679impl ToOwned for EnumDef {
680 type Owned = TreeArc<EnumDef>;
597 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) } 681 fn to_owned(&self) -> TreeArc<EnumDef> { TreeArc::cast(self.syntax.to_owned()) }
598} 682}
599 683
@@ -627,6 +711,10 @@ impl AstNode for EnumVariant {
627 } 711 }
628 } 712 }
629 fn syntax(&self) -> &SyntaxNode { &self.syntax } 713 fn syntax(&self) -> &SyntaxNode { &self.syntax }
714}
715
716impl ToOwned for EnumVariant {
717 type Owned = TreeArc<EnumVariant>;
630 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) } 718 fn to_owned(&self) -> TreeArc<EnumVariant> { TreeArc::cast(self.syntax.to_owned()) }
631} 719}
632 720
@@ -657,6 +745,10 @@ impl AstNode for EnumVariantList {
657 } 745 }
658 } 746 }
659 fn syntax(&self) -> &SyntaxNode { &self.syntax } 747 fn syntax(&self) -> &SyntaxNode { &self.syntax }
748}
749
750impl ToOwned for EnumVariantList {
751 type Owned = TreeArc<EnumVariantList>;
660 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) } 752 fn to_owned(&self) -> TreeArc<EnumVariantList> { TreeArc::cast(self.syntax.to_owned()) }
661} 753}
662 754
@@ -742,6 +834,10 @@ impl AstNode for Expr {
742 } 834 }
743 } 835 }
744 fn syntax(&self) -> &SyntaxNode { &self.syntax } 836 fn syntax(&self) -> &SyntaxNode { &self.syntax }
837}
838
839impl ToOwned for Expr {
840 type Owned = TreeArc<Expr>;
745 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) } 841 fn to_owned(&self) -> TreeArc<Expr> { TreeArc::cast(self.syntax.to_owned()) }
746} 842}
747 843
@@ -800,6 +896,10 @@ impl AstNode for ExprStmt {
800 } 896 }
801 } 897 }
802 fn syntax(&self) -> &SyntaxNode { &self.syntax } 898 fn syntax(&self) -> &SyntaxNode { &self.syntax }
899}
900
901impl ToOwned for ExprStmt {
902 type Owned = TreeArc<ExprStmt>;
803 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) } 903 fn to_owned(&self) -> TreeArc<ExprStmt> { TreeArc::cast(self.syntax.to_owned()) }
804} 904}
805 905
@@ -828,6 +928,10 @@ impl AstNode for ExternCrateItem {
828 } 928 }
829 } 929 }
830 fn syntax(&self) -> &SyntaxNode { &self.syntax } 930 fn syntax(&self) -> &SyntaxNode { &self.syntax }
931}
932
933impl ToOwned for ExternCrateItem {
934 type Owned = TreeArc<ExternCrateItem>;
831 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) } 935 fn to_owned(&self) -> TreeArc<ExternCrateItem> { TreeArc::cast(self.syntax.to_owned()) }
832} 936}
833 937
@@ -852,6 +956,10 @@ impl AstNode for FalseKw {
852 } 956 }
853 } 957 }
854 fn syntax(&self) -> &SyntaxNode { &self.syntax } 958 fn syntax(&self) -> &SyntaxNode { &self.syntax }
959}
960
961impl ToOwned for FalseKw {
962 type Owned = TreeArc<FalseKw>;
855 fn to_owned(&self) -> TreeArc<FalseKw> { TreeArc::cast(self.syntax.to_owned()) } 963 fn to_owned(&self) -> TreeArc<FalseKw> { TreeArc::cast(self.syntax.to_owned()) }
856} 964}
857 965
@@ -877,6 +985,10 @@ impl AstNode for FieldExpr {
877 } 985 }
878 } 986 }
879 fn syntax(&self) -> &SyntaxNode { &self.syntax } 987 fn syntax(&self) -> &SyntaxNode { &self.syntax }
988}
989
990impl ToOwned for FieldExpr {
991 type Owned = TreeArc<FieldExpr>;
880 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) } 992 fn to_owned(&self) -> TreeArc<FieldExpr> { TreeArc::cast(self.syntax.to_owned()) }
881} 993}
882 994
@@ -909,6 +1021,10 @@ impl AstNode for FieldPat {
909 } 1021 }
910 } 1022 }
911 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1023 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1024}
1025
1026impl ToOwned for FieldPat {
1027 type Owned = TreeArc<FieldPat>;
912 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) } 1028 fn to_owned(&self) -> TreeArc<FieldPat> { TreeArc::cast(self.syntax.to_owned()) }
913} 1029}
914 1030
@@ -938,6 +1054,10 @@ impl AstNode for FieldPatList {
938 } 1054 }
939 } 1055 }
940 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1056 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1057}
1058
1059impl ToOwned for FieldPatList {
1060 type Owned = TreeArc<FieldPatList>;
941 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) } 1061 fn to_owned(&self) -> TreeArc<FieldPatList> { TreeArc::cast(self.syntax.to_owned()) }
942} 1062}
943 1063
@@ -970,6 +1090,10 @@ impl AstNode for FloatNumber {
970 } 1090 }
971 } 1091 }
972 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1092 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1093}
1094
1095impl ToOwned for FloatNumber {
1096 type Owned = TreeArc<FloatNumber>;
973 fn to_owned(&self) -> TreeArc<FloatNumber> { TreeArc::cast(self.syntax.to_owned()) } 1097 fn to_owned(&self) -> TreeArc<FloatNumber> { TreeArc::cast(self.syntax.to_owned()) }
974} 1098}
975 1099
@@ -995,6 +1119,10 @@ impl AstNode for FnDef {
995 } 1119 }
996 } 1120 }
997 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1121 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1122}
1123
1124impl ToOwned for FnDef {
1125 type Owned = TreeArc<FnDef>;
998 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) } 1126 fn to_owned(&self) -> TreeArc<FnDef> { TreeArc::cast(self.syntax.to_owned()) }
999} 1127}
1000 1128
@@ -1036,6 +1164,10 @@ impl AstNode for FnPointerType {
1036 } 1164 }
1037 } 1165 }
1038 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1166 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1167}
1168
1169impl ToOwned for FnPointerType {
1170 type Owned = TreeArc<FnPointerType>;
1039 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) } 1171 fn to_owned(&self) -> TreeArc<FnPointerType> { TreeArc::cast(self.syntax.to_owned()) }
1040} 1172}
1041 1173
@@ -1068,6 +1200,10 @@ impl AstNode for ForExpr {
1068 } 1200 }
1069 } 1201 }
1070 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1202 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1203}
1204
1205impl ToOwned for ForExpr {
1206 type Owned = TreeArc<ForExpr>;
1071 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) } 1207 fn to_owned(&self) -> TreeArc<ForExpr> { TreeArc::cast(self.syntax.to_owned()) }
1072} 1208}
1073 1209
@@ -1101,6 +1237,10 @@ impl AstNode for ForType {
1101 } 1237 }
1102 } 1238 }
1103 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1239 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1240}
1241
1242impl ToOwned for ForType {
1243 type Owned = TreeArc<ForType>;
1104 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) } 1244 fn to_owned(&self) -> TreeArc<ForType> { TreeArc::cast(self.syntax.to_owned()) }
1105} 1245}
1106 1246
@@ -1129,6 +1269,10 @@ impl AstNode for IfExpr {
1129 } 1269 }
1130 } 1270 }
1131 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1271 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1272}
1273
1274impl ToOwned for IfExpr {
1275 type Owned = TreeArc<IfExpr>;
1132 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) } 1276 fn to_owned(&self) -> TreeArc<IfExpr> { TreeArc::cast(self.syntax.to_owned()) }
1133} 1277}
1134 1278
@@ -1157,6 +1301,10 @@ impl AstNode for ImplBlock {
1157 } 1301 }
1158 } 1302 }
1159 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1303 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1304}
1305
1306impl ToOwned for ImplBlock {
1307 type Owned = TreeArc<ImplBlock>;
1160 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) } 1308 fn to_owned(&self) -> TreeArc<ImplBlock> { TreeArc::cast(self.syntax.to_owned()) }
1161} 1309}
1162 1310
@@ -1194,6 +1342,10 @@ impl AstNode for ImplItem {
1194 } 1342 }
1195 } 1343 }
1196 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1344 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1345}
1346
1347impl ToOwned for ImplItem {
1348 type Owned = TreeArc<ImplItem>;
1197 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) } 1349 fn to_owned(&self) -> TreeArc<ImplItem> { TreeArc::cast(self.syntax.to_owned()) }
1198} 1350}
1199 1351
@@ -1228,6 +1380,10 @@ impl AstNode for ImplTraitType {
1228 } 1380 }
1229 } 1381 }
1230 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1382 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1383}
1384
1385impl ToOwned for ImplTraitType {
1386 type Owned = TreeArc<ImplTraitType>;
1231 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) } 1387 fn to_owned(&self) -> TreeArc<ImplTraitType> { TreeArc::cast(self.syntax.to_owned()) }
1232} 1388}
1233 1389
@@ -1252,6 +1408,10 @@ impl AstNode for IndexExpr {
1252 } 1408 }
1253 } 1409 }
1254 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1410 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1411}
1412
1413impl ToOwned for IndexExpr {
1414 type Owned = TreeArc<IndexExpr>;
1255 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) } 1415 fn to_owned(&self) -> TreeArc<IndexExpr> { TreeArc::cast(self.syntax.to_owned()) }
1256} 1416}
1257 1417
@@ -1276,6 +1436,10 @@ impl AstNode for IntNumber {
1276 } 1436 }
1277 } 1437 }
1278 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1438 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1439}
1440
1441impl ToOwned for IntNumber {
1442 type Owned = TreeArc<IntNumber>;
1279 fn to_owned(&self) -> TreeArc<IntNumber> { TreeArc::cast(self.syntax.to_owned()) } 1443 fn to_owned(&self) -> TreeArc<IntNumber> { TreeArc::cast(self.syntax.to_owned()) }
1280} 1444}
1281 1445
@@ -1301,6 +1465,10 @@ impl AstNode for ItemList {
1301 } 1465 }
1302 } 1466 }
1303 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1467 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1468}
1469
1470impl ToOwned for ItemList {
1471 type Owned = TreeArc<ItemList>;
1304 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) } 1472 fn to_owned(&self) -> TreeArc<ItemList> { TreeArc::cast(self.syntax.to_owned()) }
1305} 1473}
1306 1474
@@ -1331,6 +1499,10 @@ impl AstNode for Label {
1331 } 1499 }
1332 } 1500 }
1333 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1502}
1503
1504impl ToOwned for Label {
1505 type Owned = TreeArc<Label>;
1334 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) } 1506 fn to_owned(&self) -> TreeArc<Label> { TreeArc::cast(self.syntax.to_owned()) }
1335} 1507}
1336 1508
@@ -1355,6 +1527,10 @@ impl AstNode for LambdaExpr {
1355 } 1527 }
1356 } 1528 }
1357 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1529 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1530}
1531
1532impl ToOwned for LambdaExpr {
1533 type Owned = TreeArc<LambdaExpr>;
1358 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) } 1534 fn to_owned(&self) -> TreeArc<LambdaExpr> { TreeArc::cast(self.syntax.to_owned()) }
1359} 1535}
1360 1536
@@ -1387,6 +1563,10 @@ impl AstNode for LetStmt {
1387 } 1563 }
1388 } 1564 }
1389 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1565 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1566}
1567
1568impl ToOwned for LetStmt {
1569 type Owned = TreeArc<LetStmt>;
1390 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) } 1570 fn to_owned(&self) -> TreeArc<LetStmt> { TreeArc::cast(self.syntax.to_owned()) }
1391} 1571}
1392 1572
@@ -1423,6 +1603,10 @@ impl AstNode for Lifetime {
1423 } 1603 }
1424 } 1604 }
1425 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1605 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1606}
1607
1608impl ToOwned for Lifetime {
1609 type Owned = TreeArc<Lifetime>;
1426 fn to_owned(&self) -> TreeArc<Lifetime> { TreeArc::cast(self.syntax.to_owned()) } 1610 fn to_owned(&self) -> TreeArc<Lifetime> { TreeArc::cast(self.syntax.to_owned()) }
1427} 1611}
1428 1612
@@ -1448,6 +1632,10 @@ impl AstNode for LifetimeArg {
1448 } 1632 }
1449 } 1633 }
1450 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1634 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1635}
1636
1637impl ToOwned for LifetimeArg {
1638 type Owned = TreeArc<LifetimeArg>;
1451 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) } 1639 fn to_owned(&self) -> TreeArc<LifetimeArg> { TreeArc::cast(self.syntax.to_owned()) }
1452} 1640}
1453 1641
@@ -1476,6 +1664,10 @@ impl AstNode for LifetimeParam {
1476 } 1664 }
1477 } 1665 }
1478 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1666 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1667}
1668
1669impl ToOwned for LifetimeParam {
1670 type Owned = TreeArc<LifetimeParam>;
1479 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) } 1671 fn to_owned(&self) -> TreeArc<LifetimeParam> { TreeArc::cast(self.syntax.to_owned()) }
1480} 1672}
1481 1673
@@ -1504,6 +1696,10 @@ impl AstNode for Literal {
1504 } 1696 }
1505 } 1697 }
1506 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1698 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1699}
1700
1701impl ToOwned for Literal {
1702 type Owned = TreeArc<Literal>;
1507 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) } 1703 fn to_owned(&self) -> TreeArc<Literal> { TreeArc::cast(self.syntax.to_owned()) }
1508} 1704}
1509 1705
@@ -1555,6 +1751,10 @@ impl AstNode for LiteralExpr {
1555 } 1751 }
1556 } 1752 }
1557 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1753 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1754}
1755
1756impl ToOwned for LiteralExpr {
1757 type Owned = TreeArc<LiteralExpr>;
1558 fn to_owned(&self) -> TreeArc<LiteralExpr> { TreeArc::cast(self.syntax.to_owned()) } 1758 fn to_owned(&self) -> TreeArc<LiteralExpr> { TreeArc::cast(self.syntax.to_owned()) }
1559} 1759}
1560 1760
@@ -1596,6 +1796,10 @@ impl AstNode for LoopExpr {
1596 } 1796 }
1597 } 1797 }
1598 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1798 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1799}
1800
1801impl ToOwned for LoopExpr {
1802 type Owned = TreeArc<LoopExpr>;
1599 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) } 1803 fn to_owned(&self) -> TreeArc<LoopExpr> { TreeArc::cast(self.syntax.to_owned()) }
1600} 1804}
1601 1805
@@ -1621,6 +1825,10 @@ impl AstNode for MacroCall {
1621 } 1825 }
1622 } 1826 }
1623 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1827 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1828}
1829
1830impl ToOwned for MacroCall {
1831 type Owned = TreeArc<MacroCall>;
1624 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) } 1832 fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned()) }
1625} 1833}
1626 1834
@@ -1653,6 +1861,10 @@ impl AstNode for MatchArm {
1653 } 1861 }
1654 } 1862 }
1655 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1863 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1864}
1865
1866impl ToOwned for MatchArm {
1867 type Owned = TreeArc<MatchArm>;
1656 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) } 1868 fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1657} 1869}
1658 1870
@@ -1689,6 +1901,10 @@ impl AstNode for MatchArmList {
1689 } 1901 }
1690 } 1902 }
1691 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1903 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1904}
1905
1906impl ToOwned for MatchArmList {
1907 type Owned = TreeArc<MatchArmList>;
1692 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) } 1908 fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1693} 1909}
1694 1910
@@ -1717,6 +1933,10 @@ impl AstNode for MatchExpr {
1717 } 1933 }
1718 } 1934 }
1719 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1935 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1936}
1937
1938impl ToOwned for MatchExpr {
1939 type Owned = TreeArc<MatchExpr>;
1720 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) } 1940 fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1721} 1941}
1722 1942
@@ -1749,6 +1969,10 @@ impl AstNode for MatchGuard {
1749 } 1969 }
1750 } 1970 }
1751 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1971 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1972}
1973
1974impl ToOwned for MatchGuard {
1975 type Owned = TreeArc<MatchGuard>;
1752 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) } 1976 fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1753} 1977}
1754 1978
@@ -1773,6 +1997,10 @@ impl AstNode for MethodCallExpr {
1773 } 1997 }
1774 } 1998 }
1775 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1999 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2000}
2001
2002impl ToOwned for MethodCallExpr {
2003 type Owned = TreeArc<MethodCallExpr>;
1776 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) } 2004 fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
1777} 2005}
1778 2006
@@ -1806,6 +2034,10 @@ impl AstNode for Module {
1806 } 2034 }
1807 } 2035 }
1808 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2036 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2037}
2038
2039impl ToOwned for Module {
2040 type Owned = TreeArc<Module>;
1809 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) } 2041 fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
1810} 2042}
1811 2043
@@ -1863,6 +2095,10 @@ impl AstNode for ModuleItem {
1863 } 2095 }
1864 } 2096 }
1865 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2097 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2098}
2099
2100impl ToOwned for ModuleItem {
2101 type Owned = TreeArc<ModuleItem>;
1866 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) } 2102 fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
1867} 2103}
1868 2104
@@ -1905,6 +2141,10 @@ impl AstNode for Name {
1905 } 2141 }
1906 } 2142 }
1907 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2143 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2144}
2145
2146impl ToOwned for Name {
2147 type Owned = TreeArc<Name>;
1908 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) } 2148 fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
1909} 2149}
1910 2150
@@ -1929,6 +2169,10 @@ impl AstNode for NameRef {
1929 } 2169 }
1930 } 2170 }
1931 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2171 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2172}
2173
2174impl ToOwned for NameRef {
2175 type Owned = TreeArc<NameRef>;
1932 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) } 2176 fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
1933} 2177}
1934 2178
@@ -1953,6 +2197,10 @@ impl AstNode for NamedField {
1953 } 2197 }
1954 } 2198 }
1955 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2199 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2200}
2201
2202impl ToOwned for NamedField {
2203 type Owned = TreeArc<NamedField>;
1956 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) } 2204 fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
1957} 2205}
1958 2206
@@ -1985,6 +2233,10 @@ impl AstNode for NamedFieldDef {
1985 } 2233 }
1986 } 2234 }
1987 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2235 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2236}
2237
2238impl ToOwned for NamedFieldDef {
2239 type Owned = TreeArc<NamedFieldDef>;
1988 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) } 2240 fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
1989} 2241}
1990 2242
@@ -2016,6 +2268,10 @@ impl AstNode for NamedFieldDefList {
2016 } 2268 }
2017 } 2269 }
2018 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2270 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2271}
2272
2273impl ToOwned for NamedFieldDefList {
2274 type Owned = TreeArc<NamedFieldDefList>;
2019 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) } 2275 fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2020} 2276}
2021 2277
@@ -2044,6 +2300,10 @@ impl AstNode for NamedFieldList {
2044 } 2300 }
2045 } 2301 }
2046 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2302 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2303}
2304
2305impl ToOwned for NamedFieldList {
2306 type Owned = TreeArc<NamedFieldList>;
2047 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) } 2307 fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2048} 2308}
2049 2309
@@ -2072,6 +2332,10 @@ impl AstNode for NeverType {
2072 } 2332 }
2073 } 2333 }
2074 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2334 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2335}
2336
2337impl ToOwned for NeverType {
2338 type Owned = TreeArc<NeverType>;
2075 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) } 2339 fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2076} 2340}
2077 2341
@@ -2103,6 +2367,10 @@ impl AstNode for NominalDef {
2103 } 2367 }
2104 } 2368 }
2105 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2369 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2370}
2371
2372impl ToOwned for NominalDef {
2373 type Owned = TreeArc<NominalDef>;
2106 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) } 2374 fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2107} 2375}
2108 2376
@@ -2139,6 +2407,10 @@ impl AstNode for Param {
2139 } 2407 }
2140 } 2408 }
2141 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2409 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2410}
2411
2412impl ToOwned for Param {
2413 type Owned = TreeArc<Param>;
2142 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) } 2414 fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2143} 2415}
2144 2416
@@ -2171,6 +2443,10 @@ impl AstNode for ParamList {
2171 } 2443 }
2172 } 2444 }
2173 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2445 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2446}
2447
2448impl ToOwned for ParamList {
2449 type Owned = TreeArc<ParamList>;
2174 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) } 2450 fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2175} 2451}
2176 2452
@@ -2203,6 +2479,10 @@ impl AstNode for ParenExpr {
2203 } 2479 }
2204 } 2480 }
2205 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2481 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2482}
2483
2484impl ToOwned for ParenExpr {
2485 type Owned = TreeArc<ParenExpr>;
2206 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) } 2486 fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2207} 2487}
2208 2488
@@ -2231,6 +2511,10 @@ impl AstNode for ParenType {
2231 } 2511 }
2232 } 2512 }
2233 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2513 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2514}
2515
2516impl ToOwned for ParenType {
2517 type Owned = TreeArc<ParenType>;
2234 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) } 2518 fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2235} 2519}
2236 2520
@@ -2280,6 +2564,10 @@ impl AstNode for Pat {
2280 } 2564 }
2281 } 2565 }
2282 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2566 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2567}
2568
2569impl ToOwned for Pat {
2570 type Owned = TreeArc<Pat>;
2283 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) } 2571 fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2284} 2572}
2285 2573
@@ -2320,6 +2608,10 @@ impl AstNode for Path {
2320 } 2608 }
2321 } 2609 }
2322 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2610 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2611}
2612
2613impl ToOwned for Path {
2614 type Owned = TreeArc<Path>;
2323 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) } 2615 fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2324} 2616}
2325 2617
@@ -2352,6 +2644,10 @@ impl AstNode for PathExpr {
2352 } 2644 }
2353 } 2645 }
2354 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2646 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2647}
2648
2649impl ToOwned for PathExpr {
2650 type Owned = TreeArc<PathExpr>;
2355 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) } 2651 fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2356} 2652}
2357 2653
@@ -2380,6 +2676,10 @@ impl AstNode for PathPat {
2380 } 2676 }
2381 } 2677 }
2382 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2678 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2679}
2680
2681impl ToOwned for PathPat {
2682 type Owned = TreeArc<PathPat>;
2383 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) } 2683 fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2384} 2684}
2385 2685
@@ -2408,6 +2708,10 @@ impl AstNode for PathSegment {
2408 } 2708 }
2409 } 2709 }
2410 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2710 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2711}
2712
2713impl ToOwned for PathSegment {
2714 type Owned = TreeArc<PathSegment>;
2411 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) } 2715 fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2412} 2716}
2413 2717
@@ -2440,6 +2744,10 @@ impl AstNode for PathType {
2440 } 2744 }
2441 } 2745 }
2442 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2746 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2747}
2748
2749impl ToOwned for PathType {
2750 type Owned = TreeArc<PathType>;
2443 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) } 2751 fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2444} 2752}
2445 2753
@@ -2468,6 +2776,10 @@ impl AstNode for PlaceholderPat {
2468 } 2776 }
2469 } 2777 }
2470 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2778 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2779}
2780
2781impl ToOwned for PlaceholderPat {
2782 type Owned = TreeArc<PlaceholderPat>;
2471 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) } 2783 fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2472} 2784}
2473 2785
@@ -2492,6 +2804,10 @@ impl AstNode for PlaceholderType {
2492 } 2804 }
2493 } 2805 }
2494 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2806 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2807}
2808
2809impl ToOwned for PlaceholderType {
2810 type Owned = TreeArc<PlaceholderType>;
2495 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) } 2811 fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2496} 2812}
2497 2813
@@ -2516,6 +2832,10 @@ impl AstNode for PointerType {
2516 } 2832 }
2517 } 2833 }
2518 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2834 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2835}
2836
2837impl ToOwned for PointerType {
2838 type Owned = TreeArc<PointerType>;
2519 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) } 2839 fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2520} 2840}
2521 2841
@@ -2544,6 +2864,10 @@ impl AstNode for PosField {
2544 } 2864 }
2545 } 2865 }
2546 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2866 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2867}
2868
2869impl ToOwned for PosField {
2870 type Owned = TreeArc<PosField>;
2547 fn to_owned(&self) -> TreeArc<PosField> { TreeArc::cast(self.syntax.to_owned()) } 2871 fn to_owned(&self) -> TreeArc<PosField> { TreeArc::cast(self.syntax.to_owned()) }
2548} 2872}
2549 2873
@@ -2574,6 +2898,10 @@ impl AstNode for PosFieldList {
2574 } 2898 }
2575 } 2899 }
2576 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2900 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2901}
2902
2903impl ToOwned for PosFieldList {
2904 type Owned = TreeArc<PosFieldList>;
2577 fn to_owned(&self) -> TreeArc<PosFieldList> { TreeArc::cast(self.syntax.to_owned()) } 2905 fn to_owned(&self) -> TreeArc<PosFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2578} 2906}
2579 2907
@@ -2602,6 +2930,10 @@ impl AstNode for PrefixExpr {
2602 } 2930 }
2603 } 2931 }
2604 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2932 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2933}
2934
2935impl ToOwned for PrefixExpr {
2936 type Owned = TreeArc<PrefixExpr>;
2605 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) } 2937 fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
2606} 2938}
2607 2939
@@ -2630,6 +2962,10 @@ impl AstNode for RangeExpr {
2630 } 2962 }
2631 } 2963 }
2632 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2964 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2965}
2966
2967impl ToOwned for RangeExpr {
2968 type Owned = TreeArc<RangeExpr>;
2633 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) } 2969 fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
2634} 2970}
2635 2971
@@ -2654,6 +2990,10 @@ impl AstNode for RangePat {
2654 } 2990 }
2655 } 2991 }
2656 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2992 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2993}
2994
2995impl ToOwned for RangePat {
2996 type Owned = TreeArc<RangePat>;
2657 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) } 2997 fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
2658} 2998}
2659 2999
@@ -2678,6 +3018,10 @@ impl AstNode for RawByteString {
2678 } 3018 }
2679 } 3019 }
2680 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3020 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3021}
3022
3023impl ToOwned for RawByteString {
3024 type Owned = TreeArc<RawByteString>;
2681 fn to_owned(&self) -> TreeArc<RawByteString> { TreeArc::cast(self.syntax.to_owned()) } 3025 fn to_owned(&self) -> TreeArc<RawByteString> { TreeArc::cast(self.syntax.to_owned()) }
2682} 3026}
2683 3027
@@ -2703,6 +3047,10 @@ impl AstNode for RawString {
2703 } 3047 }
2704 } 3048 }
2705 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3049 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3050}
3051
3052impl ToOwned for RawString {
3053 type Owned = TreeArc<RawString>;
2706 fn to_owned(&self) -> TreeArc<RawString> { TreeArc::cast(self.syntax.to_owned()) } 3054 fn to_owned(&self) -> TreeArc<RawString> { TreeArc::cast(self.syntax.to_owned()) }
2707} 3055}
2708 3056
@@ -2728,6 +3076,10 @@ impl AstNode for RefExpr {
2728 } 3076 }
2729 } 3077 }
2730 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3078 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3079}
3080
3081impl ToOwned for RefExpr {
3082 type Owned = TreeArc<RefExpr>;
2731 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) } 3083 fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
2732} 3084}
2733 3085
@@ -2756,6 +3108,10 @@ impl AstNode for RefPat {
2756 } 3108 }
2757 } 3109 }
2758 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3110 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3111}
3112
3113impl ToOwned for RefPat {
3114 type Owned = TreeArc<RefPat>;
2759 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) } 3115 fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
2760} 3116}
2761 3117
@@ -2784,6 +3140,10 @@ impl AstNode for ReferenceType {
2784 } 3140 }
2785 } 3141 }
2786 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3142 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3143}
3144
3145impl ToOwned for ReferenceType {
3146 type Owned = TreeArc<ReferenceType>;
2787 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) } 3147 fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
2788} 3148}
2789 3149
@@ -2812,6 +3172,10 @@ impl AstNode for RetType {
2812 } 3172 }
2813 } 3173 }
2814 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3174 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3175}
3176
3177impl ToOwned for RetType {
3178 type Owned = TreeArc<RetType>;
2815 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) } 3179 fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
2816} 3180}
2817 3181
@@ -2840,6 +3204,10 @@ impl AstNode for ReturnExpr {
2840 } 3204 }
2841 } 3205 }
2842 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3206 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3207}
3208
3209impl ToOwned for ReturnExpr {
3210 type Owned = TreeArc<ReturnExpr>;
2843 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) } 3211 fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
2844} 3212}
2845 3213
@@ -2868,6 +3236,10 @@ impl AstNode for SelfKw {
2868 } 3236 }
2869 } 3237 }
2870 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3238 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3239}
3240
3241impl ToOwned for SelfKw {
3242 type Owned = TreeArc<SelfKw>;
2871 fn to_owned(&self) -> TreeArc<SelfKw> { TreeArc::cast(self.syntax.to_owned()) } 3243 fn to_owned(&self) -> TreeArc<SelfKw> { TreeArc::cast(self.syntax.to_owned()) }
2872} 3244}
2873 3245
@@ -2892,6 +3264,10 @@ impl AstNode for SelfParam {
2892 } 3264 }
2893 } 3265 }
2894 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3266 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3267}
3268
3269impl ToOwned for SelfParam {
3270 type Owned = TreeArc<SelfParam>;
2895 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) } 3271 fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
2896} 3272}
2897 3273
@@ -2924,6 +3300,10 @@ impl AstNode for SlicePat {
2924 } 3300 }
2925 } 3301 }
2926 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3302 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3303}
3304
3305impl ToOwned for SlicePat {
3306 type Owned = TreeArc<SlicePat>;
2927 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) } 3307 fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
2928} 3308}
2929 3309
@@ -2948,6 +3328,10 @@ impl AstNode for SliceType {
2948 } 3328 }
2949 } 3329 }
2950 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3330 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3331}
3332
3333impl ToOwned for SliceType {
3334 type Owned = TreeArc<SliceType>;
2951 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) } 3335 fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
2952} 3336}
2953 3337
@@ -2976,6 +3360,10 @@ impl AstNode for SourceFile {
2976 } 3360 }
2977 } 3361 }
2978 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3362 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3363}
3364
3365impl ToOwned for SourceFile {
3366 type Owned = TreeArc<SourceFile>;
2979 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) } 3367 fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
2980} 3368}
2981 3369
@@ -3006,6 +3394,10 @@ impl AstNode for StaticDef {
3006 } 3394 }
3007 } 3395 }
3008 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3397}
3398
3399impl ToOwned for StaticDef {
3400 type Owned = TreeArc<StaticDef>;
3009 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) } 3401 fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3010} 3402}
3011 3403
@@ -3042,6 +3434,10 @@ impl AstNode for Stmt {
3042 } 3434 }
3043 } 3435 }
3044 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3436 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3437}
3438
3439impl ToOwned for Stmt {
3440 type Owned = TreeArc<Stmt>;
3045 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) } 3441 fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3046} 3442}
3047 3443
@@ -3075,6 +3471,10 @@ impl AstNode for String {
3075 } 3471 }
3076 } 3472 }
3077 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3473 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3474}
3475
3476impl ToOwned for String {
3477 type Owned = TreeArc<String>;
3078 fn to_owned(&self) -> TreeArc<String> { TreeArc::cast(self.syntax.to_owned()) } 3478 fn to_owned(&self) -> TreeArc<String> { TreeArc::cast(self.syntax.to_owned()) }
3079} 3479}
3080 3480
@@ -3100,6 +3500,10 @@ impl AstNode for StructDef {
3100 } 3500 }
3101 } 3501 }
3102 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3502 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3503}
3504
3505impl ToOwned for StructDef {
3506 type Owned = TreeArc<StructDef>;
3103 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) } 3507 fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3104} 3508}
3105 3509
@@ -3129,6 +3533,10 @@ impl AstNode for StructLit {
3129 } 3533 }
3130 } 3534 }
3131 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3535 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3536}
3537
3538impl ToOwned for StructLit {
3539 type Owned = TreeArc<StructLit>;
3132 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) } 3540 fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3133} 3541}
3134 3542
@@ -3165,6 +3573,10 @@ impl AstNode for StructPat {
3165 } 3573 }
3166 } 3574 }
3167 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3575 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3576}
3577
3578impl ToOwned for StructPat {
3579 type Owned = TreeArc<StructPat>;
3168 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) } 3580 fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3169} 3581}
3170 3582
@@ -3197,6 +3609,10 @@ impl AstNode for TokenTree {
3197 } 3609 }
3198 } 3610 }
3199 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3611 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3612}
3613
3614impl ToOwned for TokenTree {
3615 type Owned = TreeArc<TokenTree>;
3200 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) } 3616 fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3201} 3617}
3202 3618
@@ -3221,6 +3637,10 @@ impl AstNode for TraitDef {
3221 } 3637 }
3222 } 3638 }
3223 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3639 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3640}
3641
3642impl ToOwned for TraitDef {
3643 type Owned = TreeArc<TraitDef>;
3224 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) } 3644 fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3225} 3645}
3226 3646
@@ -3249,6 +3669,10 @@ impl AstNode for TrueKw {
3249 } 3669 }
3250 } 3670 }
3251 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3671 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3672}
3673
3674impl ToOwned for TrueKw {
3675 type Owned = TreeArc<TrueKw>;
3252 fn to_owned(&self) -> TreeArc<TrueKw> { TreeArc::cast(self.syntax.to_owned()) } 3676 fn to_owned(&self) -> TreeArc<TrueKw> { TreeArc::cast(self.syntax.to_owned()) }
3253} 3677}
3254 3678
@@ -3274,6 +3698,10 @@ impl AstNode for TryExpr {
3274 } 3698 }
3275 } 3699 }
3276 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3700 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3701}
3702
3703impl ToOwned for TryExpr {
3704 type Owned = TreeArc<TryExpr>;
3277 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) } 3705 fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3278} 3706}
3279 3707
@@ -3302,6 +3730,10 @@ impl AstNode for TupleExpr {
3302 } 3730 }
3303 } 3731 }
3304 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3732 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3733}
3734
3735impl ToOwned for TupleExpr {
3736 type Owned = TreeArc<TupleExpr>;
3305 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) } 3737 fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3306} 3738}
3307 3739
@@ -3330,6 +3762,10 @@ impl AstNode for TuplePat {
3330 } 3762 }
3331 } 3763 }
3332 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3764 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3765}
3766
3767impl ToOwned for TuplePat {
3768 type Owned = TreeArc<TuplePat>;
3333 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) } 3769 fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3334} 3770}
3335 3771
@@ -3358,6 +3794,10 @@ impl AstNode for TupleStructPat {
3358 } 3794 }
3359 } 3795 }
3360 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3796 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3797}
3798
3799impl ToOwned for TupleStructPat {
3800 type Owned = TreeArc<TupleStructPat>;
3361 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) } 3801 fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3362} 3802}
3363 3803
@@ -3390,6 +3830,10 @@ impl AstNode for TupleType {
3390 } 3830 }
3391 } 3831 }
3392 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3832 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3833}
3834
3835impl ToOwned for TupleType {
3836 type Owned = TreeArc<TupleType>;
3393 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) } 3837 fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3394} 3838}
3395 3839
@@ -3418,6 +3862,10 @@ impl AstNode for TypeArg {
3418 } 3862 }
3419 } 3863 }
3420 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3864 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3865}
3866
3867impl ToOwned for TypeArg {
3868 type Owned = TreeArc<TypeArg>;
3421 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) } 3869 fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3422} 3870}
3423 3871
@@ -3446,6 +3894,10 @@ impl AstNode for TypeArgList {
3446 } 3894 }
3447 } 3895 }
3448 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3896 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3897}
3898
3899impl ToOwned for TypeArgList {
3900 type Owned = TreeArc<TypeArgList>;
3449 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) } 3901 fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3450} 3902}
3451 3903
@@ -3482,6 +3934,10 @@ impl AstNode for TypeDef {
3482 } 3934 }
3483 } 3935 }
3484 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3936 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3937}
3938
3939impl ToOwned for TypeDef {
3940 type Owned = TreeArc<TypeDef>;
3485 fn to_owned(&self) -> TreeArc<TypeDef> { TreeArc::cast(self.syntax.to_owned()) } 3941 fn to_owned(&self) -> TreeArc<TypeDef> { TreeArc::cast(self.syntax.to_owned()) }
3486} 3942}
3487 3943
@@ -3511,6 +3967,10 @@ impl AstNode for TypeParam {
3511 } 3967 }
3512 } 3968 }
3513 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3969 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3970}
3971
3972impl ToOwned for TypeParam {
3973 type Owned = TreeArc<TypeParam>;
3514 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) } 3974 fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
3515} 3975}
3516 3976
@@ -3536,6 +3996,10 @@ impl AstNode for TypeParamList {
3536 } 3996 }
3537 } 3997 }
3538 fn syntax(&self) -> &SyntaxNode { &self.syntax } 3998 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3999}
4000
4001impl ToOwned for TypeParamList {
4002 type Owned = TreeArc<TypeParamList>;
3539 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) } 4003 fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
3540} 4004}
3541 4005
@@ -3597,6 +4061,10 @@ impl AstNode for TypeRef {
3597 } 4061 }
3598 } 4062 }
3599 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4063 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4064}
4065
4066impl ToOwned for TypeRef {
4067 type Owned = TreeArc<TypeRef>;
3600 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) } 4068 fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
3601} 4069}
3602 4070
@@ -3641,6 +4109,10 @@ impl AstNode for UseItem {
3641 } 4109 }
3642 } 4110 }
3643 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4111 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4112}
4113
4114impl ToOwned for UseItem {
4115 type Owned = TreeArc<UseItem>;
3644 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) } 4116 fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
3645} 4117}
3646 4118
@@ -3669,6 +4141,10 @@ impl AstNode for UseTree {
3669 } 4141 }
3670 } 4142 }
3671 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4143 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4144}
4145
4146impl ToOwned for UseTree {
4147 type Owned = TreeArc<UseTree>;
3672 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) } 4148 fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
3673} 4149}
3674 4150
@@ -3701,6 +4177,10 @@ impl AstNode for UseTreeList {
3701 } 4177 }
3702 } 4178 }
3703 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4179 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4180}
4181
4182impl ToOwned for UseTreeList {
4183 type Owned = TreeArc<UseTreeList>;
3704 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) } 4184 fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
3705} 4185}
3706 4186
@@ -3729,6 +4209,10 @@ impl AstNode for Visibility {
3729 } 4209 }
3730 } 4210 }
3731 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4211 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4212}
4213
4214impl ToOwned for Visibility {
4215 type Owned = TreeArc<Visibility>;
3732 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) } 4216 fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
3733} 4217}
3734 4218
@@ -3753,6 +4237,10 @@ impl AstNode for WhereClause {
3753 } 4237 }
3754 } 4238 }
3755 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4239 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4240}
4241
4242impl ToOwned for WhereClause {
4243 type Owned = TreeArc<WhereClause>;
3756 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) } 4244 fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
3757} 4245}
3758 4246
@@ -3777,6 +4265,10 @@ impl AstNode for WhileExpr {
3777 } 4265 }
3778 } 4266 }
3779 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4267 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4268}
4269
4270impl ToOwned for WhileExpr {
4271 type Owned = TreeArc<WhileExpr>;
3780 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) } 4272 fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
3781} 4273}
3782 4274
@@ -3806,6 +4298,10 @@ impl AstNode for Whitespace {
3806 } 4298 }
3807 } 4299 }
3808 fn syntax(&self) -> &SyntaxNode { &self.syntax } 4300 fn syntax(&self) -> &SyntaxNode { &self.syntax }
4301}
4302
4303impl ToOwned for Whitespace {
4304 type Owned = TreeArc<Whitespace>;
3809 fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) } 4305 fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) }
3810} 4306}
3811 4307
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index bf9db4ee8..ea0fc35fd 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -48,6 +48,10 @@ impl AstNode for {{ node }} {
48 } 48 }
49 } 49 }
50 fn syntax(&self) -> &SyntaxNode { &self.syntax } 50 fn syntax(&self) -> &SyntaxNode { &self.syntax }
51}
52
53impl ToOwned for {{ node }} {
54 type Owned = TreeArc<{{ node }}>;
51 fn to_owned(&self) -> TreeArc<{{ node }}> { TreeArc::cast(self.syntax.to_owned()) } 55 fn to_owned(&self) -> TreeArc<{{ node }}> { TreeArc::cast(self.syntax.to_owned()) }
52} 56}
53 57
@@ -79,6 +83,10 @@ impl AstNode for {{ node }} {
79 } 83 }
80 } 84 }
81 fn syntax(&self) -> &SyntaxNode { &self.syntax } 85 fn syntax(&self) -> &SyntaxNode { &self.syntax }
86}
87
88impl ToOwned for {{ node }} {
89 type Owned = TreeArc<{{ node }}>;
82 fn to_owned(&self) -> TreeArc<{{ node }}> { TreeArc::cast(self.syntax.to_owned()) } 90 fn to_owned(&self) -> TreeArc<{{ node }}> { TreeArc::cast(self.syntax.to_owned()) }
83} 91}
84 92
diff --git a/crates/ra_syntax/src/yellow.rs b/crates/ra_syntax/src/yellow.rs
index a7bfb80e2..ed48739f8 100644
--- a/crates/ra_syntax/src/yellow.rs
+++ b/crates/ra_syntax/src/yellow.rs
@@ -2,10 +2,11 @@ mod builder;
2pub mod syntax_error; 2pub mod syntax_error;
3mod syntax_text; 3mod syntax_text;
4 4
5use std::{fmt, borrow::Borrow};
6
5use self::syntax_text::SyntaxText; 7use self::syntax_text::SyntaxText;
6use crate::{SmolStr, SyntaxKind, TextRange}; 8use crate::{SmolStr, SyntaxKind, TextRange};
7use rowan::{Types, TransparentNewType}; 9use rowan::{Types, TransparentNewType};
8use std::fmt;
9 10
10pub(crate) use self::builder::GreenBuilder; 11pub(crate) use self::builder::GreenBuilder;
11pub use self::syntax_error::{SyntaxError, SyntaxErrorKind, Location}; 12pub use self::syntax_error::{SyntaxError, SyntaxErrorKind, Location};
@@ -25,6 +26,12 @@ pub struct TreeArc<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>>(
25 pub(crate) rowan::TreeArc<RaTypes, T>, 26 pub(crate) rowan::TreeArc<RaTypes, T>,
26); 27);
27 28
29impl<T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>> Borrow<T> for TreeArc<T> {
30 fn borrow(&self) -> &T {
31 &*self
32 }
33}
34
28impl<T> TreeArc<T> 35impl<T> TreeArc<T>
29where 36where
30 T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>, 37 T: TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>>,
@@ -124,6 +131,14 @@ impl SyntaxNode {
124 } 131 }
125} 132}
126 133
134impl ToOwned for SyntaxNode {
135 type Owned = TreeArc<SyntaxNode>;
136 fn to_owned(&self) -> TreeArc<SyntaxNode> {
137 let ptr = TreeArc(self.0.to_owned());
138 TreeArc::cast(ptr)
139 }
140}
141
127impl SyntaxNode { 142impl SyntaxNode {
128 pub(crate) fn root_data(&self) -> &Vec<SyntaxError> { 143 pub(crate) fn root_data(&self) -> &Vec<SyntaxError> {
129 self.0.root_data() 144 self.0.root_data()
@@ -133,11 +148,6 @@ impl SyntaxNode {
133 self.0.replace_self(replacement) 148 self.0.replace_self(replacement)
134 } 149 }
135 150
136 pub fn to_owned(&self) -> TreeArc<SyntaxNode> {
137 let ptr = TreeArc(self.0.to_owned());
138 TreeArc::cast(ptr)
139 }
140
141 pub fn kind(&self) -> SyntaxKind { 151 pub fn kind(&self) -> SyntaxKind {
142 self.0.kind() 152 self.0.kind()
143 } 153 }