aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 66fe77a19..d88671d45 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -229,7 +229,8 @@ pub enum LiteralKind {
229 229
230impl ast::Literal { 230impl ast::Literal {
231 pub fn token(&self) -> SyntaxToken { 231 pub fn token(&self) -> SyntaxToken {
232 let elem = self.syntax() 232 let elem = self
233 .syntax()
233 .children_with_tokens() 234 .children_with_tokens()
234 .find(|e| e.kind() != ATTR && !e.kind().is_trivia()); 235 .find(|e| e.kind() != ATTR && !e.kind().is_trivia());
235 match elem { 236 match elem {
@@ -274,12 +275,7 @@ impl ast::Literal {
274#[test] 275#[test]
275fn test_literal_with_attr() { 276fn test_literal_with_attr() {
276 let parse = ast::SourceFile::parse(r#"const _: &str = { #[attr] "Hello" };"#); 277 let parse = ast::SourceFile::parse(r#"const _: &str = { #[attr] "Hello" };"#);
277 let lit = parse 278 let lit = parse.tree.syntax().descendants().find_map(ast::Literal::cast).unwrap();
278 .tree
279 .syntax()
280 .descendants()
281 .find_map(ast::Literal::cast)
282 .unwrap();
283 assert_eq!(lit.token().text(), r#""Hello""#); 279 assert_eq!(lit.token().text(), r#""Hello""#);
284} 280}
285 281