From b6cb6d5abeca51abc7e805d847f3bf3b4ba71151 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 17 Jun 2021 17:46:06 +0200 Subject: simplify --- crates/ide_assists/src/handlers/inline_local_variable.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'crates/ide_assists/src/handlers/inline_local_variable.rs') diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs index bf4ba16f0..945d28650 100644 --- a/crates/ide_assists/src/handlers/inline_local_variable.rs +++ b/crates/ide_assists/src/handlers/inline_local_variable.rs @@ -65,10 +65,9 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O Some(u) => u, None => return Some(false), }; - - Some(!matches!( - (&initializer_expr, usage_parent), - ( + Some( + !(matches!( + initializer_expr, ast::Expr::CallExpr(_) | ast::Expr::IndexExpr(_) | ast::Expr::MethodCallExpr(_) @@ -82,9 +81,8 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O | ast::Expr::PathExpr(_) | ast::Expr::BlockExpr(_) | ast::Expr::EffectExpr(_), - _ - ) | ( - _, + ) || matches!( + usage_parent, ast::Expr::CallExpr(_) | ast::Expr::TupleExpr(_) | ast::Expr::ArrayExpr(_) @@ -94,8 +92,8 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O | ast::Expr::BreakExpr(_) | ast::Expr::ReturnExpr(_) | ast::Expr::MatchExpr(_) - ) - )) + )), + ) }) .collect::>() .map(|b| (file_id, b)) -- cgit v1.2.3