diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-27 12:18:55 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-27 12:18:55 +0000 |
commit | 2e2a6dd2fbeb4da16e602fa1902ab6bbd850b442 (patch) | |
tree | b42e6faf8618c3625e41d5a2011b4ffd145f22de /crates/ra_syntax/src/ast.rs | |
parent | 1927eb088ac9aa3851f77bb929296873ccb4faed (diff) | |
parent | d3ce69aee3297e683691ec0123f5a2584a8075a0 (diff) |
Merge #900
900: Add new trait ast::TypeAscriptionOwner r=vipentti a=vipentti
This trait should be implemented for nodes which have an ascribed type,
e.g. thing : Type. Such as let, const, static, param, named struct fields.
In addition, we update some places where previously we used node + node.type_ref() with `TypeAscriptionOwner` in the trait bounds.
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 56fb7c20c..81c709bfb 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -31,6 +31,12 @@ pub trait AstToken: AstNode { | |||
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | pub trait TypeAscriptionOwner: AstNode { | ||
35 | fn ascribed_type(&self) -> Option<&TypeRef> { | ||
36 | child_opt(self) | ||
37 | } | ||
38 | } | ||
39 | |||
34 | pub trait NameOwner: AstNode { | 40 | pub trait NameOwner: AstNode { |
35 | fn name(&self) -> Option<&Name> { | 41 | fn name(&self) -> Option<&Name> { |
36 | child_opt(self) | 42 | child_opt(self) |