diff options
author | Seivan Heidari <[email protected]> | 2019-11-21 00:11:41 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-11-21 00:11:41 +0000 |
commit | 358a1bcd708c622836723e5201b6de77cc9ff327 (patch) | |
tree | aeff9c96a6059fa2b02e7c87ec88753bc7993d8d /crates/ra_syntax | |
parent | 1e2d090ab8a9bda18f148b894b7948eb05b976e6 (diff) | |
parent | 612a72fc4ea4376920f2a7da7b3c334227c1716c (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 7 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 5 | ||||
-rw-r--r-- | crates/ra_syntax/src/ptr.rs | 10 |
4 files changed, 18 insertions, 10 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 2b381dcdb..de506d7cd 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -3625,8 +3625,11 @@ impl AstNode for TypeParam { | |||
3625 | impl ast::NameOwner for TypeParam {} | 3625 | impl ast::NameOwner for TypeParam {} |
3626 | impl ast::AttrsOwner for TypeParam {} | 3626 | impl ast::AttrsOwner for TypeParam {} |
3627 | impl ast::TypeBoundsOwner for TypeParam {} | 3627 | impl ast::TypeBoundsOwner for TypeParam {} |
3628 | impl ast::DefaultTypeParamOwner for TypeParam {} | 3628 | impl TypeParam { |
3629 | impl TypeParam {} | 3629 | pub fn default_type(&self) -> Option<TypeRef> { |
3630 | AstChildren::new(&self.syntax).next() | ||
3631 | } | ||
3632 | } | ||
3630 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3633 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3631 | pub struct TypeParamList { | 3634 | pub struct TypeParamList { |
3632 | pub(crate) syntax: SyntaxNode, | 3635 | pub(crate) syntax: SyntaxNode, |
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index c2b005886..f99984fe0 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -163,9 +163,3 @@ impl Iterator for CommentIter { | |||
163 | self.iter.by_ref().find_map(|el| el.into_token().and_then(ast::Comment::cast)) | 163 | self.iter.by_ref().find_map(|el| el.into_token().and_then(ast::Comment::cast)) |
164 | } | 164 | } |
165 | } | 165 | } |
166 | |||
167 | pub trait DefaultTypeParamOwner: AstNode { | ||
168 | fn default_type(&self) -> Option<ast::PathType> { | ||
169 | child_opt(self) | ||
170 | } | ||
171 | } | ||
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 70d85a8e6..88d1dc109 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -587,7 +587,10 @@ Grammar( | |||
587 | ("lifetime_params", "LifetimeParam" ), | 587 | ("lifetime_params", "LifetimeParam" ), |
588 | ] | 588 | ] |
589 | ), | 589 | ), |
590 | "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ), | 590 | "TypeParam": ( |
591 | options: [("default_type", "TypeRef")], | ||
592 | traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"], | ||
593 | ), | ||
591 | "LifetimeParam": ( | 594 | "LifetimeParam": ( |
592 | traits: ["AttrsOwner"], | 595 | traits: ["AttrsOwner"], |
593 | ), | 596 | ), |
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs index 31167cada..e049fce61 100644 --- a/crates/ra_syntax/src/ptr.rs +++ b/crates/ra_syntax/src/ptr.rs | |||
@@ -43,7 +43,7 @@ impl SyntaxNodePtr { | |||
43 | } | 43 | } |
44 | 44 | ||
45 | /// Like `SyntaxNodePtr`, but remembers the type of node | 45 | /// Like `SyntaxNodePtr`, but remembers the type of node |
46 | #[derive(Debug, PartialEq, Eq, Hash)] | 46 | #[derive(Debug, Hash)] |
47 | pub struct AstPtr<N: AstNode> { | 47 | pub struct AstPtr<N: AstNode> { |
48 | raw: SyntaxNodePtr, | 48 | raw: SyntaxNodePtr, |
49 | _ty: PhantomData<fn() -> N>, | 49 | _ty: PhantomData<fn() -> N>, |
@@ -56,6 +56,14 @@ impl<N: AstNode> Clone for AstPtr<N> { | |||
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | impl<N: AstNode> Eq for AstPtr<N> {} | ||
60 | |||
61 | impl<N: AstNode> PartialEq for AstPtr<N> { | ||
62 | fn eq(&self, other: &AstPtr<N>) -> bool { | ||
63 | self.raw == other.raw | ||
64 | } | ||
65 | } | ||
66 | |||
59 | impl<N: AstNode> AstPtr<N> { | 67 | impl<N: AstNode> AstPtr<N> { |
60 | pub fn new(node: &N) -> AstPtr<N> { | 68 | pub fn new(node: &N) -> AstPtr<N> { |
61 | AstPtr { raw: SyntaxNodePtr::new(node.syntax()), _ty: PhantomData } | 69 | AstPtr { raw: SyntaxNodePtr::new(node.syntax()), _ty: PhantomData } |