@@ -35,7 +35,7 @@ fn gen_clone_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
35
35
stdx:: always!( func. name( ) . is_some_and( |name| name. text( ) == "clone" ) ) ;
36
36
fn gen_clone_call ( target : ast:: Expr ) -> ast:: Expr {
37
37
let method = make:: name_ref ( "clone" ) ;
38
- make:: expr_method_call ( target, method, make:: arg_list ( None ) )
38
+ make:: expr_method_call ( target, method, make:: arg_list ( None ) ) . into ( )
39
39
}
40
40
let expr = match adt {
41
41
// `Clone` cannot be derived for unions, so no default impl can be provided.
@@ -165,7 +165,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
165
165
let method = make:: name_ref ( "debug_struct" ) ;
166
166
let struct_name = format ! ( "\" {name}\" " ) ;
167
167
let args = make:: arg_list ( Some ( make:: expr_literal ( & struct_name) . into ( ) ) ) ;
168
- let mut expr = make:: expr_method_call ( target, method, args) ;
168
+ let mut expr = make:: expr_method_call ( target, method, args) . into ( ) ;
169
169
170
170
let mut pats = vec ! [ ] ;
171
171
for field in list. fields ( ) {
@@ -181,12 +181,13 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
181
181
let path = & format ! ( "{field_name}" ) ;
182
182
let path = make:: expr_path ( make:: ext:: ident_path ( path) ) ;
183
183
let args = make:: arg_list ( vec ! [ name, path] ) ;
184
- expr = make:: expr_method_call ( expr, method_name, args) ;
184
+ expr = make:: expr_method_call ( expr, method_name, args) . into ( ) ;
185
185
}
186
186
187
187
// => <expr>.finish()
188
188
let method = make:: name_ref ( "finish" ) ;
189
- let expr = make:: expr_method_call ( expr, method, make:: arg_list ( None ) ) ;
189
+ let expr =
190
+ make:: expr_method_call ( expr, method, make:: arg_list ( None ) ) . into ( ) ;
190
191
191
192
// => MyStruct { fields.. } => f.debug_struct("MyStruct")...finish(),
192
193
let pat = make:: record_pat ( variant_name. clone ( ) , pats. into_iter ( ) ) ;
@@ -198,7 +199,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
198
199
let method = make:: name_ref ( "debug_tuple" ) ;
199
200
let struct_name = format ! ( "\" {name}\" " ) ;
200
201
let args = make:: arg_list ( Some ( make:: expr_literal ( & struct_name) . into ( ) ) ) ;
201
- let mut expr = make:: expr_method_call ( target, method, args) ;
202
+ let mut expr = make:: expr_method_call ( target, method, args) . into ( ) ;
202
203
203
204
let mut pats = vec ! [ ] ;
204
205
for ( i, _) in list. fields ( ) . enumerate ( ) {
@@ -214,12 +215,13 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
214
215
let field_path = & name. to_string ( ) ;
215
216
let field_path = make:: expr_path ( make:: ext:: ident_path ( field_path) ) ;
216
217
let args = make:: arg_list ( vec ! [ field_path] ) ;
217
- expr = make:: expr_method_call ( expr, method_name, args) ;
218
+ expr = make:: expr_method_call ( expr, method_name, args) . into ( ) ;
218
219
}
219
220
220
221
// => <expr>.finish()
221
222
let method = make:: name_ref ( "finish" ) ;
222
- let expr = make:: expr_method_call ( expr, method, make:: arg_list ( None ) ) ;
223
+ let expr =
224
+ make:: expr_method_call ( expr, method, make:: arg_list ( None ) ) . into ( ) ;
223
225
224
226
// => MyStruct (fields..) => f.debug_tuple("MyStruct")...finish(),
225
227
let pat = make:: tuple_struct_pat ( variant_name. clone ( ) , pats. into_iter ( ) ) ;
@@ -254,41 +256,42 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
254
256
255
257
let expr = match strukt. field_list ( ) {
256
258
// => f.debug_struct("Name").finish()
257
- None => make:: expr_method_call ( target, make:: name_ref ( "debug_struct" ) , args) ,
259
+ None => make:: expr_method_call ( target, make:: name_ref ( "debug_struct" ) , args) . into ( ) ,
258
260
259
261
// => f.debug_struct("Name").field("foo", &self.foo).finish()
260
262
Some ( ast:: FieldList :: RecordFieldList ( field_list) ) => {
261
263
let method = make:: name_ref ( "debug_struct" ) ;
262
- let mut expr = make:: expr_method_call ( target, method, args) ;
264
+ let mut expr = make:: expr_method_call ( target, method, args) . into ( ) ;
263
265
for field in field_list. fields ( ) {
264
266
let name = field. name ( ) ?;
265
267
let f_name = make:: expr_literal ( & ( format ! ( "\" {name}\" " ) ) ) . into ( ) ;
266
268
let f_path = make:: expr_path ( make:: ext:: ident_path ( "self" ) ) ;
267
269
let f_path = make:: expr_ref ( f_path, false ) ;
268
270
let f_path = make:: expr_field ( f_path, & format ! ( "{name}" ) ) ;
269
271
let args = make:: arg_list ( [ f_name, f_path] ) ;
270
- expr = make:: expr_method_call ( expr, make:: name_ref ( "field" ) , args) ;
272
+ expr = make:: expr_method_call ( expr, make:: name_ref ( "field" ) , args) . into ( ) ;
271
273
}
272
274
expr
273
275
}
274
276
275
277
// => f.debug_tuple("Name").field(self.0).finish()
276
278
Some ( ast:: FieldList :: TupleFieldList ( field_list) ) => {
277
279
let method = make:: name_ref ( "debug_tuple" ) ;
278
- let mut expr = make:: expr_method_call ( target, method, args) ;
280
+ let mut expr = make:: expr_method_call ( target, method, args) . into ( ) ;
279
281
for ( i, _) in field_list. fields ( ) . enumerate ( ) {
280
282
let f_path = make:: expr_path ( make:: ext:: ident_path ( "self" ) ) ;
281
283
let f_path = make:: expr_ref ( f_path, false ) ;
282
284
let f_path = make:: expr_field ( f_path, & format ! ( "{i}" ) ) ;
283
285
let method = make:: name_ref ( "field" ) ;
284
- expr = make:: expr_method_call ( expr, method, make:: arg_list ( Some ( f_path) ) ) ;
286
+ expr = make:: expr_method_call ( expr, method, make:: arg_list ( Some ( f_path) ) )
287
+ . into ( ) ;
285
288
}
286
289
expr
287
290
}
288
291
} ;
289
292
290
293
let method = make:: name_ref ( "finish" ) ;
291
- let expr = make:: expr_method_call ( expr, method, make:: arg_list ( None ) ) ;
294
+ let expr = make:: expr_method_call ( expr, method, make:: arg_list ( None ) ) . into ( ) ;
292
295
let body = make:: block_expr ( None , Some ( expr) ) . indent ( ast:: edit:: IndentLevel ( 1 ) ) ;
293
296
ted:: replace ( func. body ( ) ?. syntax ( ) , body. clone_for_update ( ) . syntax ( ) ) ;
294
297
Some ( ( ) )
@@ -348,7 +351,7 @@ fn gen_hash_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
348
351
fn gen_hash_call ( target : ast:: Expr ) -> ast:: Stmt {
349
352
let method = make:: name_ref ( "hash" ) ;
350
353
let arg = make:: expr_path ( make:: ext:: ident_path ( "state" ) ) ;
351
- let expr = make:: expr_method_call ( target, method, make:: arg_list ( Some ( arg) ) ) ;
354
+ let expr = make:: expr_method_call ( target, method, make:: arg_list ( Some ( arg) ) ) . into ( ) ;
352
355
make:: expr_stmt ( expr) . into ( )
353
356
}
354
357
@@ -613,7 +616,7 @@ fn gen_partial_ord(adt: &ast::Adt, func: &ast::Fn, trait_ref: Option<TraitRef>)
613
616
fn gen_partial_cmp_call ( lhs : ast:: Expr , rhs : ast:: Expr ) -> ast:: Expr {
614
617
let rhs = make:: expr_ref ( rhs, false ) ;
615
618
let method = make:: name_ref ( "partial_cmp" ) ;
616
- make:: expr_method_call ( lhs, method, make:: arg_list ( Some ( rhs) ) )
619
+ make:: expr_method_call ( lhs, method, make:: arg_list ( Some ( rhs) ) ) . into ( )
617
620
}
618
621
619
622
// Check that self type and rhs type match. We don't know how to implement the method
0 commit comments