From 95c8c65139c10e4de44367fead8dff88511e6d46 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 17 Jun 2021 17:37:14 +0200 Subject: Nest all the or-patterns! --- .../ide_assists/src/handlers/extract_function.rs | 2 +- .../src/handlers/inline_local_variable.rs | 49 ++++++++++++---------- crates/ide_assists/src/tests.rs | 7 ++-- 3 files changed, 32 insertions(+), 26 deletions(-) (limited to 'crates/ide_assists') 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) for (param, usages) in usages_for_param { for usage in usages { match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) { - Some(ast::Expr::MethodCallExpr(_)) | Some(ast::Expr::FieldExpr(_)) => { + Some(ast::Expr::MethodCallExpr(_) | ast::Expr::FieldExpr(_)) => { // do nothing } 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 Some(!matches!( (&initializer_expr, usage_parent), - (ast::Expr::CallExpr(_), _) - | (ast::Expr::IndexExpr(_), _) - | (ast::Expr::MethodCallExpr(_), _) - | (ast::Expr::FieldExpr(_), _) - | (ast::Expr::TryExpr(_), _) - | (ast::Expr::RefExpr(_), _) - | (ast::Expr::Literal(_), _) - | (ast::Expr::TupleExpr(_), _) - | (ast::Expr::ArrayExpr(_), _) - | (ast::Expr::ParenExpr(_), _) - | (ast::Expr::PathExpr(_), _) - | (ast::Expr::BlockExpr(_), _) - | (ast::Expr::EffectExpr(_), _) - | (_, ast::Expr::CallExpr(_)) - | (_, ast::Expr::TupleExpr(_)) - | (_, ast::Expr::ArrayExpr(_)) - | (_, ast::Expr::ParenExpr(_)) - | (_, ast::Expr::ForExpr(_)) - | (_, ast::Expr::WhileExpr(_)) - | (_, ast::Expr::BreakExpr(_)) - | (_, ast::Expr::ReturnExpr(_)) - | (_, ast::Expr::MatchExpr(_)) + ( + ast::Expr::CallExpr(_) + | ast::Expr::IndexExpr(_) + | ast::Expr::MethodCallExpr(_) + | ast::Expr::FieldExpr(_) + | ast::Expr::TryExpr(_) + | ast::Expr::RefExpr(_) + | ast::Expr::Literal(_) + | ast::Expr::TupleExpr(_) + | ast::Expr::ArrayExpr(_) + | ast::Expr::ParenExpr(_) + | ast::Expr::PathExpr(_) + | ast::Expr::BlockExpr(_) + | ast::Expr::EffectExpr(_), + _ + ) | ( + _, + ast::Expr::CallExpr(_) + | ast::Expr::TupleExpr(_) + | ast::Expr::ArrayExpr(_) + | ast::Expr::ParenExpr(_) + | ast::Expr::ForExpr(_) + | ast::Expr::WhileExpr(_) + | ast::Expr::BreakExpr(_) + | ast::Expr::ReturnExpr(_) + | ast::Expr::MatchExpr(_) + ) )) }) .collect::>() 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: "unresolved assist should not contain source changes" ), (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"), - (None, ExpectedResult::After(_)) - | (None, ExpectedResult::Target(_)) - | (None, ExpectedResult::Unresolved) => { + ( + None, + ExpectedResult::After(_) | ExpectedResult::Target(_) | ExpectedResult::Unresolved, + ) => { panic!("code action is not applicable") } (None, ExpectedResult::NotApplicable) => (), -- cgit v1.2.3