diff options
author | Paul Daniel Faria <[email protected]> | 2020-05-23 22:49:53 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-06-27 15:08:14 +0100 |
commit | 0b95bed83fc8db897f54b350168567f14527e8de (patch) | |
tree | 94fc33b8e7f160ae2b45e38b32a70856006c93a2 /crates/ra_ide/src | |
parent | 9d1e2c4d9dc6c7f5fbaee5d9907d135f618d7ac6 (diff) |
Add unsafe diagnostics and unsafe highlighting
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index b7fad9719..39cd74ac3 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -370,3 +370,31 @@ fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { | |||
370 | fs::write(dst_file, &actual_html).unwrap(); | 370 | fs::write(dst_file, &actual_html).unwrap(); |
371 | assert_eq_text!(expected_html, actual_html); | 371 | assert_eq_text!(expected_html, actual_html); |
372 | } | 372 | } |
373 | |||
374 | #[test] | ||
375 | fn test_unsafe_highlighting() { | ||
376 | let (analysis, file_id) = single_file( | ||
377 | r#" | ||
378 | unsafe fn unsafe_fn() {} | ||
379 | |||
380 | struct HasUnsafeFn; | ||
381 | |||
382 | impl HasUnsafeFn { | ||
383 | unsafe fn unsafe_method(&self) {} | ||
384 | } | ||
385 | |||
386 | fn main() { | ||
387 | unsafe { | ||
388 | unsafe_fn(); | ||
389 | HasUnsafeFn.unsafe_method(); | ||
390 | } | ||
391 | } | ||
392 | "# | ||
393 | .trim(), | ||
394 | ); | ||
395 | let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_unsafe.html"); | ||
396 | let actual_html = &analysis.highlight_as_html(file_id, false).unwrap(); | ||
397 | let expected_html = &read_text(&dst_file); | ||
398 | fs::write(dst_file, &actual_html).unwrap(); | ||
399 | assert_eq_text!(expected_html, actual_html); | ||
400 | } | ||