diff options
Diffstat (limited to 'crates/ra_assists/src/inline_local_variable.rs')
-rw-r--r-- | crates/ra_assists/src/inline_local_variable.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/inline_local_variable.rs b/crates/ra_assists/src/inline_local_variable.rs index 554de8b46..3c17089de 100644 --- a/crates/ra_assists/src/inline_local_variable.rs +++ b/crates/ra_assists/src/inline_local_variable.rs | |||
@@ -16,18 +16,18 @@ pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
16 | if bind_pat.is_mutable() { | 16 | if bind_pat.is_mutable() { |
17 | return None; | 17 | return None; |
18 | } | 18 | } |
19 | let initializer_expr = let_stmt.initializer(); | 19 | let initializer_expr = let_stmt.initializer()?; |
20 | let delete_range = if let Some(whitespace) = let_stmt | 20 | let delete_range = if let Some(whitespace) = let_stmt |
21 | .syntax() | 21 | .syntax() |
22 | .next_sibling_or_token() | 22 | .next_sibling_or_token() |
23 | .and_then(|it| ast::Whitespace::cast(it.as_token()?)) | 23 | .and_then(|it| ast::Whitespace::cast(it.as_token()?.clone())) |
24 | { | 24 | { |
25 | TextRange::from_to(let_stmt.syntax().range().start(), whitespace.syntax().range().end()) | 25 | TextRange::from_to(let_stmt.syntax().range().start(), whitespace.syntax().range().end()) |
26 | } else { | 26 | } else { |
27 | let_stmt.syntax().range() | 27 | let_stmt.syntax().range() |
28 | }; | 28 | }; |
29 | let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, bind_pat.syntax(), None); | 29 | let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, bind_pat.syntax(), None); |
30 | let refs = analyzer.find_all_refs(bind_pat); | 30 | let refs = analyzer.find_all_refs(&bind_pat); |
31 | 31 | ||
32 | let mut wrap_in_parens = vec![true; refs.len()]; | 32 | let mut wrap_in_parens = vec![true; refs.len()]; |
33 | 33 | ||
@@ -45,7 +45,7 @@ pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
45 | } | 45 | } |
46 | }; | 46 | }; |
47 | 47 | ||
48 | wrap_in_parens[i] = match (initializer_expr?.kind(), usage_parent.kind()) { | 48 | wrap_in_parens[i] = match (initializer_expr.kind(), usage_parent.kind()) { |
49 | (ExprKind::CallExpr(_), _) | 49 | (ExprKind::CallExpr(_), _) |
50 | | (ExprKind::IndexExpr(_), _) | 50 | | (ExprKind::IndexExpr(_), _) |
51 | | (ExprKind::MethodCallExpr(_), _) | 51 | | (ExprKind::MethodCallExpr(_), _) |
@@ -71,7 +71,7 @@ pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
71 | }; | 71 | }; |
72 | } | 72 | } |
73 | 73 | ||
74 | let init_str = initializer_expr?.syntax().text().to_string(); | 74 | let init_str = initializer_expr.syntax().text().to_string(); |
75 | let init_in_paren = format!("({})", &init_str); | 75 | let init_in_paren = format!("({})", &init_str); |
76 | 76 | ||
77 | ctx.add_action( | 77 | ctx.add_action( |