From c9cfd57eeaa53657c0af7b9c4ba74d6b7b9889ed Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Jul 2019 20:04:34 +0300 Subject: switch to upstream rowan's API --- crates/ra_syntax/src/ast/expr_extensions.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/ra_syntax/src/ast/expr_extensions.rs') 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 @@ use crate::{ ast::{self, child_opt, children, AstChildren, AstNode}, - SmolStr, SyntaxElement, + SmolStr, SyntaxKind::*, SyntaxToken, T, }; @@ -229,14 +229,11 @@ pub enum LiteralKind { impl ast::Literal { pub fn token(&self) -> SyntaxToken { - let elem = self - .syntax() + self.syntax() .children_with_tokens() - .find(|e| e.kind() != ATTR && !e.kind().is_trivia()); - match elem { - Some(SyntaxElement::Token(token)) => token, - _ => unreachable!(), - } + .find(|e| e.kind() != ATTR && !e.kind().is_trivia()) + .and_then(|e| e.into_token()) + .unwrap() } pub fn kind(&self) -> LiteralKind { -- cgit v1.2.3