aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs2
-rw-r--r--crates/ide_assists/src/handlers/inline_local_variable.rs49
-rw-r--r--crates/ide_assists/src/tests.rs7
3 files changed, 32 insertions, 26 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..bf4ba16f0 100644
--- a/crates/ide_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ide_assists/src/handlers/inline_local_variable.rs
@@ -68,28 +68,33 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
68 68
69 Some(!matches!( 69 Some(!matches!(
70 (&initializer_expr, usage_parent), 70 (&initializer_expr, usage_parent),
71 (ast::Expr::CallExpr(_), _) 71 (
72 | (ast::Expr::IndexExpr(_), _) 72 ast::Expr::CallExpr(_)
73 | (ast::Expr::MethodCallExpr(_), _) 73 | ast::Expr::IndexExpr(_)
74 | (ast::Expr::FieldExpr(_), _) 74 | ast::Expr::MethodCallExpr(_)
75 | (ast::Expr::TryExpr(_), _) 75 | ast::Expr::FieldExpr(_)
76 | (ast::Expr::RefExpr(_), _) 76 | ast::Expr::TryExpr(_)
77 | (ast::Expr::Literal(_), _) 77 | ast::Expr::RefExpr(_)
78 | (ast::Expr::TupleExpr(_), _) 78 | ast::Expr::Literal(_)
79 | (ast::Expr::ArrayExpr(_), _) 79 | ast::Expr::TupleExpr(_)
80 | (ast::Expr::ParenExpr(_), _) 80 | ast::Expr::ArrayExpr(_)
81 | (ast::Expr::PathExpr(_), _) 81 | ast::Expr::ParenExpr(_)
82 | (ast::Expr::BlockExpr(_), _) 82 | ast::Expr::PathExpr(_)
83 | (ast::Expr::EffectExpr(_), _) 83 | ast::Expr::BlockExpr(_)
84 | (_, ast::Expr::CallExpr(_)) 84 | ast::Expr::EffectExpr(_),
85 | (_, ast::Expr::TupleExpr(_)) 85 _
86 | (_, ast::Expr::ArrayExpr(_)) 86 ) | (
87 | (_, ast::Expr::ParenExpr(_)) 87 _,
88 | (_, ast::Expr::ForExpr(_)) 88 ast::Expr::CallExpr(_)
89 | (_, ast::Expr::WhileExpr(_)) 89 | ast::Expr::TupleExpr(_)
90 | (_, ast::Expr::BreakExpr(_)) 90 | ast::Expr::ArrayExpr(_)
91 | (_, ast::Expr::ReturnExpr(_)) 91 | ast::Expr::ParenExpr(_)
92 | (_, ast::Expr::MatchExpr(_)) 92 | ast::Expr::ForExpr(_)
93 | ast::Expr::WhileExpr(_)
94 | ast::Expr::BreakExpr(_)
95 | ast::Expr::ReturnExpr(_)
96 | ast::Expr::MatchExpr(_)
97 )
93 )) 98 ))
94 }) 99 })
95 .collect::<Option<_>>() 100 .collect::<Option<_>>()
diff --git a/crates/ide_assists/src/tests.rs b/crates/ide_assists/src/tests.rs
index 60cecd94c..29bd4a563 100644
--- a/crates/ide_assists/src/tests.rs
+++ b/crates/ide_assists/src/tests.rs
@@ -179,9 +179,10 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label:
179 "unresolved assist should not contain source changes" 179 "unresolved assist should not contain source changes"
180 ), 180 ),
181 (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"), 181 (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"),
182 (None, ExpectedResult::After(_)) 182 (
183 | (None, ExpectedResult::Target(_)) 183 None,
184 | (None, ExpectedResult::Unresolved) => { 184 ExpectedResult::After(_) | ExpectedResult::Target(_) | ExpectedResult::Unresolved,
185 ) => {
185 panic!("code action is not applicable") 186 panic!("code action is not applicable")
186 } 187 }
187 (None, ExpectedResult::NotApplicable) => (), 188 (None, ExpectedResult::NotApplicable) => (),