@@ -45,8 +45,8 @@ enum AddMissingImplMembersMode {
45
45
// }
46
46
//
47
47
// impl Trait<u32> for () {
48
- // $0fn foo(&self) -> u32 {
49
- // todo!()
48
+ // fn foo(&self) -> u32 {
49
+ // ${0: todo!()}
50
50
// }
51
51
//
52
52
// }
@@ -167,15 +167,23 @@ fn add_missing_impl_members_inner(
167
167
let original_range = impl_item_list. syntax ( ) . text_range ( ) ;
168
168
match ctx. config . snippet_cap {
169
169
None => builder. replace ( original_range, new_impl_item_list. to_string ( ) ) ,
170
- Some ( cap) => builder. replace_snippet (
171
- cap,
172
- original_range,
173
- render_snippet (
170
+ Some ( cap) => {
171
+ let mut cursor = Cursor :: Before ( first_new_item. syntax ( ) ) ;
172
+ let placeholder;
173
+ if let ast:: AssocItem :: FnDef ( func) = & first_new_item {
174
+ if let Some ( m) = func. syntax ( ) . descendants ( ) . find_map ( ast:: MacroCall :: cast) {
175
+ if m. syntax ( ) . text ( ) == "todo!()" {
176
+ placeholder = m;
177
+ cursor = Cursor :: Replace ( placeholder. syntax ( ) ) ;
178
+ }
179
+ }
180
+ }
181
+ builder. replace_snippet (
174
182
cap,
175
- new_impl_item_list . syntax ( ) ,
176
- Cursor :: Before ( first_new_item . syntax ( ) ) ,
177
- ) ,
178
- ) ,
183
+ original_range ,
184
+ render_snippet ( cap , new_impl_item_list . syntax ( ) , cursor ) ,
185
+ )
186
+ }
179
187
} ;
180
188
} )
181
189
}
@@ -271,8 +279,8 @@ struct S;
271
279
272
280
impl Foo for S {
273
281
fn bar(&self) {}
274
- $0fn foo(&self) {
275
- todo!()
282
+ fn foo(&self) {
283
+ ${0: todo!()}
276
284
}
277
285
278
286
}"# ,
@@ -291,8 +299,8 @@ impl Foo for S { <|> }"#,
291
299
trait Foo { fn foo(&self); }
292
300
struct S;
293
301
impl Foo for S {
294
- $0fn foo(&self) {
295
- todo!()
302
+ fn foo(&self) {
303
+ ${0: todo!()}
296
304
}
297
305
}"# ,
298
306
) ;
@@ -310,8 +318,8 @@ impl Foo<u32> for S { <|> }"#,
310
318
trait Foo<T> { fn foo(&self, t: T) -> &T; }
311
319
struct S;
312
320
impl Foo<u32> for S {
313
- $0fn foo(&self, t: u32) -> &u32 {
314
- todo!()
321
+ fn foo(&self, t: u32) -> &u32 {
322
+ ${0: todo!()}
315
323
}
316
324
}"# ,
317
325
) ;
@@ -329,8 +337,8 @@ impl<U> Foo<U> for S { <|> }"#,
329
337
trait Foo<T> { fn foo(&self, t: T) -> &T; }
330
338
struct S;
331
339
impl<U> Foo<U> for S {
332
- $0fn foo(&self, t: U) -> &U {
333
- todo!()
340
+ fn foo(&self, t: U) -> &U {
341
+ ${0: todo!()}
334
342
}
335
343
}"# ,
336
344
) ;
@@ -348,8 +356,8 @@ impl Foo for S {}<|>"#,
348
356
trait Foo { fn foo(&self); }
349
357
struct S;
350
358
impl Foo for S {
351
- $0fn foo(&self) {
352
- todo!()
359
+ fn foo(&self) {
360
+ ${0: todo!()}
353
361
}
354
362
}"# ,
355
363
)
@@ -373,8 +381,8 @@ mod foo {
373
381
}
374
382
struct S;
375
383
impl foo::Foo for S {
376
- $0fn foo(&self, bar: foo::Bar) {
377
- todo!()
384
+ fn foo(&self, bar: foo::Bar) {
385
+ ${0: todo!()}
378
386
}
379
387
}"# ,
380
388
) ;
@@ -398,8 +406,8 @@ mod foo {
398
406
}
399
407
struct S;
400
408
impl foo::Foo for S {
401
- $0fn foo(&self, bar: foo::Bar<u32>) {
402
- todo!()
409
+ fn foo(&self, bar: foo::Bar<u32>) {
410
+ ${0: todo!()}
403
411
}
404
412
}"# ,
405
413
) ;
@@ -423,8 +431,8 @@ mod foo {
423
431
}
424
432
struct S;
425
433
impl foo::Foo<u32> for S {
426
- $0fn foo(&self, bar: foo::Bar<u32>) {
427
- todo!()
434
+ fn foo(&self, bar: foo::Bar<u32>) {
435
+ ${0: todo!()}
428
436
}
429
437
}"# ,
430
438
) ;
@@ -451,8 +459,8 @@ mod foo {
451
459
struct Param;
452
460
struct S;
453
461
impl foo::Foo<Param> for S {
454
- $0fn foo(&self, bar: Param) {
455
- todo!()
462
+ fn foo(&self, bar: Param) {
463
+ ${0: todo!()}
456
464
}
457
465
}"# ,
458
466
) ;
@@ -478,8 +486,8 @@ mod foo {
478
486
}
479
487
struct S;
480
488
impl foo::Foo for S {
481
- $0fn foo(&self, bar: foo::Bar<u32>::Assoc) {
482
- todo!()
489
+ fn foo(&self, bar: foo::Bar<u32>::Assoc) {
490
+ ${0: todo!()}
483
491
}
484
492
}"# ,
485
493
) ;
@@ -505,8 +513,8 @@ mod foo {
505
513
}
506
514
struct S;
507
515
impl foo::Foo for S {
508
- $0fn foo(&self, bar: foo::Bar<foo::Baz>) {
509
- todo!()
516
+ fn foo(&self, bar: foo::Bar<foo::Baz>) {
517
+ ${0: todo!()}
510
518
}
511
519
}"# ,
512
520
) ;
@@ -530,8 +538,8 @@ mod foo {
530
538
}
531
539
struct S;
532
540
impl foo::Foo for S {
533
- $0fn foo(&self, bar: dyn Fn(u32) -> i32) {
534
- todo!()
541
+ fn foo(&self, bar: dyn Fn(u32) -> i32) {
542
+ ${0: todo!()}
535
543
}
536
544
}"# ,
537
545
) ;
@@ -645,8 +653,8 @@ trait Foo<T = Self> {
645
653
646
654
struct S;
647
655
impl Foo for S {
648
- $0fn bar(&self, other: &Self) {
649
- todo!()
656
+ fn bar(&self, other: &Self) {
657
+ ${0: todo!()}
650
658
}
651
659
}"# ,
652
660
)
@@ -670,8 +678,8 @@ trait Foo<T1, T2 = Self> {
670
678
671
679
struct S<T>;
672
680
impl Foo<T> for S<T> {
673
- $0fn bar(&self, this: &T, that: &Self) {
674
- todo!()
681
+ fn bar(&self, this: &T, that: &Self) {
682
+ ${0: todo!()}
675
683
}
676
684
}"# ,
677
685
)
0 commit comments