File tree Expand file tree Collapse file tree 1 file changed +81
-5
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +81
-5
lines changed Original file line number Diff line number Diff line change @@ -759,7 +759,7 @@ impl Foo {
759759
760760fn main() {
761761 let x = {
762- let ref this = Foo(3);
762+ let this = & Foo(3);
763763 Foo(this.0 + 2)
764764 };
765765}
@@ -795,7 +795,7 @@ impl Foo {
795795
796796fn main() {
797797 let x = {
798- let ref this = Foo(3);
798+ let this = & Foo(3);
799799 Foo(this.0 + 2)
800800 };
801801}
@@ -833,7 +833,7 @@ impl Foo {
833833fn main() {
834834 let mut foo = Foo(3);
835835 {
836- let ref mut this = foo;
836+ let this = &mut foo;
837837 this.0 = 0;
838838 };
839839}
@@ -920,7 +920,7 @@ impl Foo {
920920 }
921921 fn bar(&self) {
922922 {
923- let ref this = self;
923+ let this = & self;
924924 this;
925925 this;
926926 };
@@ -1595,7 +1595,7 @@ impl Enum {
15951595
15961596fn a() -> bool {
15971597 {
1598- let ref this = Enum::A;
1598+ let this = & Enum::A;
15991599 this == &Enum::A || this == &Enum::B
16001600 }
16011601}
@@ -1657,6 +1657,82 @@ fn main() {
16571657 a as A
16581658 };
16591659}
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+ }
16601736"# ,
16611737 )
16621738 }
You can’t perform that action at this time.
0 commit comments