aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src/handlers')
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs2
-rw-r--r--crates/ide_assists/src/handlers/inline_local_variable.rs55
2 files changed, 30 insertions, 27 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index f2be091f4..7085a0c48 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -1384,7 +1384,7 @@ fn fix_param_usages(ctx: &AssistContext, params: &[Param], syntax: &SyntaxNode)
1384 for (param, usages) in usages_for_param { 1384 for (param, usages) in usages_for_param {
1385 for usage in usages { 1385 for usage in usages {
1386 match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) { 1386 match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) {
1387 Some(ast::Expr::MethodCallExpr(_)) | Some(ast::Expr::FieldExpr(_)) => { 1387 Some(ast::Expr::MethodCallExpr(_) | ast::Expr::FieldExpr(_)) => {
1388 // do nothing 1388 // do nothing
1389 } 1389 }
1390 Some(ast::Expr::RefExpr(node)) 1390 Some(ast::Expr::RefExpr(node))
diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs
index 2441dbb8b..945d28650 100644
--- a/crates/ide_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ide_assists/src/handlers/inline_local_variable.rs
@@ -65,32 +65,35 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
65 Some(u) => u, 65 Some(u) => u,
66 None => return Some(false), 66 None => return Some(false),
67 }; 67 };
68 68 Some(
69 Some(!matches!( 69 !(matches!(
70 (&initializer_expr, usage_parent), 70 initializer_expr,
71 (ast::Expr::CallExpr(_), _) 71 ast::Expr::CallExpr(_)
72 | (ast::Expr::IndexExpr(_), _) 72 | ast::Expr::IndexExpr(_)
73 | (ast::Expr::MethodCallExpr(_), _) 73 | ast::Expr::MethodCallExpr(_)
74 | (ast::Expr::FieldExpr(_), _) 74 | ast::Expr::FieldExpr(_)
75 | (ast::Expr::TryExpr(_), _) 75 | ast::Expr::TryExpr(_)
76 | (ast::Expr::RefExpr(_), _) 76 | ast::Expr::RefExpr(_)
77 | (ast::Expr::Literal(_), _) 77 | ast::Expr::Literal(_)
78 | (ast::Expr::TupleExpr(_), _) 78 | ast::Expr::TupleExpr(_)
79 | (ast::Expr::ArrayExpr(_), _) 79 | ast::Expr::ArrayExpr(_)
80 | (ast::Expr::ParenExpr(_), _) 80 | ast::Expr::ParenExpr(_)
81 | (ast::Expr::PathExpr(_), _) 81 | ast::Expr::PathExpr(_)
82 | (ast::Expr::BlockExpr(_), _) 82 | ast::Expr::BlockExpr(_)
83 | (ast::Expr::EffectExpr(_), _) 83 | ast::Expr::EffectExpr(_),
84 | (_, ast::Expr::CallExpr(_)) 84 ) || matches!(
85 | (_, ast::Expr::TupleExpr(_)) 85 usage_parent,
86 | (_, ast::Expr::ArrayExpr(_)) 86 ast::Expr::CallExpr(_)
87 | (_, ast::Expr::ParenExpr(_)) 87 | ast::Expr::TupleExpr(_)
88 | (_, ast::Expr::ForExpr(_)) 88 | ast::Expr::ArrayExpr(_)
89 | (_, ast::Expr::WhileExpr(_)) 89 | ast::Expr::ParenExpr(_)
90 | (_, ast::Expr::BreakExpr(_)) 90 | ast::Expr::ForExpr(_)
91 | (_, ast::Expr::ReturnExpr(_)) 91 | ast::Expr::WhileExpr(_)
92 | (_, ast::Expr::MatchExpr(_)) 92 | ast::Expr::BreakExpr(_)
93 )) 93 | ast::Expr::ReturnExpr(_)
94 | ast::Expr::MatchExpr(_)
95 )),
96 )
94 }) 97 })
95 .collect::<Option<_>>() 98 .collect::<Option<_>>()
96 .map(|b| (file_id, b)) 99 .map(|b| (file_id, b))