This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +42
-1
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ fn edit_struct_references(
168168 let arg_list = call_expr. syntax( ) . descendants( ) . find_map( ast:: ArgList :: cast) ?;
169169
170170 edit. replace(
171- call_expr . syntax ( ) . text_range ( ) ,
171+ ctx . sema . original_range ( & node ) . range ,
172172 ast:: make:: record_expr(
173173 path,
174174 ast:: make:: record_expr_field_list( arg_list. args( ) . zip( names) . map(
@@ -249,6 +249,24 @@ mod tests {
249249 ) ;
250250 check_assist_not_applicable ( convert_tuple_struct_to_named_struct, r#"struct Foo$0;"# ) ;
251251 }
252+ #[ test]
253+ fn convert_in_macro_args ( ) {
254+ check_assist (
255+ convert_tuple_struct_to_named_struct,
256+ r#"
257+ macro_rules! foo {($i:expr) => {$i} }
258+ struct T$0(u8);
259+ fn test() {
260+ foo!(T(1));
261+ }"# ,
262+ r#"
263+ macro_rules! foo {($i:expr) => {$i} }
264+ struct T { field1: u8 }
265+ fn test() {
266+ foo!(T { field1: 1 });
267+ }"# ,
268+ ) ;
269+ }
252270
253271 #[ test]
254272 fn convert_simple_struct ( ) {
@@ -554,6 +572,29 @@ where
554572 ) ;
555573 }
556574
575+ #[ test]
576+ fn convert_variant_in_macro_args ( ) {
577+ check_assist (
578+ convert_tuple_struct_to_named_struct,
579+ r#"
580+ macro_rules! foo {($i:expr) => {$i} }
581+ enum T {
582+ V$0(u8)
583+ }
584+ fn test() {
585+ foo!(T::V(1));
586+ }"# ,
587+ r#"
588+ macro_rules! foo {($i:expr) => {$i} }
589+ enum T {
590+ V { field1: u8 }
591+ }
592+ fn test() {
593+ foo!(T::V { field1: 1 });
594+ }"# ,
595+ ) ;
596+ }
597+
557598 #[ test]
558599 fn convert_simple_variant ( ) {
559600 check_assist (
You can’t perform that action at this time.
0 commit comments