File tree Expand file tree Collapse file tree 1 file changed +47
-2
lines changed
crates/ide_assists/src/handlers Expand file tree Collapse file tree 1 file changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ fn edit_struct_references(
160160 . to_string( ) ,
161161 ) ;
162162 } ,
163- _ => ( )
163+ _ => return None ,
164164 }
165165 }
166166 Some ( ( ) )
@@ -170,7 +170,9 @@ fn edit_struct_references(
170170 edit. edit_file ( file_id) ;
171171 for r in refs {
172172 for node in r. name . syntax ( ) . ancestors ( ) {
173- edit_node ( edit, node) ;
173+ if edit_node ( edit, node) . is_some ( ) {
174+ break ;
175+ }
174176 }
175177 }
176178 }
@@ -377,6 +379,49 @@ impl A {
377379 ) ;
378380 }
379381
382+ #[ test]
383+ fn convert_struct_with_wrapped_references ( ) {
384+ check_assist (
385+ convert_tuple_struct_to_named_struct,
386+ r#"
387+ struct Inner$0(u32);
388+ struct Outer(Inner);
389+
390+ impl Outer {
391+ fn new() -> Self {
392+ Self(Inner(42))
393+ }
394+
395+ fn into_inner(self) -> u32 {
396+ (self.0).0
397+ }
398+
399+ fn into_inner_destructed(self) -> u32 {
400+ let Outer(Inner(x)) = self;
401+ x
402+ }
403+ }"# ,
404+ r#"
405+ struct Inner { field1: u32 }
406+ struct Outer(Inner);
407+
408+ impl Outer {
409+ fn new() -> Self {
410+ Self(Inner { field1: 42 })
411+ }
412+
413+ fn into_inner(self) -> u32 {
414+ (self.0).field1
415+ }
416+
417+ fn into_inner_destructed(self) -> u32 {
418+ let Outer(Inner { field1: x }) = self;
419+ x
420+ }
421+ }"# ,
422+ ) ;
423+ }
424+
380425 #[ test]
381426 fn convert_struct_with_multi_file_references ( ) {
382427 check_assist (
You can’t perform that action at this time.
0 commit comments