From 7af947a032bd2e6f6df6b903b40f142cd7b8d9e0 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 6 Sep 2020 12:26:53 -0400 Subject: Add consuming modifier to lvalues that are passed by value and not Copy --- .../ide/src/syntax_highlighting/test_data/highlighting.html | 13 +++++++------ crates/ide/src/syntax_highlighting/tests.rs | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'crates/ide/src/syntax_highlighting') diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index d0df2e0ec..cade46348 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -61,8 +61,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } impl Foo { - fn baz(mut self) -> i32 { - self.x + fn baz(mut self, f: Foo) -> i32 { + f.baz(self) } fn qux(&mut self) { @@ -80,8 +80,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } impl FooCopy { - fn baz(self) -> u32 { - self.x + fn baz(self, f: FooCopy) -> u32 { + f.baz(self) } fn qux(&mut self) { @@ -144,14 +144,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd y; let mut foo = Foo { x, y: x }; + let foo2 = foo.clone(); foo.quop(); foo.qux(); - foo.baz(); + foo.baz(foo2); let mut copy = FooCopy { x }; copy.quop(); copy.qux(); - copy.baz(); + copy.baz(copy); } enum Option<T> { diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 6f72a29bd..57d4e1252 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -35,8 +35,8 @@ impl Bar for Foo { } impl Foo { - fn baz(mut self) -> i32 { - self.x + fn baz(mut self, f: Foo) -> i32 { + f.baz(self) } fn qux(&mut self) { @@ -54,8 +54,8 @@ struct FooCopy { } impl FooCopy { - fn baz(self) -> u32 { - self.x + fn baz(self, f: FooCopy) -> u32 { + f.baz(self) } fn qux(&mut self) { @@ -118,14 +118,15 @@ fn main() { y; let mut foo = Foo { x, y: x }; + let foo2 = foo.clone(); foo.quop(); foo.qux(); - foo.baz(); + foo.baz(foo2); let mut copy = FooCopy { x }; copy.quop(); copy.qux(); - copy.baz(); + copy.baz(copy); } enum Option { -- cgit v1.2.3 From a1a7b07ad33b7dcadedc2af26c3a5f8ef3daca27 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 6 Sep 2020 14:34:01 -0400 Subject: Fix handling of consuming self, refactor shared logic into a single function --- crates/ide/src/syntax_highlighting/test_data/highlighting.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ide/src/syntax_highlighting') diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index cade46348..cde42024c 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -62,7 +62,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd impl Foo { fn baz(mut self, f: Foo) -> i32 { - f.baz(self) + f.baz(self) } fn qux(&mut self) { -- cgit v1.2.3