diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-09 10:24:19 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-09 10:24:19 +0100 |
commit | 85956932872481cf4813c5e7794d981a9edb4623 (patch) | |
tree | f915426894d00e918bfb2ad475633370baa6adaa /crates/ra_syntax/src/ast.rs | |
parent | 412eda73877c7a897561a70b83f55ee346e18a2c (diff) | |
parent | 8f01e62bb962fbe282344125f6ace54326efcaa3 (diff) |
Merge #3909
3909: Generate tokense r=matklad a=matklad
bors r+
🤖
Co-authored-by: Luca Barbieri <[email protected]>
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 26fafb469..ab0f44dd2 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -30,7 +30,7 @@ pub use self::{ | |||
30 | /// conversion itself has zero runtime cost: ast and syntax nodes have exactly | 30 | /// conversion itself has zero runtime cost: ast and syntax nodes have exactly |
31 | /// the same representation: a pointer to the tree root and a pointer to the | 31 | /// the same representation: a pointer to the tree root and a pointer to the |
32 | /// node itself. | 32 | /// node itself. |
33 | pub trait AstNode: std::fmt::Display { | 33 | pub trait AstNode { |
34 | fn can_cast(kind: SyntaxKind) -> bool | 34 | fn can_cast(kind: SyntaxKind) -> bool |
35 | where | 35 | where |
36 | Self: Sized; | 36 | Self: Sized; |
@@ -49,10 +49,16 @@ fn assert_ast_is_object_safe() { | |||
49 | 49 | ||
50 | /// Like `AstNode`, but wraps tokens rather than interior nodes. | 50 | /// Like `AstNode`, but wraps tokens rather than interior nodes. |
51 | pub trait AstToken { | 51 | pub trait AstToken { |
52 | fn cast(token: SyntaxToken) -> Option<Self> | 52 | fn can_cast(token: SyntaxKind) -> bool |
53 | where | 53 | where |
54 | Self: Sized; | 54 | Self: Sized; |
55 | |||
56 | fn cast(syntax: SyntaxToken) -> Option<Self> | ||
57 | where | ||
58 | Self: Sized; | ||
59 | |||
55 | fn syntax(&self) -> &SyntaxToken; | 60 | fn syntax(&self) -> &SyntaxToken; |
61 | |||
56 | fn text(&self) -> &SmolStr { | 62 | fn text(&self) -> &SmolStr { |
57 | self.syntax().text() | 63 | self.syntax().text() |
58 | } | 64 | } |