Skip to content

Commit dcbf385

Browse files
committed
use make::name_ref
1 parent e26ba72 commit dcbf385

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,37 +218,41 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn, annotated_name: &ast::Name) {
218218
let expr = match strukt.field_list() {
219219
None => {
220220
// => f.debug_struct("Name").finish()
221-
make::expr_method_call(target, "debug_struct", args)
221+
make::expr_method_call(target, make::name_ref("debug_struct"), args)
222222
}
223223
Some(ast::FieldList::RecordFieldList(field_list)) => {
224224
// => f.debug_struct("Name").field("foo", &self.foo).finish()
225-
let mut expr = make::expr_method_call(target, "debug_struct", args);
225+
let method = make::name_ref("debug_struct");
226+
let mut expr = make::expr_method_call(target, method, args);
226227
for field in field_list.fields() {
227228
if let Some(name) = field.name() {
228229
let f_name = make::expr_literal(&(format!("\"{}\"", name))).into();
229230
let f_path = make::expr_path(make::ext::ident_path("self"));
230231
let f_path = make::expr_ref(f_path, false);
231232
let f_path = make::expr_field(f_path, &format!("{}", name)).into();
232233
let args = make::arg_list(vec![f_name, f_path]);
233-
expr = make::expr_method_call(expr, "field", args);
234+
expr = make::expr_method_call(expr, make::name_ref("field"), args);
234235
}
235236
}
236237
expr
237238
}
238239
Some(ast::FieldList::TupleFieldList(field_list)) => {
239240
// => f.debug_tuple("Name").field(self.0).finish()
240-
let mut expr = make::expr_method_call(target, "debug_tuple", args);
241+
let method = make::name_ref("debug_tuple");
242+
let mut expr = make::expr_method_call(target, method, args);
241243
for (idx, _) in field_list.fields().enumerate() {
242244
let f_path = make::expr_path(make::ext::ident_path("self"));
243245
let f_path = make::expr_ref(f_path, false);
244246
let f_path = make::expr_field(f_path, &format!("{}", idx)).into();
245-
expr = make::expr_method_call(expr, "field", make::arg_list(Some(f_path)));
247+
let method = make::name_ref("field");
248+
expr = make::expr_method_call(expr, method, make::arg_list(Some(f_path)));
246249
}
247250
expr
248251
}
249252
};
250253

251-
let expr = make::expr_method_call(expr, "finish", make::arg_list(None));
254+
let method = make::name_ref("finish");
255+
let expr = make::expr_method_call(expr, method, make::arg_list(None));
252256
let body = make::block_expr(None, Some(expr)).indent(ast::edit::IndentLevel(1));
253257
ted::replace(func.body().unwrap().syntax(), body.clone_for_update().syntax());
254258
}

0 commit comments

Comments
 (0)