diff options
author | Kirill Bulatov <[email protected]> | 2019-07-21 22:10:29 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2019-07-21 22:10:29 +0100 |
commit | 31aef808d96b779dbc8ce41e27857965e79bd96f (patch) | |
tree | 254d69a1ec3abe6d70b2dd9737ef699f33f88f62 /crates/ra_syntax/src/ast | |
parent | ba76017d2eb1b7606106c15478ac658dc32b6dbd (diff) | |
parent | d690249bc81bc265cb3d1836c2922325f4fdb8af (diff) |
Merge branch 'master' into add-type-lenses
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 13 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 5 |
2 files changed, 6 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 139bd3ec0..f9190d877 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use crate::{ | 3 | use crate::{ |
4 | ast::{self, child_opt, children, AstChildren, AstNode}, | 4 | ast::{self, child_opt, children, AstChildren, AstNode}, |
5 | SmolStr, SyntaxElement, | 5 | SmolStr, |
6 | SyntaxKind::*, | 6 | SyntaxKind::*, |
7 | SyntaxToken, T, | 7 | SyntaxToken, T, |
8 | }; | 8 | }; |
@@ -229,14 +229,11 @@ pub enum LiteralKind { | |||
229 | 229 | ||
230 | impl ast::Literal { | 230 | impl ast::Literal { |
231 | pub fn token(&self) -> SyntaxToken { | 231 | pub fn token(&self) -> SyntaxToken { |
232 | let elem = self | 232 | self.syntax() |
233 | .syntax() | ||
234 | .children_with_tokens() | 233 | .children_with_tokens() |
235 | .find(|e| e.kind() != ATTR && !e.kind().is_trivia()); | 234 | .find(|e| e.kind() != ATTR && !e.kind().is_trivia()) |
236 | match elem { | 235 | .and_then(|e| e.into_token()) |
237 | Some(SyntaxElement::Token(token)) => token, | 236 | .unwrap() |
238 | _ => unreachable!(), | ||
239 | } | ||
240 | } | 237 | } |
241 | 238 | ||
242 | pub fn kind(&self) -> LiteralKind { | 239 | pub fn kind(&self) -> LiteralKind { |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 753fc42c6..d4873b39a 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -24,10 +24,7 @@ impl ast::NameRef { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | fn text_of_first_token(node: &SyntaxNode) -> &SmolStr { | 26 | fn text_of_first_token(node: &SyntaxNode) -> &SmolStr { |
27 | match node.0.green().children().first() { | 27 | node.green().children().first().and_then(|it| it.as_token()).unwrap().text() |
28 | Some(rowan::GreenElement::Token(it)) => it.text(), | ||
29 | _ => panic!(), | ||
30 | } | ||
31 | } | 28 | } |
32 | 29 | ||
33 | impl ast::Attr { | 30 | impl ast::Attr { |