Skip to content

Commit a1f2c7a

Browse files
committed
1 parent aa09141 commit a1f2c7a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ fn impl_def_from_trait(
170170
let (impl_def, first_assoc_item) =
171171
add_trait_assoc_items_to_impl(sema, trait_items, trait_, impl_def, target_scope);
172172

173-
if let ast::AssocItem::Fn(fn_) = &first_assoc_item {
173+
if let ast::AssocItem::Fn(func) = &first_assoc_item {
174174
if trait_path.segment().unwrap().name_ref().unwrap().text() == "Debug" {
175-
gen_debug_impl(adt, fn_, annotated_name);
175+
gen_debug_impl(adt, func, annotated_name);
176176
}
177177
}
178178
Some((impl_def, first_assoc_item))
179179
}
180180

181-
fn gen_debug_impl(adt: &ast::Adt, fn_: &ast::Fn, annotated_name: &ast::Name) {
181+
fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn, annotated_name: &ast::Name) {
182182
match adt {
183183
ast::Adt::Union(_) => {} // `Debug` cannot be derived for unions, so no default impl can be provided.
184-
ast::Adt::Enum(_) => {} // TODO
184+
ast::Adt::Enum(enum_) => {} // TODO
185185
ast::Adt::Struct(strukt) => match strukt.field_list() {
186186
Some(ast::FieldList::RecordFieldList(field_list)) => {
187187
let name = format!("\"{}\"", annotated_name);
@@ -200,7 +200,7 @@ fn gen_debug_impl(adt: &ast::Adt, fn_: &ast::Fn, annotated_name: &ast::Name) {
200200
}
201201
let expr = make::expr_method_call(expr, "finish", make::arg_list(None));
202202
let body = make::block_expr(None, Some(expr)).indent(ast::edit::IndentLevel(1));
203-
ted::replace(fn_.body().unwrap().syntax(), body.clone_for_update().syntax());
203+
ted::replace(func.body().unwrap().syntax(), body.clone_for_update().syntax());
204204
}
205205
Some(ast::FieldList::TupleFieldList(field_list)) => {
206206
let name = format!("\"{}\"", annotated_name);
@@ -216,7 +216,7 @@ fn gen_debug_impl(adt: &ast::Adt, fn_: &ast::Fn, annotated_name: &ast::Name) {
216216
}
217217
let expr = make::expr_method_call(expr, "finish", make::arg_list(None));
218218
let body = make::block_expr(None, Some(expr)).indent(ast::edit::IndentLevel(1));
219-
ted::replace(fn_.body().unwrap().syntax(), body.clone_for_update().syntax());
219+
ted::replace(func.body().unwrap().syntax(), body.clone_for_update().syntax());
220220
}
221221
None => {
222222
let name = format!("\"{}\"", annotated_name);
@@ -225,7 +225,7 @@ fn gen_debug_impl(adt: &ast::Adt, fn_: &ast::Fn, annotated_name: &ast::Name) {
225225
let expr = make::expr_method_call(target, "debug_struct", args);
226226
let expr = make::expr_method_call(expr, "finish", make::arg_list(None));
227227
let body = make::block_expr(None, Some(expr)).indent(ast::edit::IndentLevel(1));
228-
ted::replace(fn_.body().unwrap().syntax(), body.clone_for_update().syntax());
228+
ted::replace(func.body().unwrap().syntax(), body.clone_for_update().syntax());
229229
}
230230
},
231231
}

0 commit comments

Comments
 (0)