Fix clippy lints

This commit is contained in:
DropDemBits 2024-01-31 23:08:51 -05:00
parent 1161082051
commit 05b8ccc378
No known key found for this signature in database
GPG Key ID: 7FE02A6C1EDFA075
3 changed files with 11 additions and 22 deletions

View File

@ -187,7 +187,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
impl_.syntax().clone() impl_.syntax().clone()
} }
_ => { _ => {
fn_def.indent(new_indent.into()); fn_def.indent(new_indent);
fn_def.syntax().clone() fn_def.syntax().clone()
} }
@ -1416,17 +1416,13 @@ fn make_call(ctx: &AssistContext<'_>, fun: &Function, indent: IndentLevel) -> Sy
[var] => { [var] => {
let name = var.local.name(ctx.db()); let name = var.local.name(ctx.db());
let name = make::name(&name.display(ctx.db()).to_string()); let name = make::name(&name.display(ctx.db()).to_string());
Some(ast::Pat::IdentPat(make::ident_pat( Some(ast::Pat::IdentPat(make::ident_pat(false, var.mut_usage_outside_body, name)))
false,
var.mut_usage_outside_body,
name.into(),
)))
} }
vars => { vars => {
let binding_pats = vars.iter().map(|var| { let binding_pats = vars.iter().map(|var| {
let name = var.local.name(ctx.db()); let name = var.local.name(ctx.db());
let name = make::name(&name.display(ctx.db()).to_string()); 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))) 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::None => block,
FlowHandler::Try { kind } => { FlowHandler::Try { kind } => {
let block = with_default_tail_expr(block, make::expr_unit()); 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)); let args = make::arg_list(iter::once(tail_expr));
make::expr_call(ok, args) make::expr_call(ok, args)
}), }),
}; }
block
} }
fn map_tail_expr(block: ast::BlockExpr, f: impl FnOnce(ast::Expr) -> ast::Expr) -> ast::BlockExpr { fn map_tail_expr(block: ast::BlockExpr, f: impl FnOnce(ast::Expr) -> ast::Expr) -> ast::BlockExpr {

View File

@ -272,17 +272,15 @@ fn generate_setter_from_info(info: &AssistInfo, record_field_info: &RecordFieldI
// Make the param list // Make the param list
// `(&mut self, $field_name: $field_ty)` // `(&mut self, $field_name: $field_ty)`
let field_param = make::param( let field_param =
make::ident_pat(false, false, make::name(&field_name)).into(), make::param(make::ident_pat(false, false, make::name(field_name)).into(), field_ty.clone());
field_ty.clone(),
);
let params = make::param_list(Some(make::mut_self_param()), [field_param]); let params = make::param_list(Some(make::mut_self_param()), [field_param]);
// Make the assignment body // Make the assignment body
// `self.$field_name = $field_name` // `self.$field_name = $field_name`
let self_expr = make::ext::expr_self(); let self_expr = make::ext::expr_self();
let lhs = make::expr_field(self_expr, &field_name); let lhs = make::expr_field(self_expr, field_name);
let rhs = make::expr_path(make::ext::ident_path(&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 assign_stmt = make::expr_stmt(make::expr_assignment(lhs, rhs));
let body = make::block_expr([assign_stmt.into()], None); let body = make::block_expr([assign_stmt.into()], None);

View File

@ -252,12 +252,9 @@ fn update_attribute(
.collect::<Vec<_>>() .collect::<Vec<_>>()
}); });
// ...which are interspersed with ", " // ...which are interspersed with ", "
let tt = Itertools::intersperse( let tt = Itertools::intersperse(tt, vec![make::token(T![,]), make::tokens::single_space()]);
tt,
vec![make::token(T![,]).into(), make::tokens::single_space().into()],
);
// ...wrap them into the appropriate `NodeOrToken` variant // ...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 // ...and make them into a flat list of tokens
let tt = tt.collect::<Vec<_>>(); let tt = tt.collect::<Vec<_>>();