File tree 1 file changed +61
-1
lines changed
crates/ide-assists/src/handlers 1 file changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -373,7 +373,9 @@ fn inline(
373
373
// We should place the following code after last usage of `usages_for_locals`
374
374
// because `ted::replace` will change the offset in syntax tree, which makes
375
375
// `FileReference` incorrect
376
- if let Some ( imp) = body. syntax ( ) . ancestors ( ) . find_map ( ast:: Impl :: cast) {
376
+ if let Some ( imp) =
377
+ sema. ancestors_with_macros ( fn_body. syntax ( ) . clone ( ) ) . find_map ( ast:: Impl :: cast)
378
+ {
377
379
if !node. syntax ( ) . ancestors ( ) . any ( |anc| & anc == imp. syntax ( ) ) {
378
380
if let Some ( t) = imp. self_ty ( ) {
379
381
while let Some ( self_tok) = body
@@ -1559,6 +1561,64 @@ fn a() -> bool {
1559
1561
this == &Enum::A || this == &Enum::B
1560
1562
}
1561
1563
}
1564
+ "# ,
1565
+ )
1566
+ }
1567
+
1568
+ #[ test]
1569
+ fn inline_call_with_self_type_in_macros ( ) {
1570
+ check_assist (
1571
+ inline_call,
1572
+ r#"
1573
+ trait Trait<T1> {
1574
+ fn f(a: T1) -> Self;
1575
+ }
1576
+
1577
+ macro_rules! impl_from {
1578
+ ($t: ty) => {
1579
+ impl Trait<$t> for $t {
1580
+ fn f(a: $t) -> Self {
1581
+ a as Self
1582
+ }
1583
+ }
1584
+ };
1585
+ }
1586
+
1587
+ struct A {}
1588
+
1589
+ impl_from!(A);
1590
+
1591
+ fn main() {
1592
+ let a: A = A{};
1593
+ let b = <A as Trait<A>>::$0f(a);
1594
+ }
1595
+ "# ,
1596
+ r#"
1597
+ trait Trait<T1> {
1598
+ fn f(a: T1) -> Self;
1599
+ }
1600
+
1601
+ macro_rules! impl_from {
1602
+ ($t: ty) => {
1603
+ impl Trait<$t> for $t {
1604
+ fn f(a: $t) -> Self {
1605
+ a as Self
1606
+ }
1607
+ }
1608
+ };
1609
+ }
1610
+
1611
+ struct A {}
1612
+
1613
+ impl_from!(A);
1614
+
1615
+ fn main() {
1616
+ let a: A = A{};
1617
+ let b = {
1618
+ let a = a;
1619
+ a as A
1620
+ };
1621
+ }
1562
1622
"# ,
1563
1623
)
1564
1624
}
You can’t perform that action at this time.
0 commit comments