File tree 1 file changed +81
-5
lines changed
crates/ide-assists/src/handlers
1 file changed +81
-5
lines changed Original file line number Diff line number Diff line change @@ -759,7 +759,7 @@ impl Foo {
759
759
760
760
fn main() {
761
761
let x = {
762
- let ref this = Foo(3);
762
+ let this = & Foo(3);
763
763
Foo(this.0 + 2)
764
764
};
765
765
}
@@ -795,7 +795,7 @@ impl Foo {
795
795
796
796
fn main() {
797
797
let x = {
798
- let ref this = Foo(3);
798
+ let this = & Foo(3);
799
799
Foo(this.0 + 2)
800
800
};
801
801
}
@@ -833,7 +833,7 @@ impl Foo {
833
833
fn main() {
834
834
let mut foo = Foo(3);
835
835
{
836
- let ref mut this = foo;
836
+ let this = &mut foo;
837
837
this.0 = 0;
838
838
};
839
839
}
@@ -920,7 +920,7 @@ impl Foo {
920
920
}
921
921
fn bar(&self) {
922
922
{
923
- let ref this = self;
923
+ let this = & self;
924
924
this;
925
925
this;
926
926
};
@@ -1595,7 +1595,7 @@ impl Enum {
1595
1595
1596
1596
fn a() -> bool {
1597
1597
{
1598
- let ref this = Enum::A;
1598
+ let this = & Enum::A;
1599
1599
this == &Enum::A || this == &Enum::B
1600
1600
}
1601
1601
}
@@ -1657,6 +1657,82 @@ fn main() {
1657
1657
a as A
1658
1658
};
1659
1659
}
1660
+ "# ,
1661
+ )
1662
+ }
1663
+
1664
+ #[ test]
1665
+ fn method_by_reborrow ( ) {
1666
+ check_assist (
1667
+ inline_call,
1668
+ r#"
1669
+ pub struct Foo(usize);
1670
+
1671
+ impl Foo {
1672
+ fn add1(&mut self) {
1673
+ self.0 += 1;
1674
+ }
1675
+ }
1676
+
1677
+ pub fn main() {
1678
+ let f = &mut Foo(0);
1679
+ f.add1$0();
1680
+ }
1681
+ "# ,
1682
+ r#"
1683
+ pub struct Foo(usize);
1684
+
1685
+ impl Foo {
1686
+ fn add1(&mut self) {
1687
+ self.0 += 1;
1688
+ }
1689
+ }
1690
+
1691
+ pub fn main() {
1692
+ let f = &mut Foo(0);
1693
+ {
1694
+ let this = &mut *f;
1695
+ this.0 += 1;
1696
+ };
1697
+ }
1698
+ "# ,
1699
+ )
1700
+ }
1701
+
1702
+ #[ test]
1703
+ fn method_by_mut ( ) {
1704
+ check_assist (
1705
+ inline_call,
1706
+ r#"
1707
+ pub struct Foo(usize);
1708
+
1709
+ impl Foo {
1710
+ fn add1(mut self) {
1711
+ self.0 += 1;
1712
+ }
1713
+ }
1714
+
1715
+ pub fn main() {
1716
+ let mut f = Foo(0);
1717
+ f.add1$0();
1718
+ }
1719
+ "# ,
1720
+ r#"
1721
+ pub struct Foo(usize);
1722
+
1723
+ impl Foo {
1724
+ fn add1(mut self) {
1725
+ self.0 += 1;
1726
+ }
1727
+ }
1728
+
1729
+ pub fn main() {
1730
+ let mut f = Foo(0);
1731
+ {
1732
+ let mut this = f;
1733
+ this.0 += 1;
1734
+ };
1735
+ }
1660
1736
"# ,
1661
1737
)
1662
1738
}
You can’t perform that action at this time.
0 commit comments