File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ fn process_struct_name_reference(
187187 return None ;
188188 }
189189
190+ // FIXME: Processing RecordPat and RecordExpr for unordered fields, and insert RestPat
190191 let parent = full_path. syntax ( ) . parent ( ) ?;
191192 match_ast ! {
192193 match parent {
@@ -202,6 +203,9 @@ fn process_struct_name_reference(
202203 . record_pat_field_list( ) ?
203204 . fields( )
204205 . filter_map( |pat| pat. pat( ) )
206+ . chain( record_struct_pat. record_pat_field_list( ) ?
207+ . rest_pat( )
208+ . map( Into :: into) )
205209 )
206210 . to_string( )
207211 ) ;
@@ -346,6 +350,37 @@ impl A {
346350 ) ;
347351 }
348352
353+ #[ test]
354+ fn convert_struct_and_rest_pat ( ) {
355+ check_assist (
356+ convert_named_struct_to_tuple_struct,
357+ r#"
358+ struct Inner;
359+ struct A$0 { inner: Inner }
360+ fn foo(A { .. }: A) {}
361+ "# ,
362+ r#"
363+ struct Inner;
364+ struct A(Inner);
365+ fn foo(A(..): A) {}
366+ "# ,
367+ ) ;
368+
369+ check_assist (
370+ convert_named_struct_to_tuple_struct,
371+ r#"
372+ struct Inner;
373+ struct A$0 { inner: Inner, extra: Inner }
374+ fn foo(A { inner, .. }: A) {}
375+ "# ,
376+ r#"
377+ struct Inner;
378+ struct A(Inner, Inner);
379+ fn foo(A(inner, ..): A) {}
380+ "# ,
381+ ) ;
382+ }
383+
349384 #[ test]
350385 fn convert_simple_struct_cursor_on_visibility_keyword ( ) {
351386 check_assist (
You can’t perform that action at this time.
0 commit comments