diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_ext.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 505 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation/block.rs | 2 |
9 files changed, 268 insertions, 267 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 6ebe10ff6..0110300af 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -29,9 +29,9 @@ impl ast::BinExpr { | |||
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | impl ast::FnDef { | 32 | impl ast::Fn { |
33 | #[must_use] | 33 | #[must_use] |
34 | pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { | 34 | pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn { |
35 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); | 35 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); |
36 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { | 36 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { |
37 | old_body.syntax().clone().into() | 37 | old_body.syntax().clone().into() |
@@ -192,9 +192,9 @@ impl ast::RecordFieldList { | |||
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | impl ast::TypeAliasDef { | 195 | impl ast::TypeAlias { |
196 | #[must_use] | 196 | #[must_use] |
197 | pub fn remove_bounds(&self) -> ast::TypeAliasDef { | 197 | pub fn remove_bounds(&self) -> ast::TypeAlias { |
198 | let colon = match self.colon_token() { | 198 | let colon = match self.colon_token() { |
199 | Some(it) => it, | 199 | Some(it) => it, |
200 | None => return self.clone(), | 200 | None => return self.clone(), |
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs index 69c85c809..8692b9bb5 100644 --- a/crates/ra_syntax/src/ast/expr_ext.rs +++ b/crates/ra_syntax/src/ast/expr_ext.rs | |||
@@ -401,7 +401,7 @@ impl ast::BlockExpr { | |||
401 | Some(it) => it, | 401 | Some(it) => it, |
402 | None => return true, | 402 | None => return true, |
403 | }; | 403 | }; |
404 | !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) | 404 | !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index be657699f..ad8ccf1ce 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -79,19 +79,19 @@ impl ExternCrate { | |||
79 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 79 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
80 | } | 80 | } |
81 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 81 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
82 | pub struct FnDef { | 82 | pub struct Fn { |
83 | pub(crate) syntax: SyntaxNode, | 83 | pub(crate) syntax: SyntaxNode, |
84 | } | 84 | } |
85 | impl ast::AttrsOwner for FnDef {} | 85 | impl ast::AttrsOwner for Fn {} |
86 | impl ast::NameOwner for FnDef {} | 86 | impl ast::NameOwner for Fn {} |
87 | impl ast::VisibilityOwner for FnDef {} | 87 | impl ast::VisibilityOwner for Fn {} |
88 | impl ast::TypeParamsOwner for FnDef {} | 88 | impl ast::TypeParamsOwner for Fn {} |
89 | impl FnDef { | 89 | impl Fn { |
90 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
91 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
92 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 90 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
93 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | 91 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } |
92 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
94 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | 93 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } |
94 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
95 | pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } | 95 | pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } |
96 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 96 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
97 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 97 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
@@ -183,15 +183,15 @@ impl TraitDef { | |||
183 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } | 183 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } |
184 | } | 184 | } |
185 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 185 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
186 | pub struct TypeAliasDef { | 186 | pub struct TypeAlias { |
187 | pub(crate) syntax: SyntaxNode, | 187 | pub(crate) syntax: SyntaxNode, |
188 | } | 188 | } |
189 | impl ast::AttrsOwner for TypeAliasDef {} | 189 | impl ast::AttrsOwner for TypeAlias {} |
190 | impl ast::NameOwner for TypeAliasDef {} | 190 | impl ast::NameOwner for TypeAlias {} |
191 | impl ast::VisibilityOwner for TypeAliasDef {} | 191 | impl ast::VisibilityOwner for TypeAlias {} |
192 | impl ast::TypeParamsOwner for TypeAliasDef {} | 192 | impl ast::TypeParamsOwner for TypeAlias {} |
193 | impl ast::TypeBoundsOwner for TypeAliasDef {} | 193 | impl ast::TypeBoundsOwner for TypeAlias {} |
194 | impl TypeAliasDef { | 194 | impl TypeAlias { |
195 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 195 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
196 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | 196 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } |
197 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 197 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
@@ -303,7 +303,9 @@ impl UseTreeList { | |||
303 | pub struct Abi { | 303 | pub struct Abi { |
304 | pub(crate) syntax: SyntaxNode, | 304 | pub(crate) syntax: SyntaxNode, |
305 | } | 305 | } |
306 | impl Abi {} | 306 | impl Abi { |
307 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } | ||
308 | } | ||
307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 309 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
308 | pub struct TypeParamList { | 310 | pub struct TypeParamList { |
309 | pub(crate) syntax: SyntaxNode, | 311 | pub(crate) syntax: SyntaxNode, |
@@ -321,8 +323,9 @@ pub struct ParamList { | |||
321 | } | 323 | } |
322 | impl ParamList { | 324 | impl ParamList { |
323 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | 325 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
324 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | ||
325 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | 326 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } |
327 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | ||
328 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } | ||
326 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 329 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
327 | } | 330 | } |
328 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 331 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -355,6 +358,39 @@ impl BlockExpr { | |||
355 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 358 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
356 | } | 359 | } |
357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 360 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
361 | pub struct Param { | ||
362 | pub(crate) syntax: SyntaxNode, | ||
363 | } | ||
364 | impl ast::AttrsOwner for Param {} | ||
365 | impl ast::TypeAscriptionOwner for Param {} | ||
366 | impl Param { | ||
367 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
368 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
369 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | ||
370 | } | ||
371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
372 | pub struct SelfParam { | ||
373 | pub(crate) syntax: SyntaxNode, | ||
374 | } | ||
375 | impl ast::AttrsOwner for SelfParam {} | ||
376 | impl ast::TypeAscriptionOwner for SelfParam {} | ||
377 | impl SelfParam { | ||
378 | pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } | ||
379 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
380 | support::token(&self.syntax, T![lifetime]) | ||
381 | } | ||
382 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | ||
383 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
384 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
385 | } | ||
386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
387 | pub struct TypeBoundList { | ||
388 | pub(crate) syntax: SyntaxNode, | ||
389 | } | ||
390 | impl TypeBoundList { | ||
391 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
392 | } | ||
393 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
358 | pub struct RecordFieldDefList { | 394 | pub struct RecordFieldDefList { |
359 | pub(crate) syntax: SyntaxNode, | 395 | pub(crate) syntax: SyntaxNode, |
360 | } | 396 | } |
@@ -415,13 +451,6 @@ impl EnumVariant { | |||
415 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 451 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
416 | } | 452 | } |
417 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 453 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
418 | pub struct TypeBoundList { | ||
419 | pub(crate) syntax: SyntaxNode, | ||
420 | } | ||
421 | impl TypeBoundList { | ||
422 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
423 | } | ||
424 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
425 | pub struct AssocItemList { | 454 | pub struct AssocItemList { |
426 | pub(crate) syntax: SyntaxNode, | 455 | pub(crate) syntax: SyntaxNode, |
427 | } | 456 | } |
@@ -1173,32 +1202,6 @@ impl LetStmt { | |||
1173 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 1202 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
1174 | } | 1203 | } |
1175 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1204 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1176 | pub struct SelfParam { | ||
1177 | pub(crate) syntax: SyntaxNode, | ||
1178 | } | ||
1179 | impl ast::AttrsOwner for SelfParam {} | ||
1180 | impl ast::TypeAscriptionOwner for SelfParam {} | ||
1181 | impl SelfParam { | ||
1182 | pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } | ||
1183 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
1184 | support::token(&self.syntax, T![lifetime]) | ||
1185 | } | ||
1186 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | ||
1187 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1188 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
1189 | } | ||
1190 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1191 | pub struct Param { | ||
1192 | pub(crate) syntax: SyntaxNode, | ||
1193 | } | ||
1194 | impl ast::AttrsOwner for Param {} | ||
1195 | impl ast::TypeAscriptionOwner for Param {} | ||
1196 | impl Param { | ||
1197 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1198 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
1199 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | ||
1200 | } | ||
1201 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1202 | pub struct PathSegment { | 1205 | pub struct PathSegment { |
1203 | pub(crate) syntax: SyntaxNode, | 1206 | pub(crate) syntax: SyntaxNode, |
1204 | } | 1207 | } |
@@ -1274,14 +1277,14 @@ pub enum Item { | |||
1274 | EnumDef(EnumDef), | 1277 | EnumDef(EnumDef), |
1275 | ExternBlock(ExternBlock), | 1278 | ExternBlock(ExternBlock), |
1276 | ExternCrate(ExternCrate), | 1279 | ExternCrate(ExternCrate), |
1277 | FnDef(FnDef), | 1280 | Fn(Fn), |
1278 | ImplDef(ImplDef), | 1281 | ImplDef(ImplDef), |
1279 | MacroCall(MacroCall), | 1282 | MacroCall(MacroCall), |
1280 | Module(Module), | 1283 | Module(Module), |
1281 | StaticDef(StaticDef), | 1284 | StaticDef(StaticDef), |
1282 | StructDef(StructDef), | 1285 | StructDef(StructDef), |
1283 | TraitDef(TraitDef), | 1286 | TraitDef(TraitDef), |
1284 | TypeAliasDef(TypeAliasDef), | 1287 | TypeAlias(TypeAlias), |
1285 | UnionDef(UnionDef), | 1288 | UnionDef(UnionDef), |
1286 | Use(Use), | 1289 | Use(Use), |
1287 | } | 1290 | } |
@@ -1303,6 +1306,24 @@ pub enum TypeRef { | |||
1303 | DynTraitType(DynTraitType), | 1306 | DynTraitType(DynTraitType), |
1304 | } | 1307 | } |
1305 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1308 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1309 | pub enum Pat { | ||
1310 | OrPat(OrPat), | ||
1311 | ParenPat(ParenPat), | ||
1312 | RefPat(RefPat), | ||
1313 | BoxPat(BoxPat), | ||
1314 | BindPat(BindPat), | ||
1315 | PlaceholderPat(PlaceholderPat), | ||
1316 | DotDotPat(DotDotPat), | ||
1317 | PathPat(PathPat), | ||
1318 | RecordPat(RecordPat), | ||
1319 | TupleStructPat(TupleStructPat), | ||
1320 | TuplePat(TuplePat), | ||
1321 | SlicePat(SlicePat), | ||
1322 | RangePat(RangePat), | ||
1323 | LiteralPat(LiteralPat), | ||
1324 | MacroPat(MacroPat), | ||
1325 | } | ||
1326 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1306 | pub enum FieldDefList { | 1327 | pub enum FieldDefList { |
1307 | RecordFieldDefList(RecordFieldDefList), | 1328 | RecordFieldDefList(RecordFieldDefList), |
1308 | TupleFieldDefList(TupleFieldDefList), | 1329 | TupleFieldDefList(TupleFieldDefList), |
@@ -1343,32 +1364,14 @@ pub enum Expr { | |||
1343 | } | 1364 | } |
1344 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1365 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1345 | pub enum AssocItem { | 1366 | pub enum AssocItem { |
1346 | FnDef(FnDef), | 1367 | Fn(Fn), |
1347 | TypeAliasDef(TypeAliasDef), | 1368 | TypeAlias(TypeAlias), |
1348 | ConstDef(ConstDef), | 1369 | ConstDef(ConstDef), |
1349 | MacroCall(MacroCall), | 1370 | MacroCall(MacroCall), |
1350 | } | 1371 | } |
1351 | impl ast::AttrsOwner for AssocItem {} | 1372 | impl ast::AttrsOwner for AssocItem {} |
1352 | impl ast::NameOwner for AssocItem {} | 1373 | impl ast::NameOwner for AssocItem {} |
1353 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1374 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1354 | pub enum Pat { | ||
1355 | OrPat(OrPat), | ||
1356 | ParenPat(ParenPat), | ||
1357 | RefPat(RefPat), | ||
1358 | BoxPat(BoxPat), | ||
1359 | BindPat(BindPat), | ||
1360 | PlaceholderPat(PlaceholderPat), | ||
1361 | DotDotPat(DotDotPat), | ||
1362 | PathPat(PathPat), | ||
1363 | RecordPat(RecordPat), | ||
1364 | TupleStructPat(TupleStructPat), | ||
1365 | TuplePat(TuplePat), | ||
1366 | SlicePat(SlicePat), | ||
1367 | RangePat(RangePat), | ||
1368 | LiteralPat(LiteralPat), | ||
1369 | MacroPat(MacroPat), | ||
1370 | } | ||
1371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1372 | pub enum Stmt { | 1375 | pub enum Stmt { |
1373 | LetStmt(LetStmt), | 1376 | LetStmt(LetStmt), |
1374 | ExprStmt(ExprStmt), | 1377 | ExprStmt(ExprStmt), |
@@ -1381,7 +1384,7 @@ pub enum AttrInput { | |||
1381 | } | 1384 | } |
1382 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1383 | pub enum ExternItem { | 1386 | pub enum ExternItem { |
1384 | FnDef(FnDef), | 1387 | Fn(Fn), |
1385 | StaticDef(StaticDef), | 1388 | StaticDef(StaticDef), |
1386 | } | 1389 | } |
1387 | impl ast::AttrsOwner for ExternItem {} | 1390 | impl ast::AttrsOwner for ExternItem {} |
@@ -1463,8 +1466,8 @@ impl AstNode for ExternCrate { | |||
1463 | } | 1466 | } |
1464 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1467 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1465 | } | 1468 | } |
1466 | impl AstNode for FnDef { | 1469 | impl AstNode for Fn { |
1467 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } | 1470 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN } |
1468 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1471 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1469 | if Self::can_cast(syntax.kind()) { | 1472 | if Self::can_cast(syntax.kind()) { |
1470 | Some(Self { syntax }) | 1473 | Some(Self { syntax }) |
@@ -1540,8 +1543,8 @@ impl AstNode for TraitDef { | |||
1540 | } | 1543 | } |
1541 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1544 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1542 | } | 1545 | } |
1543 | impl AstNode for TypeAliasDef { | 1546 | impl AstNode for TypeAlias { |
1544 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } | 1547 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } |
1545 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1548 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1546 | if Self::can_cast(syntax.kind()) { | 1549 | if Self::can_cast(syntax.kind()) { |
1547 | Some(Self { syntax }) | 1550 | Some(Self { syntax }) |
@@ -1727,6 +1730,39 @@ impl AstNode for BlockExpr { | |||
1727 | } | 1730 | } |
1728 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1731 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1729 | } | 1732 | } |
1733 | impl AstNode for Param { | ||
1734 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | ||
1735 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1736 | if Self::can_cast(syntax.kind()) { | ||
1737 | Some(Self { syntax }) | ||
1738 | } else { | ||
1739 | None | ||
1740 | } | ||
1741 | } | ||
1742 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1743 | } | ||
1744 | impl AstNode for SelfParam { | ||
1745 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | ||
1746 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1747 | if Self::can_cast(syntax.kind()) { | ||
1748 | Some(Self { syntax }) | ||
1749 | } else { | ||
1750 | None | ||
1751 | } | ||
1752 | } | ||
1753 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1754 | } | ||
1755 | impl AstNode for TypeBoundList { | ||
1756 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1757 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1758 | if Self::can_cast(syntax.kind()) { | ||
1759 | Some(Self { syntax }) | ||
1760 | } else { | ||
1761 | None | ||
1762 | } | ||
1763 | } | ||
1764 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1765 | } | ||
1730 | impl AstNode for RecordFieldDefList { | 1766 | impl AstNode for RecordFieldDefList { |
1731 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } | 1767 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } |
1732 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1768 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1793,17 +1829,6 @@ impl AstNode for EnumVariant { | |||
1793 | } | 1829 | } |
1794 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1830 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1795 | } | 1831 | } |
1796 | impl AstNode for TypeBoundList { | ||
1797 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1798 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1799 | if Self::can_cast(syntax.kind()) { | ||
1800 | Some(Self { syntax }) | ||
1801 | } else { | ||
1802 | None | ||
1803 | } | ||
1804 | } | ||
1805 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1806 | } | ||
1807 | impl AstNode for AssocItemList { | 1832 | impl AstNode for AssocItemList { |
1808 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST } | 1833 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST } |
1809 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1834 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2673,28 +2698,6 @@ impl AstNode for LetStmt { | |||
2673 | } | 2698 | } |
2674 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2699 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2675 | } | 2700 | } |
2676 | impl AstNode for SelfParam { | ||
2677 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | ||
2678 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2679 | if Self::can_cast(syntax.kind()) { | ||
2680 | Some(Self { syntax }) | ||
2681 | } else { | ||
2682 | None | ||
2683 | } | ||
2684 | } | ||
2685 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2686 | } | ||
2687 | impl AstNode for Param { | ||
2688 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | ||
2689 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2690 | if Self::can_cast(syntax.kind()) { | ||
2691 | Some(Self { syntax }) | ||
2692 | } else { | ||
2693 | None | ||
2694 | } | ||
2695 | } | ||
2696 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2697 | } | ||
2698 | impl AstNode for PathSegment { | 2701 | impl AstNode for PathSegment { |
2699 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2702 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } |
2700 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2703 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2784,8 +2787,8 @@ impl From<ExternBlock> for Item { | |||
2784 | impl From<ExternCrate> for Item { | 2787 | impl From<ExternCrate> for Item { |
2785 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } | 2788 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } |
2786 | } | 2789 | } |
2787 | impl From<FnDef> for Item { | 2790 | impl From<Fn> for Item { |
2788 | fn from(node: FnDef) -> Item { Item::FnDef(node) } | 2791 | fn from(node: Fn) -> Item { Item::Fn(node) } |
2789 | } | 2792 | } |
2790 | impl From<ImplDef> for Item { | 2793 | impl From<ImplDef> for Item { |
2791 | fn from(node: ImplDef) -> Item { Item::ImplDef(node) } | 2794 | fn from(node: ImplDef) -> Item { Item::ImplDef(node) } |
@@ -2805,8 +2808,8 @@ impl From<StructDef> for Item { | |||
2805 | impl From<TraitDef> for Item { | 2808 | impl From<TraitDef> for Item { |
2806 | fn from(node: TraitDef) -> Item { Item::TraitDef(node) } | 2809 | fn from(node: TraitDef) -> Item { Item::TraitDef(node) } |
2807 | } | 2810 | } |
2808 | impl From<TypeAliasDef> for Item { | 2811 | impl From<TypeAlias> for Item { |
2809 | fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) } | 2812 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } |
2810 | } | 2813 | } |
2811 | impl From<UnionDef> for Item { | 2814 | impl From<UnionDef> for Item { |
2812 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } | 2815 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } |
@@ -2817,10 +2820,8 @@ impl From<Use> for Item { | |||
2817 | impl AstNode for Item { | 2820 | impl AstNode for Item { |
2818 | fn can_cast(kind: SyntaxKind) -> bool { | 2821 | fn can_cast(kind: SyntaxKind) -> bool { |
2819 | match kind { | 2822 | match kind { |
2820 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL | 2823 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL |
2821 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { | 2824 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION_DEF | USE => true, |
2822 | true | ||
2823 | } | ||
2824 | _ => false, | 2825 | _ => false, |
2825 | } | 2826 | } |
2826 | } | 2827 | } |
@@ -2830,14 +2831,14 @@ impl AstNode for Item { | |||
2830 | ENUM_DEF => Item::EnumDef(EnumDef { syntax }), | 2831 | ENUM_DEF => Item::EnumDef(EnumDef { syntax }), |
2831 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | 2832 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), |
2832 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), | 2833 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), |
2833 | FN_DEF => Item::FnDef(FnDef { syntax }), | 2834 | FN => Item::Fn(Fn { syntax }), |
2834 | IMPL_DEF => Item::ImplDef(ImplDef { syntax }), | 2835 | IMPL_DEF => Item::ImplDef(ImplDef { syntax }), |
2835 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | 2836 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), |
2836 | MODULE => Item::Module(Module { syntax }), | 2837 | MODULE => Item::Module(Module { syntax }), |
2837 | STATIC_DEF => Item::StaticDef(StaticDef { syntax }), | 2838 | STATIC_DEF => Item::StaticDef(StaticDef { syntax }), |
2838 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), | 2839 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), |
2839 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), | 2840 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), |
2840 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), | 2841 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), |
2841 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), | 2842 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), |
2842 | USE => Item::Use(Use { syntax }), | 2843 | USE => Item::Use(Use { syntax }), |
2843 | _ => return None, | 2844 | _ => return None, |
@@ -2850,14 +2851,14 @@ impl AstNode for Item { | |||
2850 | Item::EnumDef(it) => &it.syntax, | 2851 | Item::EnumDef(it) => &it.syntax, |
2851 | Item::ExternBlock(it) => &it.syntax, | 2852 | Item::ExternBlock(it) => &it.syntax, |
2852 | Item::ExternCrate(it) => &it.syntax, | 2853 | Item::ExternCrate(it) => &it.syntax, |
2853 | Item::FnDef(it) => &it.syntax, | 2854 | Item::Fn(it) => &it.syntax, |
2854 | Item::ImplDef(it) => &it.syntax, | 2855 | Item::ImplDef(it) => &it.syntax, |
2855 | Item::MacroCall(it) => &it.syntax, | 2856 | Item::MacroCall(it) => &it.syntax, |
2856 | Item::Module(it) => &it.syntax, | 2857 | Item::Module(it) => &it.syntax, |
2857 | Item::StaticDef(it) => &it.syntax, | 2858 | Item::StaticDef(it) => &it.syntax, |
2858 | Item::StructDef(it) => &it.syntax, | 2859 | Item::StructDef(it) => &it.syntax, |
2859 | Item::TraitDef(it) => &it.syntax, | 2860 | Item::TraitDef(it) => &it.syntax, |
2860 | Item::TypeAliasDef(it) => &it.syntax, | 2861 | Item::TypeAlias(it) => &it.syntax, |
2861 | Item::UnionDef(it) => &it.syntax, | 2862 | Item::UnionDef(it) => &it.syntax, |
2862 | Item::Use(it) => &it.syntax, | 2863 | Item::Use(it) => &it.syntax, |
2863 | } | 2864 | } |
@@ -2948,6 +2949,101 @@ impl AstNode for TypeRef { | |||
2948 | } | 2949 | } |
2949 | } | 2950 | } |
2950 | } | 2951 | } |
2952 | impl From<OrPat> for Pat { | ||
2953 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
2954 | } | ||
2955 | impl From<ParenPat> for Pat { | ||
2956 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
2957 | } | ||
2958 | impl From<RefPat> for Pat { | ||
2959 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
2960 | } | ||
2961 | impl From<BoxPat> for Pat { | ||
2962 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
2963 | } | ||
2964 | impl From<BindPat> for Pat { | ||
2965 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
2966 | } | ||
2967 | impl From<PlaceholderPat> for Pat { | ||
2968 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
2969 | } | ||
2970 | impl From<DotDotPat> for Pat { | ||
2971 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
2972 | } | ||
2973 | impl From<PathPat> for Pat { | ||
2974 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
2975 | } | ||
2976 | impl From<RecordPat> for Pat { | ||
2977 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
2978 | } | ||
2979 | impl From<TupleStructPat> for Pat { | ||
2980 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
2981 | } | ||
2982 | impl From<TuplePat> for Pat { | ||
2983 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
2984 | } | ||
2985 | impl From<SlicePat> for Pat { | ||
2986 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
2987 | } | ||
2988 | impl From<RangePat> for Pat { | ||
2989 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
2990 | } | ||
2991 | impl From<LiteralPat> for Pat { | ||
2992 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
2993 | } | ||
2994 | impl From<MacroPat> for Pat { | ||
2995 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
2996 | } | ||
2997 | impl AstNode for Pat { | ||
2998 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2999 | match kind { | ||
3000 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
3001 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
3002 | | LITERAL_PAT | MACRO_PAT => true, | ||
3003 | _ => false, | ||
3004 | } | ||
3005 | } | ||
3006 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3007 | let res = match syntax.kind() { | ||
3008 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
3009 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
3010 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
3011 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3012 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3013 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3014 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3015 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3016 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3017 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3018 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3019 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3020 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3021 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3022 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3023 | _ => return None, | ||
3024 | }; | ||
3025 | Some(res) | ||
3026 | } | ||
3027 | fn syntax(&self) -> &SyntaxNode { | ||
3028 | match self { | ||
3029 | Pat::OrPat(it) => &it.syntax, | ||
3030 | Pat::ParenPat(it) => &it.syntax, | ||
3031 | Pat::RefPat(it) => &it.syntax, | ||
3032 | Pat::BoxPat(it) => &it.syntax, | ||
3033 | Pat::BindPat(it) => &it.syntax, | ||
3034 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3035 | Pat::DotDotPat(it) => &it.syntax, | ||
3036 | Pat::PathPat(it) => &it.syntax, | ||
3037 | Pat::RecordPat(it) => &it.syntax, | ||
3038 | Pat::TupleStructPat(it) => &it.syntax, | ||
3039 | Pat::TuplePat(it) => &it.syntax, | ||
3040 | Pat::SlicePat(it) => &it.syntax, | ||
3041 | Pat::RangePat(it) => &it.syntax, | ||
3042 | Pat::LiteralPat(it) => &it.syntax, | ||
3043 | Pat::MacroPat(it) => &it.syntax, | ||
3044 | } | ||
3045 | } | ||
3046 | } | ||
2951 | impl From<RecordFieldDefList> for FieldDefList { | 3047 | impl From<RecordFieldDefList> for FieldDefList { |
2952 | fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } | 3048 | fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } |
2953 | } | 3049 | } |
@@ -3157,11 +3253,11 @@ impl AstNode for Expr { | |||
3157 | } | 3253 | } |
3158 | } | 3254 | } |
3159 | } | 3255 | } |
3160 | impl From<FnDef> for AssocItem { | 3256 | impl From<Fn> for AssocItem { |
3161 | fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) } | 3257 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } |
3162 | } | 3258 | } |
3163 | impl From<TypeAliasDef> for AssocItem { | 3259 | impl From<TypeAlias> for AssocItem { |
3164 | fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } | 3260 | fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) } |
3165 | } | 3261 | } |
3166 | impl From<ConstDef> for AssocItem { | 3262 | impl From<ConstDef> for AssocItem { |
3167 | fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } | 3263 | fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } |
@@ -3172,14 +3268,14 @@ impl From<MacroCall> for AssocItem { | |||
3172 | impl AstNode for AssocItem { | 3268 | impl AstNode for AssocItem { |
3173 | fn can_cast(kind: SyntaxKind) -> bool { | 3269 | fn can_cast(kind: SyntaxKind) -> bool { |
3174 | match kind { | 3270 | match kind { |
3175 | FN_DEF | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, | 3271 | FN | TYPE_ALIAS | CONST_DEF | MACRO_CALL => true, |
3176 | _ => false, | 3272 | _ => false, |
3177 | } | 3273 | } |
3178 | } | 3274 | } |
3179 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3275 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3180 | let res = match syntax.kind() { | 3276 | let res = match syntax.kind() { |
3181 | FN_DEF => AssocItem::FnDef(FnDef { syntax }), | 3277 | FN => AssocItem::Fn(Fn { syntax }), |
3182 | TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), | 3278 | TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }), |
3183 | CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), | 3279 | CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), |
3184 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), | 3280 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), |
3185 | _ => return None, | 3281 | _ => return None, |
@@ -3188,108 +3284,13 @@ impl AstNode for AssocItem { | |||
3188 | } | 3284 | } |
3189 | fn syntax(&self) -> &SyntaxNode { | 3285 | fn syntax(&self) -> &SyntaxNode { |
3190 | match self { | 3286 | match self { |
3191 | AssocItem::FnDef(it) => &it.syntax, | 3287 | AssocItem::Fn(it) => &it.syntax, |
3192 | AssocItem::TypeAliasDef(it) => &it.syntax, | 3288 | AssocItem::TypeAlias(it) => &it.syntax, |
3193 | AssocItem::ConstDef(it) => &it.syntax, | 3289 | AssocItem::ConstDef(it) => &it.syntax, |
3194 | AssocItem::MacroCall(it) => &it.syntax, | 3290 | AssocItem::MacroCall(it) => &it.syntax, |
3195 | } | 3291 | } |
3196 | } | 3292 | } |
3197 | } | 3293 | } |
3198 | impl From<OrPat> for Pat { | ||
3199 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
3200 | } | ||
3201 | impl From<ParenPat> for Pat { | ||
3202 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
3203 | } | ||
3204 | impl From<RefPat> for Pat { | ||
3205 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
3206 | } | ||
3207 | impl From<BoxPat> for Pat { | ||
3208 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
3209 | } | ||
3210 | impl From<BindPat> for Pat { | ||
3211 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
3212 | } | ||
3213 | impl From<PlaceholderPat> for Pat { | ||
3214 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
3215 | } | ||
3216 | impl From<DotDotPat> for Pat { | ||
3217 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
3218 | } | ||
3219 | impl From<PathPat> for Pat { | ||
3220 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
3221 | } | ||
3222 | impl From<RecordPat> for Pat { | ||
3223 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
3224 | } | ||
3225 | impl From<TupleStructPat> for Pat { | ||
3226 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
3227 | } | ||
3228 | impl From<TuplePat> for Pat { | ||
3229 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
3230 | } | ||
3231 | impl From<SlicePat> for Pat { | ||
3232 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
3233 | } | ||
3234 | impl From<RangePat> for Pat { | ||
3235 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
3236 | } | ||
3237 | impl From<LiteralPat> for Pat { | ||
3238 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
3239 | } | ||
3240 | impl From<MacroPat> for Pat { | ||
3241 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
3242 | } | ||
3243 | impl AstNode for Pat { | ||
3244 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3245 | match kind { | ||
3246 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
3247 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
3248 | | LITERAL_PAT | MACRO_PAT => true, | ||
3249 | _ => false, | ||
3250 | } | ||
3251 | } | ||
3252 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3253 | let res = match syntax.kind() { | ||
3254 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
3255 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
3256 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
3257 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3258 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3259 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3260 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3261 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3262 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3263 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3264 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3265 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3266 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3267 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3268 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3269 | _ => return None, | ||
3270 | }; | ||
3271 | Some(res) | ||
3272 | } | ||
3273 | fn syntax(&self) -> &SyntaxNode { | ||
3274 | match self { | ||
3275 | Pat::OrPat(it) => &it.syntax, | ||
3276 | Pat::ParenPat(it) => &it.syntax, | ||
3277 | Pat::RefPat(it) => &it.syntax, | ||
3278 | Pat::BoxPat(it) => &it.syntax, | ||
3279 | Pat::BindPat(it) => &it.syntax, | ||
3280 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3281 | Pat::DotDotPat(it) => &it.syntax, | ||
3282 | Pat::PathPat(it) => &it.syntax, | ||
3283 | Pat::RecordPat(it) => &it.syntax, | ||
3284 | Pat::TupleStructPat(it) => &it.syntax, | ||
3285 | Pat::TuplePat(it) => &it.syntax, | ||
3286 | Pat::SlicePat(it) => &it.syntax, | ||
3287 | Pat::RangePat(it) => &it.syntax, | ||
3288 | Pat::LiteralPat(it) => &it.syntax, | ||
3289 | Pat::MacroPat(it) => &it.syntax, | ||
3290 | } | ||
3291 | } | ||
3292 | } | ||
3293 | impl From<LetStmt> for Stmt { | 3294 | impl From<LetStmt> for Stmt { |
3294 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3295 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3295 | } | 3296 | } |
@@ -3346,8 +3347,8 @@ impl AstNode for AttrInput { | |||
3346 | } | 3347 | } |
3347 | } | 3348 | } |
3348 | } | 3349 | } |
3349 | impl From<FnDef> for ExternItem { | 3350 | impl From<Fn> for ExternItem { |
3350 | fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } | 3351 | fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } |
3351 | } | 3352 | } |
3352 | impl From<StaticDef> for ExternItem { | 3353 | impl From<StaticDef> for ExternItem { |
3353 | fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } | 3354 | fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } |
@@ -3355,13 +3356,13 @@ impl From<StaticDef> for ExternItem { | |||
3355 | impl AstNode for ExternItem { | 3356 | impl AstNode for ExternItem { |
3356 | fn can_cast(kind: SyntaxKind) -> bool { | 3357 | fn can_cast(kind: SyntaxKind) -> bool { |
3357 | match kind { | 3358 | match kind { |
3358 | FN_DEF | STATIC_DEF => true, | 3359 | FN | STATIC_DEF => true, |
3359 | _ => false, | 3360 | _ => false, |
3360 | } | 3361 | } |
3361 | } | 3362 | } |
3362 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3363 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3363 | let res = match syntax.kind() { | 3364 | let res = match syntax.kind() { |
3364 | FN_DEF => ExternItem::FnDef(FnDef { syntax }), | 3365 | FN => ExternItem::Fn(Fn { syntax }), |
3365 | STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), | 3366 | STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), |
3366 | _ => return None, | 3367 | _ => return None, |
3367 | }; | 3368 | }; |
@@ -3369,7 +3370,7 @@ impl AstNode for ExternItem { | |||
3369 | } | 3370 | } |
3370 | fn syntax(&self) -> &SyntaxNode { | 3371 | fn syntax(&self) -> &SyntaxNode { |
3371 | match self { | 3372 | match self { |
3372 | ExternItem::FnDef(it) => &it.syntax, | 3373 | ExternItem::Fn(it) => &it.syntax, |
3373 | ExternItem::StaticDef(it) => &it.syntax, | 3374 | ExternItem::StaticDef(it) => &it.syntax, |
3374 | } | 3375 | } |
3375 | } | 3376 | } |
@@ -3417,22 +3418,22 @@ impl std::fmt::Display for TypeRef { | |||
3417 | std::fmt::Display::fmt(self.syntax(), f) | 3418 | std::fmt::Display::fmt(self.syntax(), f) |
3418 | } | 3419 | } |
3419 | } | 3420 | } |
3420 | impl std::fmt::Display for FieldDefList { | 3421 | impl std::fmt::Display for Pat { |
3421 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3422 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3422 | std::fmt::Display::fmt(self.syntax(), f) | 3423 | std::fmt::Display::fmt(self.syntax(), f) |
3423 | } | 3424 | } |
3424 | } | 3425 | } |
3425 | impl std::fmt::Display for Expr { | 3426 | impl std::fmt::Display for FieldDefList { |
3426 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3427 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3427 | std::fmt::Display::fmt(self.syntax(), f) | 3428 | std::fmt::Display::fmt(self.syntax(), f) |
3428 | } | 3429 | } |
3429 | } | 3430 | } |
3430 | impl std::fmt::Display for AssocItem { | 3431 | impl std::fmt::Display for Expr { |
3431 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3432 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3432 | std::fmt::Display::fmt(self.syntax(), f) | 3433 | std::fmt::Display::fmt(self.syntax(), f) |
3433 | } | 3434 | } |
3434 | } | 3435 | } |
3435 | impl std::fmt::Display for Pat { | 3436 | impl std::fmt::Display for AssocItem { |
3436 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3437 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3437 | std::fmt::Display::fmt(self.syntax(), f) | 3438 | std::fmt::Display::fmt(self.syntax(), f) |
3438 | } | 3439 | } |
@@ -3487,7 +3488,7 @@ impl std::fmt::Display for ExternCrate { | |||
3487 | std::fmt::Display::fmt(self.syntax(), f) | 3488 | std::fmt::Display::fmt(self.syntax(), f) |
3488 | } | 3489 | } |
3489 | } | 3490 | } |
3490 | impl std::fmt::Display for FnDef { | 3491 | impl std::fmt::Display for Fn { |
3491 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3492 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3492 | std::fmt::Display::fmt(self.syntax(), f) | 3493 | std::fmt::Display::fmt(self.syntax(), f) |
3493 | } | 3494 | } |
@@ -3522,7 +3523,7 @@ impl std::fmt::Display for TraitDef { | |||
3522 | std::fmt::Display::fmt(self.syntax(), f) | 3523 | std::fmt::Display::fmt(self.syntax(), f) |
3523 | } | 3524 | } |
3524 | } | 3525 | } |
3525 | impl std::fmt::Display for TypeAliasDef { | 3526 | impl std::fmt::Display for TypeAlias { |
3526 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3527 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3527 | std::fmt::Display::fmt(self.syntax(), f) | 3528 | std::fmt::Display::fmt(self.syntax(), f) |
3528 | } | 3529 | } |
@@ -3607,6 +3608,21 @@ impl std::fmt::Display for BlockExpr { | |||
3607 | std::fmt::Display::fmt(self.syntax(), f) | 3608 | std::fmt::Display::fmt(self.syntax(), f) |
3608 | } | 3609 | } |
3609 | } | 3610 | } |
3611 | impl std::fmt::Display for Param { | ||
3612 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3613 | std::fmt::Display::fmt(self.syntax(), f) | ||
3614 | } | ||
3615 | } | ||
3616 | impl std::fmt::Display for SelfParam { | ||
3617 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3618 | std::fmt::Display::fmt(self.syntax(), f) | ||
3619 | } | ||
3620 | } | ||
3621 | impl std::fmt::Display for TypeBoundList { | ||
3622 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3623 | std::fmt::Display::fmt(self.syntax(), f) | ||
3624 | } | ||
3625 | } | ||
3610 | impl std::fmt::Display for RecordFieldDefList { | 3626 | impl std::fmt::Display for RecordFieldDefList { |
3611 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3627 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3612 | std::fmt::Display::fmt(self.syntax(), f) | 3628 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3637,11 +3653,6 @@ impl std::fmt::Display for EnumVariant { | |||
3637 | std::fmt::Display::fmt(self.syntax(), f) | 3653 | std::fmt::Display::fmt(self.syntax(), f) |
3638 | } | 3654 | } |
3639 | } | 3655 | } |
3640 | impl std::fmt::Display for TypeBoundList { | ||
3641 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3642 | std::fmt::Display::fmt(self.syntax(), f) | ||
3643 | } | ||
3644 | } | ||
3645 | impl std::fmt::Display for AssocItemList { | 3656 | impl std::fmt::Display for AssocItemList { |
3646 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3657 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3647 | std::fmt::Display::fmt(self.syntax(), f) | 3658 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4037,16 +4048,6 @@ impl std::fmt::Display for LetStmt { | |||
4037 | std::fmt::Display::fmt(self.syntax(), f) | 4048 | std::fmt::Display::fmt(self.syntax(), f) |
4038 | } | 4049 | } |
4039 | } | 4050 | } |
4040 | impl std::fmt::Display for SelfParam { | ||
4041 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4042 | std::fmt::Display::fmt(self.syntax(), f) | ||
4043 | } | ||
4044 | } | ||
4045 | impl std::fmt::Display for Param { | ||
4046 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4047 | std::fmt::Display::fmt(self.syntax(), f) | ||
4048 | } | ||
4049 | } | ||
4050 | impl std::fmt::Display for PathSegment { | 4051 | impl std::fmt::Display for PathSegment { |
4051 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4052 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4052 | std::fmt::Display::fmt(self.syntax(), f) | 4053 | std::fmt::Display::fmt(self.syntax(), f) |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 0ff69bc2d..ef235680f 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -294,7 +294,7 @@ pub fn fn_def( | |||
294 | type_params: Option<ast::TypeParamList>, | 294 | type_params: Option<ast::TypeParamList>, |
295 | params: ast::ParamList, | 295 | params: ast::ParamList, |
296 | body: ast::BlockExpr, | 296 | body: ast::BlockExpr, |
297 | ) -> ast::FnDef { | 297 | ) -> ast::Fn { |
298 | let type_params = | 298 | let type_params = |
299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; | 299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; |
300 | let visibility = match visibility { | 300 | let visibility = match visibility { |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 242900643..a7a301d6b 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -474,7 +474,7 @@ impl ast::TokenTree { | |||
474 | } | 474 | } |
475 | 475 | ||
476 | impl ast::DocCommentsOwner for ast::SourceFile {} | 476 | impl ast::DocCommentsOwner for ast::SourceFile {} |
477 | impl ast::DocCommentsOwner for ast::FnDef {} | 477 | impl ast::DocCommentsOwner for ast::Fn {} |
478 | impl ast::DocCommentsOwner for ast::StructDef {} | 478 | impl ast::DocCommentsOwner for ast::StructDef {} |
479 | impl ast::DocCommentsOwner for ast::UnionDef {} | 479 | impl ast::DocCommentsOwner for ast::UnionDef {} |
480 | impl ast::DocCommentsOwner for ast::RecordFieldDef {} | 480 | impl ast::DocCommentsOwner for ast::RecordFieldDef {} |
@@ -485,6 +485,6 @@ impl ast::DocCommentsOwner for ast::TraitDef {} | |||
485 | impl ast::DocCommentsOwner for ast::Module {} | 485 | impl ast::DocCommentsOwner for ast::Module {} |
486 | impl ast::DocCommentsOwner for ast::StaticDef {} | 486 | impl ast::DocCommentsOwner for ast::StaticDef {} |
487 | impl ast::DocCommentsOwner for ast::ConstDef {} | 487 | impl ast::DocCommentsOwner for ast::ConstDef {} |
488 | impl ast::DocCommentsOwner for ast::TypeAliasDef {} | 488 | impl ast::DocCommentsOwner for ast::TypeAlias {} |
489 | impl ast::DocCommentsOwner for ast::ImplDef {} | 489 | impl ast::DocCommentsOwner for ast::ImplDef {} |
490 | impl ast::DocCommentsOwner for ast::MacroCall {} | 490 | impl ast::DocCommentsOwner for ast::MacroCall {} |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 219dd0b07..6203b6206 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -255,11 +255,11 @@ fn api_walkthrough() { | |||
255 | let mut func = None; | 255 | let mut func = None; |
256 | for item in file.items() { | 256 | for item in file.items() { |
257 | match item { | 257 | match item { |
258 | ast::Item::FnDef(f) => func = Some(f), | 258 | ast::Item::Fn(f) => func = Some(f), |
259 | _ => unreachable!(), | 259 | _ => unreachable!(), |
260 | } | 260 | } |
261 | } | 261 | } |
262 | let func: ast::FnDef = func.unwrap(); | 262 | let func: ast::Fn = func.unwrap(); |
263 | 263 | ||
264 | // Each AST node has a bunch of getters for children. All getters return | 264 | // Each AST node has a bunch of getters for children. All getters return |
265 | // `Option`s though, to account for incomplete code. Some getters are common | 265 | // `Option`s though, to account for incomplete code. Some getters are common |
@@ -316,7 +316,7 @@ fn api_walkthrough() { | |||
316 | ); | 316 | ); |
317 | 317 | ||
318 | // As well as some iterator helpers: | 318 | // As well as some iterator helpers: |
319 | let f = expr_syntax.ancestors().find_map(ast::FnDef::cast); | 319 | let f = expr_syntax.ancestors().find_map(ast::Fn::cast); |
320 | assert_eq!(f, Some(func)); | 320 | assert_eq!(f, Some(func)); |
321 | assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); | 321 | assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); |
322 | assert_eq!( | 322 | assert_eq!( |
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index c6b30a02a..87a7acd09 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs | |||
@@ -146,7 +146,7 @@ fn n_attached_trivias<'a>( | |||
146 | trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, | 146 | trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, |
147 | ) -> usize { | 147 | ) -> usize { |
148 | match kind { | 148 | match kind { |
149 | MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | 149 | MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN |
150 | | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { | 150 | | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { |
151 | let mut res = 0; | 151 | let mut res = 0; |
152 | let mut trivias = trivias.enumerate().peekable(); | 152 | let mut trivias = trivias.enumerate().peekable(); |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index fdec48fb0..6a2749381 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -4,7 +4,7 @@ mod block; | |||
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | ast, match_ast, AstNode, SyntaxError, | 6 | ast, match_ast, AstNode, SyntaxError, |
7 | SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, | 7 | SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN, INT_NUMBER, STRING, TYPE_ALIAS}, |
8 | SyntaxNode, SyntaxToken, TextSize, T, | 8 | SyntaxNode, SyntaxToken, TextSize, T, |
9 | }; | 9 | }; |
10 | use rustc_lexer::unescape::{ | 10 | use rustc_lexer::unescape::{ |
@@ -200,7 +200,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) { | |||
200 | None => return, | 200 | None => return, |
201 | }; | 201 | }; |
202 | match parent.kind() { | 202 | match parent.kind() { |
203 | FN_DEF | CONST_DEF | TYPE_ALIAS_DEF => (), | 203 | FN | CONST_DEF | TYPE_ALIAS => (), |
204 | _ => return, | 204 | _ => return, |
205 | } | 205 | } |
206 | 206 | ||
diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs index 2c08f7e6e..ad9901468 100644 --- a/crates/ra_syntax/src/validation/block.rs +++ b/crates/ra_syntax/src/validation/block.rs | |||
@@ -9,7 +9,7 @@ use crate::{ | |||
9 | pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { | 9 | pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { |
10 | if let Some(parent) = block.syntax().parent() { | 10 | if let Some(parent) = block.syntax().parent() { |
11 | match parent.kind() { | 11 | match parent.kind() { |
12 | FN_DEF | EXPR_STMT | BLOCK_EXPR => return, | 12 | FN | EXPR_STMT | BLOCK_EXPR => return, |
13 | _ => {} | 13 | _ => {} |
14 | } | 14 | } |
15 | } | 15 | } |