File tree 1 file changed +42
-1
lines changed
crates/ide-assists/src/handlers
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(
168
168
let arg_list = call_expr. syntax( ) . descendants( ) . find_map( ast:: ArgList :: cast) ?;
169
169
170
170
edit. replace(
171
- call_expr . syntax ( ) . text_range ( ) ,
171
+ ctx . sema . original_range ( & node ) . range ,
172
172
ast:: make:: record_expr(
173
173
path,
174
174
ast:: make:: record_expr_field_list( arg_list. args( ) . zip( names) . map(
@@ -249,6 +249,24 @@ mod tests {
249
249
) ;
250
250
check_assist_not_applicable ( convert_tuple_struct_to_named_struct, r#"struct Foo$0;"# ) ;
251
251
}
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
+ }
252
270
253
271
#[ test]
254
272
fn convert_simple_struct ( ) {
@@ -554,6 +572,29 @@ where
554
572
) ;
555
573
}
556
574
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
+
557
598
#[ test]
558
599
fn convert_simple_variant ( ) {
559
600
check_assist (
You can’t perform that action at this time.
0 commit comments