Fix clippy lints
This commit is contained in:
parent
1161082051
commit
05b8ccc378
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -252,12 +252,9 @@ fn update_attribute(
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
// ...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::<Vec<_>>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user