diff options
author | Paul Daniel Faria <[email protected]> | 2020-07-31 03:31:53 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-08-16 15:26:16 +0100 |
commit | 3456e2eec7c1e18734f8fa41924a83b4c676dc00 (patch) | |
tree | 22c470056daeb136c64966cc4f4c976a8f45bf00 /crates/ide/src/syntax_highlighting | |
parent | a044ff0138d6bff9406b94de89fde43e7672ee1b (diff) |
Add new method to Semantics, method_receiver_kind, which returns the kind of self
The options are Shared, Mutable, Consuming, and Copied. Use this to add proper
highlighting to methods based on usage.
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r-- | crates/ide/src/syntax_highlighting/tests.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 6cb955d29..ccb76f552 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs | |||
@@ -12,6 +12,12 @@ fn test_highlighting() { | |||
12 | use inner::{self as inner_mod}; | 12 | use inner::{self as inner_mod}; |
13 | mod inner {} | 13 | mod inner {} |
14 | 14 | ||
15 | // Needed for function consuming vs normal | ||
16 | pub mod marker { | ||
17 | #[lang = "copy"] | ||
18 | pub trait Copy {} | ||
19 | } | ||
20 | |||
15 | #[derive(Clone, Debug)] | 21 | #[derive(Clone, Debug)] |
16 | struct Foo { | 22 | struct Foo { |
17 | pub x: i32, | 23 | pub x: i32, |
@@ -42,6 +48,25 @@ impl Foo { | |||
42 | } | 48 | } |
43 | } | 49 | } |
44 | 50 | ||
51 | #[derive(Copy, Clone)] | ||
52 | struct FooCopy { | ||
53 | x: u32, | ||
54 | } | ||
55 | |||
56 | impl FooCopy { | ||
57 | fn baz(self) -> u32 { | ||
58 | self.x | ||
59 | } | ||
60 | |||
61 | fn qux(&mut self) { | ||
62 | self.x = 0; | ||
63 | } | ||
64 | |||
65 | fn quop(&self) -> u32 { | ||
66 | self.x | ||
67 | } | ||
68 | } | ||
69 | |||
45 | static mut STATIC_MUT: i32 = 0; | 70 | static mut STATIC_MUT: i32 = 0; |
46 | 71 | ||
47 | fn foo<'a, T>() -> T { | 72 | fn foo<'a, T>() -> T { |
@@ -96,6 +121,11 @@ fn main() { | |||
96 | foo.quop(); | 121 | foo.quop(); |
97 | foo.qux(); | 122 | foo.qux(); |
98 | foo.baz(); | 123 | foo.baz(); |
124 | |||
125 | let mut copy = FooCopy { x }; | ||
126 | copy.quop(); | ||
127 | copy.qux(); | ||
128 | copy.baz(); | ||
99 | } | 129 | } |
100 | 130 | ||
101 | enum Option<T> { | 131 | enum Option<T> { |