diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-13 10:36:30 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-13 10:36:30 +0000 |
commit | ff3d91bb0ce9e40059c7322ce562946b8088d3e7 (patch) | |
tree | c086e3d9fa0b75f51f924e27ac740cc0679b0be6 /crates/ra_syntax | |
parent | a2659abed8417bfb36fb5a448c52b8af1495ec51 (diff) | |
parent | 8e554ea5faa1158e084462162d5e1932db5c81c2 (diff) |
Merge #519
519: support ref-patterns r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 123a7a6b9..8bf439b60 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -348,6 +348,12 @@ impl UseTreeList { | |||
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | impl RefPat { | ||
352 | pub fn is_mut(&self) -> bool { | ||
353 | self.syntax().children().any(|n| n.kind() == MUT_KW) | ||
354 | } | ||
355 | } | ||
356 | |||
351 | fn child_opt<P: AstNode, C: AstNode>(parent: &P) -> Option<&C> { | 357 | fn child_opt<P: AstNode, C: AstNode>(parent: &P) -> Option<&C> { |
352 | children(parent).next() | 358 | children(parent).next() |
353 | } | 359 | } |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 1f6055115..f745cb1cb 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -2456,7 +2456,11 @@ impl AstNode for RefPat { | |||
2456 | } | 2456 | } |
2457 | 2457 | ||
2458 | 2458 | ||
2459 | impl RefPat {} | 2459 | impl RefPat { |
2460 | pub fn pat(&self) -> Option<&Pat> { | ||
2461 | super::child_opt(self) | ||
2462 | } | ||
2463 | } | ||
2460 | 2464 | ||
2461 | // ReferenceType | 2465 | // ReferenceType |
2462 | #[derive(Debug, PartialEq, Eq, Hash)] | 2466 | #[derive(Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index bddd96a5c..bac62fa04 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -462,7 +462,7 @@ Grammar( | |||
462 | ], | 462 | ], |
463 | ), | 463 | ), |
464 | 464 | ||
465 | "RefPat": (), | 465 | "RefPat": ( options: [ "Pat" ]), |
466 | "BindPat": ( traits: ["NameOwner"] ), | 466 | "BindPat": ( traits: ["NameOwner"] ), |
467 | "PlaceholderPat": (), | 467 | "PlaceholderPat": (), |
468 | "PathPat": (), | 468 | "PathPat": (), |