From 05b8ccc3787888671bde6b8fae4175c1a1ebc37a Mon Sep 17 00:00:00 2001 From: DropDemBits Date: Wed, 31 Jan 2024 23:08:51 -0500 Subject: [PATCH] Fix clippy lints --- .../ide-assists/src/handlers/extract_function.rs | 16 +++++----------- .../src/handlers/generate_getter_or_setter.rs | 10 ++++------ .../handlers/replace_derive_with_manual_impl.rs | 7 ++----- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/crates/ide-assists/src/handlers/extract_function.rs b/crates/ide-assists/src/handlers/extract_function.rs index fce132f7824..54e99e07959 100644 --- a/crates/ide-assists/src/handlers/extract_function.rs +++ b/crates/ide-assists/src/handlers/extract_function.rs @@ -187,7 +187,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op impl_.syntax().clone() } _ => { - fn_def.indent(new_indent.into()); + fn_def.indent(new_indent); fn_def.syntax().clone() } @@ -1416,17 +1416,13 @@ fn make_call(ctx: &AssistContext<'_>, fun: &Function, indent: IndentLevel) -> Sy [var] => { let name = var.local.name(ctx.db()); let name = make::name(&name.display(ctx.db()).to_string()); - Some(ast::Pat::IdentPat(make::ident_pat( - false, - var.mut_usage_outside_body, - name.into(), - ))) + Some(ast::Pat::IdentPat(make::ident_pat(false, var.mut_usage_outside_body, name))) } vars => { let binding_pats = vars.iter().map(|var| { let name = var.local.name(ctx.db()); let name = make::name(&name.display(ctx.db()).to_string()); - make::ident_pat(false, var.mut_usage_outside_body, name.into()).into() + make::ident_pat(false, var.mut_usage_outside_body, name).into() }); Some(ast::Pat::TuplePat(make::tuple_pat(binding_pats))) } @@ -1874,7 +1870,7 @@ fn make_body(ctx: &AssistContext<'_>, old_indent: IndentLevel, fun: &Function) - } }; - let block = match &handler { + match &handler { FlowHandler::None => block, FlowHandler::Try { kind } => { let block = with_default_tail_expr(block, make::expr_unit()); @@ -1909,9 +1905,7 @@ fn make_body(ctx: &AssistContext<'_>, old_indent: IndentLevel, fun: &Function) - let args = make::arg_list(iter::once(tail_expr)); make::expr_call(ok, args) }), - }; - - block + } } fn map_tail_expr(block: ast::BlockExpr, f: impl FnOnce(ast::Expr) -> ast::Expr) -> ast::BlockExpr { diff --git a/crates/ide-assists/src/handlers/generate_getter_or_setter.rs b/crates/ide-assists/src/handlers/generate_getter_or_setter.rs index c5332445356..e90a032f1cb 100644 --- a/crates/ide-assists/src/handlers/generate_getter_or_setter.rs +++ b/crates/ide-assists/src/handlers/generate_getter_or_setter.rs @@ -272,17 +272,15 @@ fn generate_setter_from_info(info: &AssistInfo, record_field_info: &RecordFieldI // Make the param list // `(&mut self, $field_name: $field_ty)` - let field_param = make::param( - make::ident_pat(false, false, make::name(&field_name)).into(), - field_ty.clone(), - ); + let field_param = + make::param(make::ident_pat(false, false, make::name(field_name)).into(), field_ty.clone()); let params = make::param_list(Some(make::mut_self_param()), [field_param]); // Make the assignment body // `self.$field_name = $field_name` let self_expr = make::ext::expr_self(); - let lhs = make::expr_field(self_expr, &field_name); - let rhs = make::expr_path(make::ext::ident_path(&field_name)); + let lhs = make::expr_field(self_expr, field_name); + let rhs = make::expr_path(make::ext::ident_path(field_name)); let assign_stmt = make::expr_stmt(make::expr_assignment(lhs, rhs)); let body = make::block_expr([assign_stmt.into()], None); diff --git a/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs index 0714b089aba..3420d906dea 100644 --- a/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs +++ b/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs @@ -252,12 +252,9 @@ fn update_attribute( .collect::>() }); // ...which are interspersed with ", " - let tt = Itertools::intersperse( - tt, - vec![make::token(T![,]).into(), make::tokens::single_space().into()], - ); + let tt = Itertools::intersperse(tt, vec![make::token(T![,]), make::tokens::single_space()]); // ...wrap them into the appropriate `NodeOrToken` variant - let tt = tt.flatten().map(|token| syntax::NodeOrToken::Token(token)); + let tt = tt.flatten().map(syntax::NodeOrToken::Token); // ...and make them into a flat list of tokens let tt = tt.collect::>();