@@ -24,7 +24,7 @@ use crate::{AssistContext, AssistId, Assists};
24
24
// struct Bar { y: Y, z: Z }
25
25
//
26
26
// fn foo(bar: Bar) {
27
- // let Bar { y, z } = bar;
27
+ // let Bar { y, z } = bar;
28
28
// }
29
29
// ```
30
30
fn expand_record_rest_pattern (
@@ -53,18 +53,17 @@ fn expand_record_rest_pattern(
53
53
|builder| {
54
54
let make = SyntaxFactory :: with_mappings ( ) ;
55
55
let mut editor = builder. make_editor ( rest_pat. syntax ( ) ) ;
56
- let new_field_list = make. record_pat_field_list ( old_field_list. fields ( ) , None ) ;
57
- for ( f, _) in missing_fields. iter ( ) {
58
- let field = make. record_pat_field_shorthand (
56
+ let new_fields = old_field_list. fields ( ) . chain ( missing_fields. iter ( ) . map ( |( f, _) | {
57
+ make. record_pat_field_shorthand (
59
58
make. ident_pat (
60
59
false ,
61
60
false ,
62
61
make. name ( & f. name ( ctx. sema . db ) . display_no_db ( edition) . to_smolstr ( ) ) ,
63
62
)
64
63
. into ( ) ,
65
- ) ;
66
- new_field_list . add_field ( field ) ;
67
- }
64
+ )
65
+ } ) ) ;
66
+ let new_field_list = make . record_pat_field_list ( new_fields , None ) ;
68
67
69
68
editor. replace ( old_field_list. syntax ( ) , new_field_list. syntax ( ) ) ;
70
69
@@ -214,7 +213,7 @@ enum Foo {
214
213
fn bar(foo: Foo) {
215
214
match foo {
216
215
Foo::A(_) => false,
217
- Foo::B{ y, z } => true,
216
+ Foo::B{ y, z } => true,
218
217
};
219
218
}
220
219
"# ,
@@ -275,7 +274,7 @@ struct Bar {
275
274
}
276
275
277
276
fn foo(bar: Bar) {
278
- let Bar { y, z } = bar;
277
+ let Bar { y, z } = bar;
279
278
}
280
279
"# ,
281
280
) ;
@@ -379,7 +378,7 @@ macro_rules! position {
379
378
position!(usize);
380
379
381
380
fn macro_call(pos: Pos) {
382
- let Pos { x, y } = pos;
381
+ let Pos { x, y } = pos;
383
382
}
384
383
"# ,
385
384
) ;
@@ -423,7 +422,7 @@ enum_gen!(usize);
423
422
fn macro_call(foo: Foo) {
424
423
match foo {
425
424
Foo::A(_) => false,
426
- Foo::B{ x, y } => true,
425
+ Foo::B{ x, y } => true,
427
426
}
428
427
}
429
428
"# ,
0 commit comments