aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs654
-rw-r--r--crates/ra_syntax/src/ast/make.rs8
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs8
4 files changed, 333 insertions, 339 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 04746ef8f..667a9294f 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -390,7 +390,7 @@ impl ast::MatchArmList {
390 #[must_use] 390 #[must_use]
391 pub fn remove_placeholder(&self) -> ast::MatchArmList { 391 pub fn remove_placeholder(&self) -> ast::MatchArmList {
392 let placeholder = 392 let placeholder =
393 self.arms().find(|arm| matches!(arm.pat(), Some(ast::Pat::PlaceholderPat(_)))); 393 self.arms().find(|arm| matches!(arm.pat(), Some(ast::Pat::WildcardPat(_))));
394 if let Some(placeholder) = placeholder { 394 if let Some(placeholder) = placeholder {
395 self.remove_arm(&placeholder) 395 self.remove_arm(&placeholder)
396 } else { 396 } else {
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 6ce9c4adc..231a0f727 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -6,6 +6,20 @@ use crate::{
6 SyntaxNode, SyntaxToken, T, 6 SyntaxNode, SyntaxToken, T,
7}; 7};
8#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9pub struct Name {
10 pub(crate) syntax: SyntaxNode,
11}
12impl Name {
13 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
14}
15#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16pub struct NameRef {
17 pub(crate) syntax: SyntaxNode,
18}
19impl NameRef {
20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
21}
22#[derive(Debug, Clone, PartialEq, Eq, Hash)]
9pub struct Path { 23pub struct Path {
10 pub(crate) syntax: SyntaxNode, 24 pub(crate) syntax: SyntaxNode,
11} 25}
@@ -33,13 +47,6 @@ impl PathSegment {
33 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } 47 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
34} 48}
35#[derive(Debug, Clone, PartialEq, Eq, Hash)] 49#[derive(Debug, Clone, PartialEq, Eq, Hash)]
36pub struct NameRef {
37 pub(crate) syntax: SyntaxNode,
38}
39impl NameRef {
40 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
41}
42#[derive(Debug, Clone, PartialEq, Eq, Hash)]
43pub struct GenericArgList { 50pub struct GenericArgList {
44 pub(crate) syntax: SyntaxNode, 51 pub(crate) syntax: SyntaxNode,
45} 52}
@@ -116,13 +123,16 @@ impl TypeBoundList {
116 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } 123 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
117} 124}
118#[derive(Debug, Clone, PartialEq, Eq, Hash)] 125#[derive(Debug, Clone, PartialEq, Eq, Hash)]
119pub struct SourceFile { 126pub struct MacroCall {
120 pub(crate) syntax: SyntaxNode, 127 pub(crate) syntax: SyntaxNode,
121} 128}
122impl ast::AttrsOwner for SourceFile {} 129impl ast::AttrsOwner for MacroCall {}
123impl ast::ModuleItemOwner for SourceFile {} 130impl ast::NameOwner for MacroCall {}
124impl SourceFile { 131impl MacroCall {
125 pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) } 132 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
133 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
134 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
135 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
126} 136}
127#[derive(Debug, Clone, PartialEq, Eq, Hash)] 137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
128pub struct Attr { 138pub struct Attr {
@@ -139,6 +149,41 @@ impl Attr {
139 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 149 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
140} 150}
141#[derive(Debug, Clone, PartialEq, Eq, Hash)] 151#[derive(Debug, Clone, PartialEq, Eq, Hash)]
152pub struct TokenTree {
153 pub(crate) syntax: SyntaxNode,
154}
155impl TokenTree {
156 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
157 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
158 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
159 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
160 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
161 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
162}
163#[derive(Debug, Clone, PartialEq, Eq, Hash)]
164pub struct MacroItems {
165 pub(crate) syntax: SyntaxNode,
166}
167impl ast::ModuleItemOwner for MacroItems {}
168impl MacroItems {}
169#[derive(Debug, Clone, PartialEq, Eq, Hash)]
170pub struct MacroStmts {
171 pub(crate) syntax: SyntaxNode,
172}
173impl MacroStmts {
174 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
175 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
176}
177#[derive(Debug, Clone, PartialEq, Eq, Hash)]
178pub struct SourceFile {
179 pub(crate) syntax: SyntaxNode,
180}
181impl ast::AttrsOwner for SourceFile {}
182impl ast::ModuleItemOwner for SourceFile {}
183impl SourceFile {
184 pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
185}
186#[derive(Debug, Clone, PartialEq, Eq, Hash)]
142pub struct Const { 187pub struct Const {
143 pub(crate) syntax: SyntaxNode, 188 pub(crate) syntax: SyntaxNode,
144} 189}
@@ -228,18 +273,6 @@ impl Impl {
228 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } 273 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
229} 274}
230#[derive(Debug, Clone, PartialEq, Eq, Hash)] 275#[derive(Debug, Clone, PartialEq, Eq, Hash)]
231pub struct MacroCall {
232 pub(crate) syntax: SyntaxNode,
233}
234impl ast::AttrsOwner for MacroCall {}
235impl ast::NameOwner for MacroCall {}
236impl MacroCall {
237 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
238 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
239 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
240 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
241}
242#[derive(Debug, Clone, PartialEq, Eq, Hash)]
243pub struct Module { 276pub struct Module {
244 pub(crate) syntax: SyntaxNode, 277 pub(crate) syntax: SyntaxNode,
245} 278}
@@ -349,13 +382,6 @@ impl Visibility {
349 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 382 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
350} 383}
351#[derive(Debug, Clone, PartialEq, Eq, Hash)] 384#[derive(Debug, Clone, PartialEq, Eq, Hash)]
352pub struct Name {
353 pub(crate) syntax: SyntaxNode,
354}
355impl Name {
356 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
357}
358#[derive(Debug, Clone, PartialEq, Eq, Hash)]
359pub struct ItemList { 385pub struct ItemList {
360 pub(crate) syntax: SyntaxNode, 386 pub(crate) syntax: SyntaxNode,
361} 387}
@@ -589,18 +615,6 @@ pub struct Literal {
589impl ast::AttrsOwner for Literal {} 615impl ast::AttrsOwner for Literal {}
590impl Literal {} 616impl Literal {}
591#[derive(Debug, Clone, PartialEq, Eq, Hash)] 617#[derive(Debug, Clone, PartialEq, Eq, Hash)]
592pub struct TokenTree {
593 pub(crate) syntax: SyntaxNode,
594}
595impl TokenTree {
596 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
597 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
598 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
599 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
600 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
601 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
602}
603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
604pub struct ExprStmt { 618pub struct ExprStmt {
605 pub(crate) syntax: SyntaxNode, 619 pub(crate) syntax: SyntaxNode,
606} 620}
@@ -1097,28 +1111,15 @@ impl TypeBound {
1097 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 1111 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1098} 1112}
1099#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1113#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1100pub struct OrPat { 1114pub struct IdentPat {
1101 pub(crate) syntax: SyntaxNode,
1102}
1103impl OrPat {
1104 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1105}
1106#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1107pub struct ParenPat {
1108 pub(crate) syntax: SyntaxNode,
1109}
1110impl ParenPat {
1111 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1112 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1113 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1114}
1115#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1116pub struct RefPat {
1117 pub(crate) syntax: SyntaxNode, 1115 pub(crate) syntax: SyntaxNode,
1118} 1116}
1119impl RefPat { 1117impl ast::AttrsOwner for IdentPat {}
1120 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 1118impl ast::NameOwner for IdentPat {}
1119impl IdentPat {
1120 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1121 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1121 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1122 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1122 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1123 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1123} 1124}
1124#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1125#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1127,137 +1128,130 @@ pub struct BoxPat {
1127} 1128}
1128impl BoxPat { 1129impl BoxPat {
1129 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 1130 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1130 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1131 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1131} 1132}
1132#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1133#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1133pub struct BindPat { 1134pub struct DotDotPat {
1134 pub(crate) syntax: SyntaxNode, 1135 pub(crate) syntax: SyntaxNode,
1135} 1136}
1136impl ast::AttrsOwner for BindPat {} 1137impl DotDotPat {
1137impl ast::NameOwner for BindPat {} 1138 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1138impl BindPat {
1139 pub fn ref_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ref]) }
1140 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1141 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1142 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1143} 1139}
1144#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1140#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1145pub struct PlaceholderPat { 1141pub struct LiteralPat {
1146 pub(crate) syntax: SyntaxNode, 1142 pub(crate) syntax: SyntaxNode,
1147} 1143}
1148impl PlaceholderPat { 1144impl LiteralPat {
1149 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 1145 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1150} 1146}
1151#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1147#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1152pub struct DotDotPat { 1148pub struct MacroPat {
1153 pub(crate) syntax: SyntaxNode, 1149 pub(crate) syntax: SyntaxNode,
1154} 1150}
1155impl DotDotPat { 1151impl MacroPat {
1156 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 1152 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1157} 1153}
1158#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1154#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1159pub struct PathPat { 1155pub struct OrPat {
1160 pub(crate) syntax: SyntaxNode, 1156 pub(crate) syntax: SyntaxNode,
1161} 1157}
1162impl PathPat { 1158impl OrPat {
1163 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1159 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1164} 1160}
1165#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1161#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1166pub struct SlicePat { 1162pub struct ParenPat {
1167 pub(crate) syntax: SyntaxNode, 1163 pub(crate) syntax: SyntaxNode,
1168} 1164}
1169impl SlicePat { 1165impl ParenPat {
1170 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 1166 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1171 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1167 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1172 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 1168 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1173} 1169}
1174#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1170#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1175pub struct RangePat { 1171pub struct PathPat {
1176 pub(crate) syntax: SyntaxNode, 1172 pub(crate) syntax: SyntaxNode,
1177} 1173}
1178impl RangePat { 1174impl PathPat {
1179 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 1175 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1180 pub fn dotdoteq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..=]) }
1181} 1176}
1182#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1177#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1183pub struct LiteralPat { 1178pub struct WildcardPat {
1184 pub(crate) syntax: SyntaxNode, 1179 pub(crate) syntax: SyntaxNode,
1185} 1180}
1186impl LiteralPat { 1181impl WildcardPat {
1187 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1182 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1188} 1183}
1189#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1184#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1190pub struct MacroPat { 1185pub struct RangePat {
1191 pub(crate) syntax: SyntaxNode, 1186 pub(crate) syntax: SyntaxNode,
1192} 1187}
1193impl MacroPat { 1188impl RangePat {}
1194 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1195}
1196#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1189#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1197pub struct RecordPat { 1190pub struct RecordPat {
1198 pub(crate) syntax: SyntaxNode, 1191 pub(crate) syntax: SyntaxNode,
1199} 1192}
1200impl RecordPat { 1193impl RecordPat {
1201 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1194 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1202 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { 1195 pub fn record_pat_field_list(&self) -> Option<RecordPatFieldList> {
1203 support::child(&self.syntax) 1196 support::child(&self.syntax)
1204 } 1197 }
1205} 1198}
1206#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1199#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1207pub struct RecordFieldPatList { 1200pub struct RefPat {
1208 pub(crate) syntax: SyntaxNode, 1201 pub(crate) syntax: SyntaxNode,
1209} 1202}
1210impl RecordFieldPatList { 1203impl RefPat {
1211 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 1204 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1212 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { 1205 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1213 support::children(&self.syntax) 1206 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1214 }
1215 pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) }
1216 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1217 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1218} 1207}
1219#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1208#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1220pub struct RecordFieldPat { 1209pub struct SlicePat {
1221 pub(crate) syntax: SyntaxNode, 1210 pub(crate) syntax: SyntaxNode,
1222} 1211}
1223impl ast::AttrsOwner for RecordFieldPat {} 1212impl SlicePat {
1224impl RecordFieldPat { 1213 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1225 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 1214 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1226 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 1215 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1227 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1228} 1216}
1229#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1217#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1230pub struct TupleStructPat { 1218pub struct TuplePat {
1231 pub(crate) syntax: SyntaxNode, 1219 pub(crate) syntax: SyntaxNode,
1232} 1220}
1233impl TupleStructPat { 1221impl TuplePat {
1234 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1235 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 1222 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1236 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1223 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1237 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1224 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1238} 1225}
1239#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1226#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1240pub struct TuplePat { 1227pub struct TupleStructPat {
1241 pub(crate) syntax: SyntaxNode, 1228 pub(crate) syntax: SyntaxNode,
1242} 1229}
1243impl TuplePat { 1230impl TupleStructPat {
1231 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1244 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 1232 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1245 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1233 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1246 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1234 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1247} 1235}
1248#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1236#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1249pub struct MacroItems { 1237pub struct RecordPatFieldList {
1250 pub(crate) syntax: SyntaxNode, 1238 pub(crate) syntax: SyntaxNode,
1251} 1239}
1252impl ast::ModuleItemOwner for MacroItems {} 1240impl RecordPatFieldList {
1253impl MacroItems {} 1241 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1242 pub fn fields(&self) -> AstChildren<RecordPatField> { support::children(&self.syntax) }
1243 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1244 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1245}
1254#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1246#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1255pub struct MacroStmts { 1247pub struct RecordPatField {
1256 pub(crate) syntax: SyntaxNode, 1248 pub(crate) syntax: SyntaxNode,
1257} 1249}
1258impl MacroStmts { 1250impl ast::AttrsOwner for RecordPatField {}
1259 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } 1251impl RecordPatField {
1260 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1252 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1253 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1254 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1261} 1255}
1262#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1256#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1263pub enum GenericArg { 1257pub enum GenericArg {
@@ -1334,22 +1328,28 @@ pub enum Item {
1334} 1328}
1335impl ast::AttrsOwner for Item {} 1329impl ast::AttrsOwner for Item {}
1336#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1331pub enum Stmt {
1332 ExprStmt(ExprStmt),
1333 Item(Item),
1334 LetStmt(LetStmt),
1335}
1336#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1337pub enum Pat { 1337pub enum Pat {
1338 OrPat(OrPat), 1338 IdentPat(IdentPat),
1339 ParenPat(ParenPat),
1340 RefPat(RefPat),
1341 BoxPat(BoxPat), 1339 BoxPat(BoxPat),
1342 BindPat(BindPat),
1343 PlaceholderPat(PlaceholderPat),
1344 DotDotPat(DotDotPat), 1340 DotDotPat(DotDotPat),
1341 LiteralPat(LiteralPat),
1342 MacroPat(MacroPat),
1343 OrPat(OrPat),
1344 ParenPat(ParenPat),
1345 PathPat(PathPat), 1345 PathPat(PathPat),
1346 WildcardPat(WildcardPat),
1347 RangePat(RangePat),
1346 RecordPat(RecordPat), 1348 RecordPat(RecordPat),
1347 TupleStructPat(TupleStructPat), 1349 RefPat(RefPat),
1348 TuplePat(TuplePat),
1349 SlicePat(SlicePat), 1350 SlicePat(SlicePat),
1350 RangePat(RangePat), 1351 TuplePat(TuplePat),
1351 LiteralPat(LiteralPat), 1352 TupleStructPat(TupleStructPat),
1352 MacroPat(MacroPat),
1353} 1353}
1354#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1354#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1355pub enum FieldList { 1355pub enum FieldList {
@@ -1390,14 +1390,19 @@ pub enum GenericParam {
1390 TypeParam(TypeParam), 1390 TypeParam(TypeParam),
1391} 1391}
1392impl ast::AttrsOwner for GenericParam {} 1392impl ast::AttrsOwner for GenericParam {}
1393#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1393impl AstNode for Name {
1394pub enum Stmt { 1394 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
1395 ExprStmt(ExprStmt), 1395 fn cast(syntax: SyntaxNode) -> Option<Self> {
1396 Item(Item), 1396 if Self::can_cast(syntax.kind()) {
1397 LetStmt(LetStmt), 1397 Some(Self { syntax })
1398 } else {
1399 None
1400 }
1401 }
1402 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1398} 1403}
1399impl AstNode for Path { 1404impl AstNode for NameRef {
1400 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } 1405 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
1401 fn cast(syntax: SyntaxNode) -> Option<Self> { 1406 fn cast(syntax: SyntaxNode) -> Option<Self> {
1402 if Self::can_cast(syntax.kind()) { 1407 if Self::can_cast(syntax.kind()) {
1403 Some(Self { syntax }) 1408 Some(Self { syntax })
@@ -1407,8 +1412,8 @@ impl AstNode for Path {
1407 } 1412 }
1408 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1413 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1409} 1414}
1410impl AstNode for PathSegment { 1415impl AstNode for Path {
1411 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } 1416 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
1412 fn cast(syntax: SyntaxNode) -> Option<Self> { 1417 fn cast(syntax: SyntaxNode) -> Option<Self> {
1413 if Self::can_cast(syntax.kind()) { 1418 if Self::can_cast(syntax.kind()) {
1414 Some(Self { syntax }) 1419 Some(Self { syntax })
@@ -1418,8 +1423,8 @@ impl AstNode for PathSegment {
1418 } 1423 }
1419 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1424 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1420} 1425}
1421impl AstNode for NameRef { 1426impl AstNode for PathSegment {
1422 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } 1427 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT }
1423 fn cast(syntax: SyntaxNode) -> Option<Self> { 1428 fn cast(syntax: SyntaxNode) -> Option<Self> {
1424 if Self::can_cast(syntax.kind()) { 1429 if Self::can_cast(syntax.kind()) {
1425 Some(Self { syntax }) 1430 Some(Self { syntax })
@@ -1528,8 +1533,8 @@ impl AstNode for TypeBoundList {
1528 } 1533 }
1529 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1534 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1530} 1535}
1531impl AstNode for SourceFile { 1536impl AstNode for MacroCall {
1532 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1537 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
1533 fn cast(syntax: SyntaxNode) -> Option<Self> { 1538 fn cast(syntax: SyntaxNode) -> Option<Self> {
1534 if Self::can_cast(syntax.kind()) { 1539 if Self::can_cast(syntax.kind()) {
1535 Some(Self { syntax }) 1540 Some(Self { syntax })
@@ -1550,6 +1555,50 @@ impl AstNode for Attr {
1550 } 1555 }
1551 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1556 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1552} 1557}
1558impl AstNode for TokenTree {
1559 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
1560 fn cast(syntax: SyntaxNode) -> Option<Self> {
1561 if Self::can_cast(syntax.kind()) {
1562 Some(Self { syntax })
1563 } else {
1564 None
1565 }
1566 }
1567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1568}
1569impl AstNode for MacroItems {
1570 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS }
1571 fn cast(syntax: SyntaxNode) -> Option<Self> {
1572 if Self::can_cast(syntax.kind()) {
1573 Some(Self { syntax })
1574 } else {
1575 None
1576 }
1577 }
1578 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1579}
1580impl AstNode for MacroStmts {
1581 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS }
1582 fn cast(syntax: SyntaxNode) -> Option<Self> {
1583 if Self::can_cast(syntax.kind()) {
1584 Some(Self { syntax })
1585 } else {
1586 None
1587 }
1588 }
1589 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1590}
1591impl AstNode for SourceFile {
1592 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
1593 fn cast(syntax: SyntaxNode) -> Option<Self> {
1594 if Self::can_cast(syntax.kind()) {
1595 Some(Self { syntax })
1596 } else {
1597 None
1598 }
1599 }
1600 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1601}
1553impl AstNode for Const { 1602impl AstNode for Const {
1554 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } 1603 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST }
1555 fn cast(syntax: SyntaxNode) -> Option<Self> { 1604 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1616,17 +1665,6 @@ impl AstNode for Impl {
1616 } 1665 }
1617 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1666 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1618} 1667}
1619impl AstNode for MacroCall {
1620 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
1621 fn cast(syntax: SyntaxNode) -> Option<Self> {
1622 if Self::can_cast(syntax.kind()) {
1623 Some(Self { syntax })
1624 } else {
1625 None
1626 }
1627 }
1628 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1629}
1630impl AstNode for Module { 1668impl AstNode for Module {
1631 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } 1669 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
1632 fn cast(syntax: SyntaxNode) -> Option<Self> { 1670 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1715,17 +1753,6 @@ impl AstNode for Visibility {
1715 } 1753 }
1716 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1754 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1717} 1755}
1718impl AstNode for Name {
1719 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
1720 fn cast(syntax: SyntaxNode) -> Option<Self> {
1721 if Self::can_cast(syntax.kind()) {
1722 Some(Self { syntax })
1723 } else {
1724 None
1725 }
1726 }
1727 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1728}
1729impl AstNode for ItemList { 1756impl AstNode for ItemList {
1730 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } 1757 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
1731 fn cast(syntax: SyntaxNode) -> Option<Self> { 1758 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1979,17 +2006,6 @@ impl AstNode for Literal {
1979 } 2006 }
1980 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2007 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1981} 2008}
1982impl AstNode for TokenTree {
1983 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
1984 fn cast(syntax: SyntaxNode) -> Option<Self> {
1985 if Self::can_cast(syntax.kind()) {
1986 Some(Self { syntax })
1987 } else {
1988 None
1989 }
1990 }
1991 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1992}
1993impl AstNode for ExprStmt { 2009impl AstNode for ExprStmt {
1994 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } 2010 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT }
1995 fn cast(syntax: SyntaxNode) -> Option<Self> { 2011 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2540,8 +2556,8 @@ impl AstNode for TypeBound {
2540 } 2556 }
2541 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2557 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2542} 2558}
2543impl AstNode for OrPat { 2559impl AstNode for IdentPat {
2544 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT } 2560 fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT_PAT }
2545 fn cast(syntax: SyntaxNode) -> Option<Self> { 2561 fn cast(syntax: SyntaxNode) -> Option<Self> {
2546 if Self::can_cast(syntax.kind()) { 2562 if Self::can_cast(syntax.kind()) {
2547 Some(Self { syntax }) 2563 Some(Self { syntax })
@@ -2551,8 +2567,8 @@ impl AstNode for OrPat {
2551 } 2567 }
2552 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2568 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2553} 2569}
2554impl AstNode for ParenPat { 2570impl AstNode for BoxPat {
2555 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT } 2571 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT }
2556 fn cast(syntax: SyntaxNode) -> Option<Self> { 2572 fn cast(syntax: SyntaxNode) -> Option<Self> {
2557 if Self::can_cast(syntax.kind()) { 2573 if Self::can_cast(syntax.kind()) {
2558 Some(Self { syntax }) 2574 Some(Self { syntax })
@@ -2562,8 +2578,8 @@ impl AstNode for ParenPat {
2562 } 2578 }
2563 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2579 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2564} 2580}
2565impl AstNode for RefPat { 2581impl AstNode for DotDotPat {
2566 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT } 2582 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT }
2567 fn cast(syntax: SyntaxNode) -> Option<Self> { 2583 fn cast(syntax: SyntaxNode) -> Option<Self> {
2568 if Self::can_cast(syntax.kind()) { 2584 if Self::can_cast(syntax.kind()) {
2569 Some(Self { syntax }) 2585 Some(Self { syntax })
@@ -2573,8 +2589,8 @@ impl AstNode for RefPat {
2573 } 2589 }
2574 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2590 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2575} 2591}
2576impl AstNode for BoxPat { 2592impl AstNode for LiteralPat {
2577 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT } 2593 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
2578 fn cast(syntax: SyntaxNode) -> Option<Self> { 2594 fn cast(syntax: SyntaxNode) -> Option<Self> {
2579 if Self::can_cast(syntax.kind()) { 2595 if Self::can_cast(syntax.kind()) {
2580 Some(Self { syntax }) 2596 Some(Self { syntax })
@@ -2584,8 +2600,8 @@ impl AstNode for BoxPat {
2584 } 2600 }
2585 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2601 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2586} 2602}
2587impl AstNode for BindPat { 2603impl AstNode for MacroPat {
2588 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } 2604 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
2589 fn cast(syntax: SyntaxNode) -> Option<Self> { 2605 fn cast(syntax: SyntaxNode) -> Option<Self> {
2590 if Self::can_cast(syntax.kind()) { 2606 if Self::can_cast(syntax.kind()) {
2591 Some(Self { syntax }) 2607 Some(Self { syntax })
@@ -2595,8 +2611,8 @@ impl AstNode for BindPat {
2595 } 2611 }
2596 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2612 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2597} 2613}
2598impl AstNode for PlaceholderPat { 2614impl AstNode for OrPat {
2599 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT } 2615 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT }
2600 fn cast(syntax: SyntaxNode) -> Option<Self> { 2616 fn cast(syntax: SyntaxNode) -> Option<Self> {
2601 if Self::can_cast(syntax.kind()) { 2617 if Self::can_cast(syntax.kind()) {
2602 Some(Self { syntax }) 2618 Some(Self { syntax })
@@ -2606,8 +2622,8 @@ impl AstNode for PlaceholderPat {
2606 } 2622 }
2607 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2623 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2608} 2624}
2609impl AstNode for DotDotPat { 2625impl AstNode for ParenPat {
2610 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT } 2626 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT }
2611 fn cast(syntax: SyntaxNode) -> Option<Self> { 2627 fn cast(syntax: SyntaxNode) -> Option<Self> {
2612 if Self::can_cast(syntax.kind()) { 2628 if Self::can_cast(syntax.kind()) {
2613 Some(Self { syntax }) 2629 Some(Self { syntax })
@@ -2628,8 +2644,8 @@ impl AstNode for PathPat {
2628 } 2644 }
2629 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2645 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2630} 2646}
2631impl AstNode for SlicePat { 2647impl AstNode for WildcardPat {
2632 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT } 2648 fn can_cast(kind: SyntaxKind) -> bool { kind == WILDCARD_PAT }
2633 fn cast(syntax: SyntaxNode) -> Option<Self> { 2649 fn cast(syntax: SyntaxNode) -> Option<Self> {
2634 if Self::can_cast(syntax.kind()) { 2650 if Self::can_cast(syntax.kind()) {
2635 Some(Self { syntax }) 2651 Some(Self { syntax })
@@ -2650,28 +2666,6 @@ impl AstNode for RangePat {
2650 } 2666 }
2651 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2667 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2652} 2668}
2653impl AstNode for LiteralPat {
2654 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
2655 fn cast(syntax: SyntaxNode) -> Option<Self> {
2656 if Self::can_cast(syntax.kind()) {
2657 Some(Self { syntax })
2658 } else {
2659 None
2660 }
2661 }
2662 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2663}
2664impl AstNode for MacroPat {
2665 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
2666 fn cast(syntax: SyntaxNode) -> Option<Self> {
2667 if Self::can_cast(syntax.kind()) {
2668 Some(Self { syntax })
2669 } else {
2670 None
2671 }
2672 }
2673 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2674}
2675impl AstNode for RecordPat { 2669impl AstNode for RecordPat {
2676 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } 2670 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
2677 fn cast(syntax: SyntaxNode) -> Option<Self> { 2671 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2683,8 +2677,8 @@ impl AstNode for RecordPat {
2683 } 2677 }
2684 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2678 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2685} 2679}
2686impl AstNode for RecordFieldPatList { 2680impl AstNode for RefPat {
2687 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST } 2681 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT }
2688 fn cast(syntax: SyntaxNode) -> Option<Self> { 2682 fn cast(syntax: SyntaxNode) -> Option<Self> {
2689 if Self::can_cast(syntax.kind()) { 2683 if Self::can_cast(syntax.kind()) {
2690 Some(Self { syntax }) 2684 Some(Self { syntax })
@@ -2694,8 +2688,8 @@ impl AstNode for RecordFieldPatList {
2694 } 2688 }
2695 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2689 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2696} 2690}
2697impl AstNode for RecordFieldPat { 2691impl AstNode for SlicePat {
2698 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT } 2692 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT }
2699 fn cast(syntax: SyntaxNode) -> Option<Self> { 2693 fn cast(syntax: SyntaxNode) -> Option<Self> {
2700 if Self::can_cast(syntax.kind()) { 2694 if Self::can_cast(syntax.kind()) {
2701 Some(Self { syntax }) 2695 Some(Self { syntax })
@@ -2705,8 +2699,8 @@ impl AstNode for RecordFieldPat {
2705 } 2699 }
2706 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2700 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2707} 2701}
2708impl AstNode for TupleStructPat { 2702impl AstNode for TuplePat {
2709 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT } 2703 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT }
2710 fn cast(syntax: SyntaxNode) -> Option<Self> { 2704 fn cast(syntax: SyntaxNode) -> Option<Self> {
2711 if Self::can_cast(syntax.kind()) { 2705 if Self::can_cast(syntax.kind()) {
2712 Some(Self { syntax }) 2706 Some(Self { syntax })
@@ -2716,8 +2710,8 @@ impl AstNode for TupleStructPat {
2716 } 2710 }
2717 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2711 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2718} 2712}
2719impl AstNode for TuplePat { 2713impl AstNode for TupleStructPat {
2720 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT } 2714 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT }
2721 fn cast(syntax: SyntaxNode) -> Option<Self> { 2715 fn cast(syntax: SyntaxNode) -> Option<Self> {
2722 if Self::can_cast(syntax.kind()) { 2716 if Self::can_cast(syntax.kind()) {
2723 Some(Self { syntax }) 2717 Some(Self { syntax })
@@ -2727,8 +2721,8 @@ impl AstNode for TuplePat {
2727 } 2721 }
2728 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2722 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2729} 2723}
2730impl AstNode for MacroItems { 2724impl AstNode for RecordPatFieldList {
2731 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } 2725 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT_FIELD_LIST }
2732 fn cast(syntax: SyntaxNode) -> Option<Self> { 2726 fn cast(syntax: SyntaxNode) -> Option<Self> {
2733 if Self::can_cast(syntax.kind()) { 2727 if Self::can_cast(syntax.kind()) {
2734 Some(Self { syntax }) 2728 Some(Self { syntax })
@@ -2738,8 +2732,8 @@ impl AstNode for MacroItems {
2738 } 2732 }
2739 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2733 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2740} 2734}
2741impl AstNode for MacroStmts { 2735impl AstNode for RecordPatField {
2742 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } 2736 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT_FIELD }
2743 fn cast(syntax: SyntaxNode) -> Option<Self> { 2737 fn cast(syntax: SyntaxNode) -> Option<Self> {
2744 if Self::can_cast(syntax.kind()) { 2738 if Self::can_cast(syntax.kind()) {
2745 Some(Self { syntax }) 2739 Some(Self { syntax })
@@ -3133,98 +3127,107 @@ impl AstNode for Item {
3133 } 3127 }
3134 } 3128 }
3135} 3129}
3136impl From<OrPat> for Pat { 3130impl From<ExprStmt> for Stmt {
3137 fn from(node: OrPat) -> Pat { Pat::OrPat(node) } 3131 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
3138} 3132}
3139impl From<ParenPat> for Pat { 3133impl From<Item> for Stmt {
3140 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } 3134 fn from(node: Item) -> Stmt { Stmt::Item(node) }
3141} 3135}
3142impl From<RefPat> for Pat { 3136impl From<LetStmt> for Stmt {
3143 fn from(node: RefPat) -> Pat { Pat::RefPat(node) } 3137 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3138}
3139impl From<IdentPat> for Pat {
3140 fn from(node: IdentPat) -> Pat { Pat::IdentPat(node) }
3144} 3141}
3145impl From<BoxPat> for Pat { 3142impl From<BoxPat> for Pat {
3146 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } 3143 fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) }
3147} 3144}
3148impl From<BindPat> for Pat {
3149 fn from(node: BindPat) -> Pat { Pat::BindPat(node) }
3150}
3151impl From<PlaceholderPat> for Pat {
3152 fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) }
3153}
3154impl From<DotDotPat> for Pat { 3145impl From<DotDotPat> for Pat {
3155 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } 3146 fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) }
3156} 3147}
3148impl From<LiteralPat> for Pat {
3149 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
3150}
3151impl From<MacroPat> for Pat {
3152 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) }
3153}
3154impl From<OrPat> for Pat {
3155 fn from(node: OrPat) -> Pat { Pat::OrPat(node) }
3156}
3157impl From<ParenPat> for Pat {
3158 fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) }
3159}
3157impl From<PathPat> for Pat { 3160impl From<PathPat> for Pat {
3158 fn from(node: PathPat) -> Pat { Pat::PathPat(node) } 3161 fn from(node: PathPat) -> Pat { Pat::PathPat(node) }
3159} 3162}
3163impl From<WildcardPat> for Pat {
3164 fn from(node: WildcardPat) -> Pat { Pat::WildcardPat(node) }
3165}
3166impl From<RangePat> for Pat {
3167 fn from(node: RangePat) -> Pat { Pat::RangePat(node) }
3168}
3160impl From<RecordPat> for Pat { 3169impl From<RecordPat> for Pat {
3161 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } 3170 fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) }
3162} 3171}
3163impl From<TupleStructPat> for Pat { 3172impl From<RefPat> for Pat {
3164 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } 3173 fn from(node: RefPat) -> Pat { Pat::RefPat(node) }
3165}
3166impl From<TuplePat> for Pat {
3167 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
3168} 3174}
3169impl From<SlicePat> for Pat { 3175impl From<SlicePat> for Pat {
3170 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } 3176 fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) }
3171} 3177}
3172impl From<RangePat> for Pat { 3178impl From<TuplePat> for Pat {
3173 fn from(node: RangePat) -> Pat { Pat::RangePat(node) } 3179 fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) }
3174}
3175impl From<LiteralPat> for Pat {
3176 fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) }
3177} 3180}
3178impl From<MacroPat> for Pat { 3181impl From<TupleStructPat> for Pat {
3179 fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } 3182 fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) }
3180} 3183}
3181impl AstNode for Pat { 3184impl AstNode for Pat {
3182 fn can_cast(kind: SyntaxKind) -> bool { 3185 fn can_cast(kind: SyntaxKind) -> bool {
3183 match kind { 3186 match kind {
3184 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT 3187 IDENT_PAT | BOX_PAT | DOT_DOT_PAT | LITERAL_PAT | MACRO_PAT | OR_PAT | PAREN_PAT
3185 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT 3188 | PATH_PAT | WILDCARD_PAT | RANGE_PAT | RECORD_PAT | REF_PAT | SLICE_PAT
3186 | LITERAL_PAT | MACRO_PAT => true, 3189 | TUPLE_PAT | TUPLE_STRUCT_PAT => true,
3187 _ => false, 3190 _ => false,
3188 } 3191 }
3189 } 3192 }
3190 fn cast(syntax: SyntaxNode) -> Option<Self> { 3193 fn cast(syntax: SyntaxNode) -> Option<Self> {
3191 let res = match syntax.kind() { 3194 let res = match syntax.kind() {
3192 OR_PAT => Pat::OrPat(OrPat { syntax }), 3195 IDENT_PAT => Pat::IdentPat(IdentPat { syntax }),
3193 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
3194 REF_PAT => Pat::RefPat(RefPat { syntax }),
3195 BOX_PAT => Pat::BoxPat(BoxPat { syntax }), 3196 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3196 BIND_PAT => Pat::BindPat(BindPat { syntax }),
3197 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
3198 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), 3197 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
3198 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
3199 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
3200 OR_PAT => Pat::OrPat(OrPat { syntax }),
3201 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
3199 PATH_PAT => Pat::PathPat(PathPat { syntax }), 3202 PATH_PAT => Pat::PathPat(PathPat { syntax }),
3203 WILDCARD_PAT => Pat::WildcardPat(WildcardPat { syntax }),
3204 RANGE_PAT => Pat::RangePat(RangePat { syntax }),
3200 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), 3205 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
3201 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), 3206 REF_PAT => Pat::RefPat(RefPat { syntax }),
3202 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
3203 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), 3207 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
3204 RANGE_PAT => Pat::RangePat(RangePat { syntax }), 3208 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
3205 LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), 3209 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
3206 MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
3207 _ => return None, 3210 _ => return None,
3208 }; 3211 };
3209 Some(res) 3212 Some(res)
3210 } 3213 }
3211 fn syntax(&self) -> &SyntaxNode { 3214 fn syntax(&self) -> &SyntaxNode {
3212 match self { 3215 match self {
3213 Pat::OrPat(it) => &it.syntax, 3216 Pat::IdentPat(it) => &it.syntax,
3214 Pat::ParenPat(it) => &it.syntax,
3215 Pat::RefPat(it) => &it.syntax,
3216 Pat::BoxPat(it) => &it.syntax, 3217 Pat::BoxPat(it) => &it.syntax,
3217 Pat::BindPat(it) => &it.syntax,
3218 Pat::PlaceholderPat(it) => &it.syntax,
3219 Pat::DotDotPat(it) => &it.syntax, 3218 Pat::DotDotPat(it) => &it.syntax,
3219 Pat::LiteralPat(it) => &it.syntax,
3220 Pat::MacroPat(it) => &it.syntax,
3221 Pat::OrPat(it) => &it.syntax,
3222 Pat::ParenPat(it) => &it.syntax,
3220 Pat::PathPat(it) => &it.syntax, 3223 Pat::PathPat(it) => &it.syntax,
3224 Pat::WildcardPat(it) => &it.syntax,
3225 Pat::RangePat(it) => &it.syntax,
3221 Pat::RecordPat(it) => &it.syntax, 3226 Pat::RecordPat(it) => &it.syntax,
3222 Pat::TupleStructPat(it) => &it.syntax, 3227 Pat::RefPat(it) => &it.syntax,
3223 Pat::TuplePat(it) => &it.syntax,
3224 Pat::SlicePat(it) => &it.syntax, 3228 Pat::SlicePat(it) => &it.syntax,
3225 Pat::RangePat(it) => &it.syntax, 3229 Pat::TuplePat(it) => &it.syntax,
3226 Pat::LiteralPat(it) => &it.syntax, 3230 Pat::TupleStructPat(it) => &it.syntax,
3227 Pat::MacroPat(it) => &it.syntax,
3228 } 3231 }
3229 } 3232 }
3230} 3233}
@@ -3393,15 +3396,6 @@ impl AstNode for GenericParam {
3393 } 3396 }
3394 } 3397 }
3395} 3398}
3396impl From<ExprStmt> for Stmt {
3397 fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
3398}
3399impl From<Item> for Stmt {
3400 fn from(node: Item) -> Stmt { Stmt::Item(node) }
3401}
3402impl From<LetStmt> for Stmt {
3403 fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) }
3404}
3405impl std::fmt::Display for GenericArg { 3399impl std::fmt::Display for GenericArg {
3406 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3400 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3407 std::fmt::Display::fmt(self.syntax(), f) 3401 std::fmt::Display::fmt(self.syntax(), f)
@@ -3422,6 +3416,11 @@ impl std::fmt::Display for Item {
3422 std::fmt::Display::fmt(self.syntax(), f) 3416 std::fmt::Display::fmt(self.syntax(), f)
3423 } 3417 }
3424} 3418}
3419impl std::fmt::Display for Stmt {
3420 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3421 std::fmt::Display::fmt(self.syntax(), f)
3422 }
3423}
3425impl std::fmt::Display for Pat { 3424impl std::fmt::Display for Pat {
3426 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3425 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3427 std::fmt::Display::fmt(self.syntax(), f) 3426 std::fmt::Display::fmt(self.syntax(), f)
@@ -3452,22 +3451,22 @@ impl std::fmt::Display for GenericParam {
3452 std::fmt::Display::fmt(self.syntax(), f) 3451 std::fmt::Display::fmt(self.syntax(), f)
3453 } 3452 }
3454} 3453}
3455impl std::fmt::Display for Stmt { 3454impl std::fmt::Display for Name {
3456 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3455 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3457 std::fmt::Display::fmt(self.syntax(), f) 3456 std::fmt::Display::fmt(self.syntax(), f)
3458 } 3457 }
3459} 3458}
3460impl std::fmt::Display for Path { 3459impl std::fmt::Display for NameRef {
3461 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3460 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3462 std::fmt::Display::fmt(self.syntax(), f) 3461 std::fmt::Display::fmt(self.syntax(), f)
3463 } 3462 }
3464} 3463}
3465impl std::fmt::Display for PathSegment { 3464impl std::fmt::Display for Path {
3466 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3465 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3467 std::fmt::Display::fmt(self.syntax(), f) 3466 std::fmt::Display::fmt(self.syntax(), f)
3468 } 3467 }
3469} 3468}
3470impl std::fmt::Display for NameRef { 3469impl std::fmt::Display for PathSegment {
3471 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3470 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3472 std::fmt::Display::fmt(self.syntax(), f) 3471 std::fmt::Display::fmt(self.syntax(), f)
3473 } 3472 }
@@ -3517,7 +3516,7 @@ impl std::fmt::Display for TypeBoundList {
3517 std::fmt::Display::fmt(self.syntax(), f) 3516 std::fmt::Display::fmt(self.syntax(), f)
3518 } 3517 }
3519} 3518}
3520impl std::fmt::Display for SourceFile { 3519impl std::fmt::Display for MacroCall {
3521 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3520 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3522 std::fmt::Display::fmt(self.syntax(), f) 3521 std::fmt::Display::fmt(self.syntax(), f)
3523 } 3522 }
@@ -3527,6 +3526,26 @@ impl std::fmt::Display for Attr {
3527 std::fmt::Display::fmt(self.syntax(), f) 3526 std::fmt::Display::fmt(self.syntax(), f)
3528 } 3527 }
3529} 3528}
3529impl std::fmt::Display for TokenTree {
3530 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3531 std::fmt::Display::fmt(self.syntax(), f)
3532 }
3533}
3534impl std::fmt::Display for MacroItems {
3535 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3536 std::fmt::Display::fmt(self.syntax(), f)
3537 }
3538}
3539impl std::fmt::Display for MacroStmts {
3540 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3541 std::fmt::Display::fmt(self.syntax(), f)
3542 }
3543}
3544impl std::fmt::Display for SourceFile {
3545 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3546 std::fmt::Display::fmt(self.syntax(), f)
3547 }
3548}
3530impl std::fmt::Display for Const { 3549impl std::fmt::Display for Const {
3531 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3550 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3532 std::fmt::Display::fmt(self.syntax(), f) 3551 std::fmt::Display::fmt(self.syntax(), f)
@@ -3557,11 +3576,6 @@ impl std::fmt::Display for Impl {
3557 std::fmt::Display::fmt(self.syntax(), f) 3576 std::fmt::Display::fmt(self.syntax(), f)
3558 } 3577 }
3559} 3578}
3560impl std::fmt::Display for MacroCall {
3561 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3562 std::fmt::Display::fmt(self.syntax(), f)
3563 }
3564}
3565impl std::fmt::Display for Module { 3579impl std::fmt::Display for Module {
3566 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3580 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3567 std::fmt::Display::fmt(self.syntax(), f) 3581 std::fmt::Display::fmt(self.syntax(), f)
@@ -3602,11 +3616,6 @@ impl std::fmt::Display for Visibility {
3602 std::fmt::Display::fmt(self.syntax(), f) 3616 std::fmt::Display::fmt(self.syntax(), f)
3603 } 3617 }
3604} 3618}
3605impl std::fmt::Display for Name {
3606 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3607 std::fmt::Display::fmt(self.syntax(), f)
3608 }
3609}
3610impl std::fmt::Display for ItemList { 3619impl std::fmt::Display for ItemList {
3611 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3620 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3612 std::fmt::Display::fmt(self.syntax(), f) 3621 std::fmt::Display::fmt(self.syntax(), f)
@@ -3722,11 +3731,6 @@ impl std::fmt::Display for Literal {
3722 std::fmt::Display::fmt(self.syntax(), f) 3731 std::fmt::Display::fmt(self.syntax(), f)
3723 } 3732 }
3724} 3733}
3725impl std::fmt::Display for TokenTree {
3726 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3727 std::fmt::Display::fmt(self.syntax(), f)
3728 }
3729}
3730impl std::fmt::Display for ExprStmt { 3734impl std::fmt::Display for ExprStmt {
3731 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3735 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3732 std::fmt::Display::fmt(self.syntax(), f) 3736 std::fmt::Display::fmt(self.syntax(), f)
@@ -3977,37 +3981,37 @@ impl std::fmt::Display for TypeBound {
3977 std::fmt::Display::fmt(self.syntax(), f) 3981 std::fmt::Display::fmt(self.syntax(), f)
3978 } 3982 }
3979} 3983}
3980impl std::fmt::Display for OrPat { 3984impl std::fmt::Display for IdentPat {
3981 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3985 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3982 std::fmt::Display::fmt(self.syntax(), f) 3986 std::fmt::Display::fmt(self.syntax(), f)
3983 } 3987 }
3984} 3988}
3985impl std::fmt::Display for ParenPat { 3989impl std::fmt::Display for BoxPat {
3986 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3990 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3987 std::fmt::Display::fmt(self.syntax(), f) 3991 std::fmt::Display::fmt(self.syntax(), f)
3988 } 3992 }
3989} 3993}
3990impl std::fmt::Display for RefPat { 3994impl std::fmt::Display for DotDotPat {
3991 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3995 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3992 std::fmt::Display::fmt(self.syntax(), f) 3996 std::fmt::Display::fmt(self.syntax(), f)
3993 } 3997 }
3994} 3998}
3995impl std::fmt::Display for BoxPat { 3999impl std::fmt::Display for LiteralPat {
3996 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4000 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3997 std::fmt::Display::fmt(self.syntax(), f) 4001 std::fmt::Display::fmt(self.syntax(), f)
3998 } 4002 }
3999} 4003}
4000impl std::fmt::Display for BindPat { 4004impl std::fmt::Display for MacroPat {
4001 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4005 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4002 std::fmt::Display::fmt(self.syntax(), f) 4006 std::fmt::Display::fmt(self.syntax(), f)
4003 } 4007 }
4004} 4008}
4005impl std::fmt::Display for PlaceholderPat { 4009impl std::fmt::Display for OrPat {
4006 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4010 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4007 std::fmt::Display::fmt(self.syntax(), f) 4011 std::fmt::Display::fmt(self.syntax(), f)
4008 } 4012 }
4009} 4013}
4010impl std::fmt::Display for DotDotPat { 4014impl std::fmt::Display for ParenPat {
4011 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4015 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4012 std::fmt::Display::fmt(self.syntax(), f) 4016 std::fmt::Display::fmt(self.syntax(), f)
4013 } 4017 }
@@ -4017,7 +4021,7 @@ impl std::fmt::Display for PathPat {
4017 std::fmt::Display::fmt(self.syntax(), f) 4021 std::fmt::Display::fmt(self.syntax(), f)
4018 } 4022 }
4019} 4023}
4020impl std::fmt::Display for SlicePat { 4024impl std::fmt::Display for WildcardPat {
4021 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4025 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4022 std::fmt::Display::fmt(self.syntax(), f) 4026 std::fmt::Display::fmt(self.syntax(), f)
4023 } 4027 }
@@ -4027,47 +4031,37 @@ impl std::fmt::Display for RangePat {
4027 std::fmt::Display::fmt(self.syntax(), f) 4031 std::fmt::Display::fmt(self.syntax(), f)
4028 } 4032 }
4029} 4033}
4030impl std::fmt::Display for LiteralPat {
4031 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4032 std::fmt::Display::fmt(self.syntax(), f)
4033 }
4034}
4035impl std::fmt::Display for MacroPat {
4036 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4037 std::fmt::Display::fmt(self.syntax(), f)
4038 }
4039}
4040impl std::fmt::Display for RecordPat { 4034impl std::fmt::Display for RecordPat {
4041 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4035 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4042 std::fmt::Display::fmt(self.syntax(), f) 4036 std::fmt::Display::fmt(self.syntax(), f)
4043 } 4037 }
4044} 4038}
4045impl std::fmt::Display for RecordFieldPatList { 4039impl std::fmt::Display for RefPat {
4046 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4040 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4047 std::fmt::Display::fmt(self.syntax(), f) 4041 std::fmt::Display::fmt(self.syntax(), f)
4048 } 4042 }
4049} 4043}
4050impl std::fmt::Display for RecordFieldPat { 4044impl std::fmt::Display for SlicePat {
4051 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4045 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4052 std::fmt::Display::fmt(self.syntax(), f) 4046 std::fmt::Display::fmt(self.syntax(), f)
4053 } 4047 }
4054} 4048}
4055impl std::fmt::Display for TupleStructPat { 4049impl std::fmt::Display for TuplePat {
4056 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4050 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4057 std::fmt::Display::fmt(self.syntax(), f) 4051 std::fmt::Display::fmt(self.syntax(), f)
4058 } 4052 }
4059} 4053}
4060impl std::fmt::Display for TuplePat { 4054impl std::fmt::Display for TupleStructPat {
4061 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4055 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4062 std::fmt::Display::fmt(self.syntax(), f) 4056 std::fmt::Display::fmt(self.syntax(), f)
4063 } 4057 }
4064} 4058}
4065impl std::fmt::Display for MacroItems { 4059impl std::fmt::Display for RecordPatFieldList {
4066 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4060 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4067 std::fmt::Display::fmt(self.syntax(), f) 4061 std::fmt::Display::fmt(self.syntax(), f)
4068 } 4062 }
4069} 4063}
4070impl std::fmt::Display for MacroStmts { 4064impl std::fmt::Display for RecordPatField {
4071 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4065 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4072 std::fmt::Display::fmt(self.syntax(), f) 4066 std::fmt::Display::fmt(self.syntax(), f)
4073 } 4067 }
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 3d4fed64c..673777015 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -148,18 +148,18 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition {
148 } 148 }
149} 149}
150 150
151pub fn bind_pat(name: ast::Name) -> ast::BindPat { 151pub fn bind_pat(name: ast::Name) -> ast::IdentPat {
152 return from_text(name.text()); 152 return from_text(name.text());
153 153
154 fn from_text(text: &str) -> ast::BindPat { 154 fn from_text(text: &str) -> ast::IdentPat {
155 ast_from_text(&format!("fn f({}: ())", text)) 155 ast_from_text(&format!("fn f({}: ())", text))
156 } 156 }
157} 157}
158 158
159pub fn placeholder_pat() -> ast::PlaceholderPat { 159pub fn placeholder_pat() -> ast::WildcardPat {
160 return from_text("_"); 160 return from_text("_");
161 161
162 fn from_text(text: &str) -> ast::PlaceholderPat { 162 fn from_text(text: &str) -> ast::WildcardPat {
163 ast_from_text(&format!("fn f({}: ())", text)) 163 ast_from_text(&format!("fn f({}: ())", text))
164 } 164 }
165} 165}
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs
index 69726fb93..4b4a72375 100644
--- a/crates/ra_syntax/src/ast/node_ext.rs
+++ b/crates/ra_syntax/src/ast/node_ext.rs
@@ -227,13 +227,13 @@ impl fmt::Display for NameOrNameRef {
227 } 227 }
228} 228}
229 229
230impl ast::RecordFieldPat { 230impl ast::RecordPatField {
231 /// Deals with field init shorthand 231 /// Deals with field init shorthand
232 pub fn field_name(&self) -> Option<NameOrNameRef> { 232 pub fn field_name(&self) -> Option<NameOrNameRef> {
233 if let Some(name_ref) = self.name_ref() { 233 if let Some(name_ref) = self.name_ref() {
234 return Some(NameOrNameRef::NameRef(name_ref)); 234 return Some(NameOrNameRef::NameRef(name_ref));
235 } 235 }
236 if let Some(ast::Pat::BindPat(pat)) = self.pat() { 236 if let Some(ast::Pat::IdentPat(pat)) = self.pat() {
237 let name = pat.name()?; 237 let name = pat.name()?;
238 return Some(NameOrNameRef::Name(name)); 238 return Some(NameOrNameRef::Name(name));
239 } 239 }
@@ -294,13 +294,13 @@ impl ast::SlicePat {
294 let prefix = args 294 let prefix = args
295 .peeking_take_while(|p| match p { 295 .peeking_take_while(|p| match p {
296 ast::Pat::DotDotPat(_) => false, 296 ast::Pat::DotDotPat(_) => false,
297 ast::Pat::BindPat(bp) => match bp.pat() { 297 ast::Pat::IdentPat(bp) => match bp.pat() {
298 Some(ast::Pat::DotDotPat(_)) => false, 298 Some(ast::Pat::DotDotPat(_)) => false,
299 _ => true, 299 _ => true,
300 }, 300 },
301 ast::Pat::RefPat(rp) => match rp.pat() { 301 ast::Pat::RefPat(rp) => match rp.pat() {
302 Some(ast::Pat::DotDotPat(_)) => false, 302 Some(ast::Pat::DotDotPat(_)) => false,
303 Some(ast::Pat::BindPat(bp)) => match bp.pat() { 303 Some(ast::Pat::IdentPat(bp)) => match bp.pat() {
304 Some(ast::Pat::DotDotPat(_)) => false, 304 Some(ast::Pat::DotDotPat(_)) => false,
305 _ => true, 305 _ => true,
306 }, 306 },