From db1cadd4447f7c580c5436a4368a4de3c67fa37a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 10 Jun 2020 12:34:23 +0200 Subject: In field patterns, don't highlight local binding as a field --- crates/ra_ide/src/snapshots/highlighting.html | 4 +++- crates/ra_ide/src/syntax_highlighting/tests.rs | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'crates/ra_ide/src') 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 let y = &mut x; let z = &y; - y; + let Foo { x: z, y } = Foo { x: z, y }; + + y; } enum Option<T> { 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::{ FileRange, TextRange, }; -/// Highlights the code given by the `ra_fixture` argument, renders the -/// result as HTML, and compares it with the HTML file given as `snapshot`. -/// Note that the `snapshot` file is overwritten by the rendered HTML. -fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { - let (analysis, file_id) = single_file(ra_fixture); - let dst_file = project_dir().join(snapshot); - let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); - let expected_html = &read_text(&dst_file); - fs::write(dst_file, &actual_html).unwrap(); - assert_eq_text!(expected_html, actual_html); -} - #[test] fn test_highlighting() { check_highlighting( @@ -77,6 +65,8 @@ fn main() { let y = &mut x; let z = &y; + let Foo { x: z, y } = Foo { x: z, y }; + y; } @@ -334,3 +324,15 @@ impl Foo { false, ) } + +/// Highlights the code given by the `ra_fixture` argument, renders the +/// result as HTML, and compares it with the HTML file given as `snapshot`. +/// Note that the `snapshot` file is overwritten by the rendered HTML. +fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { + let (analysis, file_id) = single_file(ra_fixture); + let dst_file = project_dir().join(snapshot); + let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); + let expected_html = &read_text(&dst_file); + fs::write(dst_file, &actual_html).unwrap(); + assert_eq_text!(expected_html, actual_html); +} -- cgit v1.2.3