aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting/tests.rs
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-07-31 03:31:53 +0100
committerPaul Daniel Faria <[email protected]>2020-08-16 15:26:16 +0100
commit3456e2eec7c1e18734f8fa41924a83b4c676dc00 (patch)
tree22c470056daeb136c64966cc4f4c976a8f45bf00 /crates/ide/src/syntax_highlighting/tests.rs
parenta044ff0138d6bff9406b94de89fde43e7672ee1b (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/tests.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs30
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() {
12use inner::{self as inner_mod}; 12use inner::{self as inner_mod};
13mod inner {} 13mod inner {}
14 14
15// Needed for function consuming vs normal
16pub mod marker {
17 #[lang = "copy"]
18 pub trait Copy {}
19}
20
15#[derive(Clone, Debug)] 21#[derive(Clone, Debug)]
16struct Foo { 22struct 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)]
52struct FooCopy {
53 x: u32,
54}
55
56impl 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
45static mut STATIC_MUT: i32 = 0; 70static mut STATIC_MUT: i32 = 0;
46 71
47fn foo<'a, T>() -> T { 72fn 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
101enum Option<T> { 131enum Option<T> {