diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-19 12:27:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-19 12:27:02 +0100 |
commit | 529ca7e5e0573e15b23cd0067a691bf1ffebae84 (patch) | |
tree | 0cc09513805718a7c31cadb1776ff4eb865caaef /crates/ide/src/syntax_highlighting/tests.rs | |
parent | c1cfd010096daa85f8acd6f1ea15d92097816e14 (diff) | |
parent | 3456e2eec7c1e18734f8fa41924a83b4c676dc00 (diff) |
Merge #5643
5643: Add new consuming modifier, apply consuming and mutable to methods r=matklad a=Nashenas88
This adds a new `consuming` semantic modifier for syntax highlighters.
This also emits `mutable` and `consuming` in two cases:
- When a method takes `&mut self`, then it now has `function.mutable` emitted.
- When a method takes `self`, and the type of `Self` is not `Copy`, then `function.consuming` is emitted.
CC @flodiebold
Co-authored-by: Paul Daniel Faria <[email protected]>
Diffstat (limited to 'crates/ide/src/syntax_highlighting/tests.rs')
-rw-r--r-- | crates/ide/src/syntax_highlighting/tests.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 94f37d773..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, |
@@ -36,6 +42,29 @@ impl Foo { | |||
36 | fn qux(&mut self) { | 42 | fn qux(&mut self) { |
37 | self.x = 0; | 43 | self.x = 0; |
38 | } | 44 | } |
45 | |||
46 | fn quop(&self) -> i32 { | ||
47 | self.x | ||
48 | } | ||
49 | } | ||
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 | } | ||
39 | } | 68 | } |
40 | 69 | ||
41 | static mut STATIC_MUT: i32 = 0; | 70 | static mut STATIC_MUT: i32 = 0; |
@@ -87,6 +116,16 @@ fn main() { | |||
87 | let Foo { x: z, y } = Foo { x: z, y }; | 116 | let Foo { x: z, y } = Foo { x: z, y }; |
88 | 117 | ||
89 | y; | 118 | y; |
119 | |||
120 | let mut foo = Foo { x, y: x }; | ||
121 | foo.quop(); | ||
122 | foo.qux(); | ||
123 | foo.baz(); | ||
124 | |||
125 | let mut copy = FooCopy { x }; | ||
126 | copy.quop(); | ||
127 | copy.qux(); | ||
128 | copy.baz(); | ||
90 | } | 129 | } |
91 | 130 | ||
92 | enum Option<T> { | 131 | enum Option<T> { |