Skip to content

Commit 6c4a94b

Browse files
committed
finishing touches
1 parent c4e10c8 commit 6c4a94b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

crates/ide_assists/src/utils/gen_trait_fn_body.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ fn gen_hash_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
274274
let method = make::name_ref("hash");
275275
let arg = make::expr_path(make::ext::ident_path("state"));
276276
let expr = make::expr_method_call(target, method, make::arg_list(Some(arg)));
277-
let stmt = make::expr_stmt(expr);
278-
stmt.into()
277+
make::expr_stmt(expr).into()
279278
}
280279

281280
let body = match adt {
@@ -335,8 +334,7 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
335334
let submodule = make::ext::ident_path("mem");
336335
let fn_name = make::ext::ident_path("discriminant");
337336
let fn_name = make::path_concat(submodule, fn_name);
338-
let fn_name = make::expr_path(make::path_concat(root, fn_name));
339-
fn_name
337+
make::expr_path(make::path_concat(root, fn_name))
340338
}
341339

342340
fn gen_eq_chain(expr: Option<ast::Expr>, cmp: ast::Expr) -> Option<ast::Expr> {
@@ -349,15 +347,11 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
349347
fn gen_record_pat_field(field_name: &str, pat_name: &str) -> ast::RecordPatField {
350348
let pat = make::ext::simple_ident_pat(make::name(&pat_name));
351349
let name_ref = make::name_ref(field_name);
352-
let field = make::record_pat_field(name_ref, pat.into());
353-
field
350+
make::record_pat_field(name_ref, pat.into())
354351
}
355352

356-
fn gen_record_pat(
357-
record_name: ast::Path,
358-
r_fields: Vec<ast::RecordPatField>,
359-
) -> ast::RecordPat {
360-
let list = make::record_pat_field_list(r_fields);
353+
fn gen_record_pat(record_name: ast::Path, fields: Vec<ast::RecordPatField>) -> ast::RecordPat {
354+
let list = make::record_pat_field_list(fields);
361355
make::record_pat_with_fields(record_name, list)
362356
}
363357

@@ -371,6 +365,7 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
371365
fn gen_tuple_field(field_name: &String) -> ast::Pat {
372366
ast::Pat::IdentPat(make::ident_pat(false, false, make::name(field_name)))
373367
}
368+
374369
// FIXME: return `None` if the trait carries a generic type; we can only
375370
// generate this code `Self` for the time being.
376371

0 commit comments

Comments
 (0)