diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-10 11:37:27 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-10 11:37:27 +0100 |
commit | f632727b2ab985a9c5ceca781d033a08ee3822ea (patch) | |
tree | b209cdea80c80c96c75ea2ded1f12ebc79d107fb /crates/ra_ide | |
parent | 9251f181de92c64b51e34980e591d2611b030140 (diff) | |
parent | db1cadd4447f7c580c5436a4368a4de3c67fa37a (diff) |
Merge #4834
4834: In field patterns, don't highlight local binding as a field r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/snapshots/highlighting.html | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 26 |
2 files changed, 17 insertions, 13 deletions
diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index e34ff5a7d..33548d43c 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html | |||
@@ -84,7 +84,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
84 | <span class="keyword">let</span> <span class="variable declaration mutable">y</span> = &<span class="keyword">mut</span> <span class="variable mutable">x</span>; | 84 | <span class="keyword">let</span> <span class="variable declaration mutable">y</span> = &<span class="keyword">mut</span> <span class="variable mutable">x</span>; |
85 | <span class="keyword">let</span> <span class="variable declaration">z</span> = &<span class="variable mutable">y</span>; | 85 | <span class="keyword">let</span> <span class="variable declaration">z</span> = &<span class="variable mutable">y</span>; |
86 | 86 | ||
87 | <span class="variable mutable">y</span>; | 87 | <span class="keyword">let</span> <span class="struct">Foo</span> { <span class="field">x</span>: <span class="variable declaration">z</span>, <span class="field">y</span> } = <span class="struct">Foo</span> { <span class="field">x</span>: <span class="variable">z</span>, <span class="field">y</span> }; |
88 | |||
89 | <span class="variable">y</span>; | ||
88 | } | 90 | } |
89 | 91 | ||
90 | <span class="keyword">enum</span> <span class="enum declaration">Option</span><<span class="type_param declaration">T</span>> { | 92 | <span class="keyword">enum</span> <span class="enum declaration">Option</span><<span class="type_param declaration">T</span>> { |
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 021f8e7e2..949bf59a0 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -7,18 +7,6 @@ use crate::{ | |||
7 | FileRange, TextRange, | 7 | FileRange, TextRange, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | /// Highlights the code given by the `ra_fixture` argument, renders the | ||
11 | /// result as HTML, and compares it with the HTML file given as `snapshot`. | ||
12 | /// Note that the `snapshot` file is overwritten by the rendered HTML. | ||
13 | fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { | ||
14 | let (analysis, file_id) = single_file(ra_fixture); | ||
15 | let dst_file = project_dir().join(snapshot); | ||
16 | let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); | ||
17 | let expected_html = &read_text(&dst_file); | ||
18 | fs::write(dst_file, &actual_html).unwrap(); | ||
19 | assert_eq_text!(expected_html, actual_html); | ||
20 | } | ||
21 | |||
22 | #[test] | 10 | #[test] |
23 | fn test_highlighting() { | 11 | fn test_highlighting() { |
24 | check_highlighting( | 12 | check_highlighting( |
@@ -77,6 +65,8 @@ fn main() { | |||
77 | let y = &mut x; | 65 | let y = &mut x; |
78 | let z = &y; | 66 | let z = &y; |
79 | 67 | ||
68 | let Foo { x: z, y } = Foo { x: z, y }; | ||
69 | |||
80 | y; | 70 | y; |
81 | } | 71 | } |
82 | 72 | ||
@@ -334,3 +324,15 @@ impl Foo { | |||
334 | false, | 324 | false, |
335 | ) | 325 | ) |
336 | } | 326 | } |
327 | |||
328 | /// Highlights the code given by the `ra_fixture` argument, renders the | ||
329 | /// result as HTML, and compares it with the HTML file given as `snapshot`. | ||
330 | /// Note that the `snapshot` file is overwritten by the rendered HTML. | ||
331 | fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { | ||
332 | let (analysis, file_id) = single_file(ra_fixture); | ||
333 | let dst_file = project_dir().join(snapshot); | ||
334 | let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); | ||
335 | let expected_html = &read_text(&dst_file); | ||
336 | fs::write(dst_file, &actual_html).unwrap(); | ||
337 | assert_eq_text!(expected_html, actual_html); | ||
338 | } | ||