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 +++++++--------- .../src/diagnostics/test_data/handles_macro_location.txt | 2 +- .../test_data/rustc_incompatible_type_for_trait.txt | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'crates') 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)) diff --git a/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt b/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt index d5ab03576..a7f936a70 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt @@ -54,7 +54,7 @@ source: Some( "rustc", ), - message: "can\'t compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`", + message: "can't compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`", related_information: None, tags: None, data: None, diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt index ada540ea6..afc562a0e 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt @@ -54,7 +54,7 @@ source: Some( "rustc", ), - message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&ty::Ref>`\n found type `fn(&ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&\'list ty::Ref>`", + message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref>`\n found type `fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref>`", related_information: None, tags: None, data: None, -- cgit v1.2.3