aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/expr_ext.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast/expr_ext.rs')
-rw-r--r--crates/ra_syntax/src/ast/expr_ext.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs
index db5438d68..f5ba87223 100644
--- a/crates/ra_syntax/src/ast/expr_ext.rs
+++ b/crates/ra_syntax/src/ast/expr_ext.rs
@@ -7,6 +7,8 @@ use crate::{
7 SyntaxToken, T, 7 SyntaxToken, T,
8}; 8};
9 9
10impl ast::AttrsOwner for ast::Expr {}
11
10impl ast::Expr { 12impl ast::Expr {
11 pub fn is_block_like(&self) -> bool { 13 pub fn is_block_like(&self) -> bool {
12 match self { 14 match self {
@@ -331,13 +333,12 @@ impl ast::Literal {
331 333
332 match token.kind() { 334 match token.kind() {
333 INT_NUMBER => { 335 INT_NUMBER => {
334 // FYI: there was a bug here previously, thus an if statement bellow is necessary. 336 // FYI: there was a bug here previously, thus the if statement below is necessary.
335 // The lexer treats e.g. `1f64` as an integer literal. See 337 // The lexer treats e.g. `1f64` as an integer literal. See
336 // https://github.com/rust-analyzer/rust-analyzer/issues/1592 338 // https://github.com/rust-analyzer/rust-analyzer/issues/1592
337 // and the comments on the linked PR. 339 // and the comments on the linked PR.
338 340
339 let text = token.text(); 341 let text = token.text();
340
341 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) { 342 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) {
342 LiteralKind::FloatNumber { suffix } 343 LiteralKind::FloatNumber { suffix }
343 } else { 344 } else {
@@ -399,7 +400,7 @@ impl ast::BlockExpr {
399 Some(it) => it, 400 Some(it) => it,
400 None => return true, 401 None => return true,
401 }; 402 };
402 !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) 403 !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
403 } 404 }
404} 405}
405 406
@@ -410,8 +411,8 @@ fn test_literal_with_attr() {
410 assert_eq!(lit.token().text(), r#""Hello""#); 411 assert_eq!(lit.token().text(), r#""Hello""#);
411} 412}
412 413
413impl ast::RecordField { 414impl ast::RecordExprField {
414 pub fn parent_record_lit(&self) -> ast::RecordLit { 415 pub fn parent_record_lit(&self) -> ast::RecordExpr {
415 self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() 416 self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
416 } 417 }
417} 418}