aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-05-23 22:49:53 +0100
committerPaul Daniel Faria <[email protected]>2020-06-27 15:08:14 +0100
commit0b95bed83fc8db897f54b350168567f14527e8de (patch)
tree94fc33b8e7f160ae2b45e38b32a70856006c93a2 /crates/ra_ide/src
parent9d1e2c4d9dc6c7f5fbaee5d9907d135f618d7ac6 (diff)
Add unsafe diagnostics and unsafe highlighting
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs28
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]
375fn test_unsafe_highlighting() {
376 let (analysis, file_id) = single_file(
377 r#"
378unsafe fn unsafe_fn() {}
379
380struct HasUnsafeFn;
381
382impl HasUnsafeFn {
383 unsafe fn unsafe_method(&self) {}
384}
385
386fn 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}