@@ -218,37 +218,41 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn, annotated_name: &ast::Name) {
218
218
let expr = match strukt. field_list ( ) {
219
219
None => {
220
220
// => 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)
222
222
}
223
223
Some ( ast:: FieldList :: RecordFieldList ( field_list) ) => {
224
224
// => 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) ;
226
227
for field in field_list. fields ( ) {
227
228
if let Some ( name) = field. name ( ) {
228
229
let f_name = make:: expr_literal ( & ( format ! ( "\" {}\" " , name) ) ) . into ( ) ;
229
230
let f_path = make:: expr_path ( make:: ext:: ident_path ( "self" ) ) ;
230
231
let f_path = make:: expr_ref ( f_path, false ) ;
231
232
let f_path = make:: expr_field ( f_path, & format ! ( "{}" , name) ) . into ( ) ;
232
233
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) ;
234
235
}
235
236
}
236
237
expr
237
238
}
238
239
Some ( ast:: FieldList :: TupleFieldList ( field_list) ) => {
239
240
// => 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) ;
241
243
for ( idx, _) in field_list. fields ( ) . enumerate ( ) {
242
244
let f_path = make:: expr_path ( make:: ext:: ident_path ( "self" ) ) ;
243
245
let f_path = make:: expr_ref ( f_path, false ) ;
244
246
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) ) ) ;
246
249
}
247
250
expr
248
251
}
249
252
} ;
250
253
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 ) ) ;
252
256
let body = make:: block_expr ( None , Some ( expr) ) . indent ( ast:: edit:: IndentLevel ( 1 ) ) ;
253
257
ted:: replace ( func. body ( ) . unwrap ( ) . syntax ( ) , body. clone_for_update ( ) . syntax ( ) ) ;
254
258
}
0 commit comments