From 0b95bed83fc8db897f54b350168567f14527e8de Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sat, 23 May 2020 17:49:53 -0400 Subject: Add unsafe diagnostics and unsafe highlighting --- crates/ra_ide/src/syntax_highlighting/tests.rs | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/ra_ide') 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) { fs::write(dst_file, &actual_html).unwrap(); assert_eq_text!(expected_html, actual_html); } + +#[test] +fn test_unsafe_highlighting() { + let (analysis, file_id) = single_file( + r#" +unsafe fn unsafe_fn() {} + +struct HasUnsafeFn; + +impl HasUnsafeFn { + unsafe fn unsafe_method(&self) {} +} + +fn main() { + unsafe { + unsafe_fn(); + HasUnsafeFn.unsafe_method(); + } +} +"# + .trim(), + ); + let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_unsafe.html"); + let actual_html = &analysis.highlight_as_html(file_id, false).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 From daf1cac9f87023d37a4418ea24ed615c9706258b Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 24 May 2020 01:33:22 -0400 Subject: Move diagnostics back into expr, add tests for diagnostics, fix logic to account for derefs of raw ptrs --- crates/ra_ide/src/syntax_highlighting/tests.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 39cd74ac3..43f554a29 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -384,9 +384,11 @@ impl HasUnsafeFn { } fn main() { + let x = &5 as *usize; unsafe { unsafe_fn(); HasUnsafeFn.unsafe_method(); + let y = *x; } } "# -- cgit v1.2.3 From c622551ec27c9d68e8310c2408317253952b6f44 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 24 May 2020 13:20:03 -0400 Subject: Fix typo in test --- crates/ra_ide/src/syntax_highlighting/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 43f554a29..e9a6fbcdf 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -384,7 +384,7 @@ impl HasUnsafeFn { } fn main() { - let x = &5 as *usize; + let x = &5 as *const usize; unsafe { unsafe_fn(); HasUnsafeFn.unsafe_method(); -- cgit v1.2.3 From 6c1682396c9894da07af74b43c2443e9bde89be4 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Wed, 27 May 2020 22:37:23 -0400 Subject: Account for deref token in syntax highlighting of unsafe, add test for that case --- crates/ra_ide/src/syntax_highlighting/tests.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index e9a6fbcdf..facdc42b7 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -389,6 +389,7 @@ fn main() { unsafe_fn(); HasUnsafeFn.unsafe_method(); let y = *x; + let z = -x; } } "# -- cgit v1.2.3 From f678e0d837e472dc2f1421f89f794d33f3ade55c Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 28 May 2020 09:30:19 -0400 Subject: Add HighlightTag::Operator, use it for unsafe deref. Move unsafe validation to its own file --- crates/ra_ide/src/snapshots/highlight_injection.html | 2 +- crates/ra_ide/src/snapshots/highlight_strings.html | 2 +- crates/ra_ide/src/snapshots/highlight_unsafe.html | 4 ++-- crates/ra_ide/src/snapshots/highlighting.html | 2 +- crates/ra_ide/src/snapshots/rainbow_highlighting.html | 2 +- crates/ra_ide/src/syntax_highlighting/html.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/snapshots/highlight_injection.html b/crates/ra_ide/src/snapshots/highlight_injection.html index 1b0349bae..3ac6c4ae5 100644 --- a/crates/ra_ide/src/snapshots/highlight_injection.html +++ b/crates/ra_ide/src/snapshots/highlight_injection.html @@ -12,7 +12,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #BC8383; } +.function.unsafe { color: #E28C14; } .operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } diff --git a/crates/ra_ide/src/snapshots/highlight_strings.html b/crates/ra_ide/src/snapshots/highlight_strings.html index d184b5691..8556eb850 100644 --- a/crates/ra_ide/src/snapshots/highlight_strings.html +++ b/crates/ra_ide/src/snapshots/highlight_strings.html @@ -12,7 +12,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #BC8383; } +.function.unsafe { color: #E28C14; } .operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } diff --git a/crates/ra_ide/src/snapshots/highlight_unsafe.html b/crates/ra_ide/src/snapshots/highlight_unsafe.html index 6936e949f..692307280 100644 --- a/crates/ra_ide/src/snapshots/highlight_unsafe.html +++ b/crates/ra_ide/src/snapshots/highlight_unsafe.html @@ -12,7 +12,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #BC8383; } +.function.unsafe { color: #E28C14; } .operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } @@ -47,7 +47,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd unsafe { unsafe_fn(); HasUnsafeFn.unsafe_method(); - let y = *(x); + let y = *x; let z = -x; } } \ No newline at end of file diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 8d0b38f95..47403b367 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -12,7 +12,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #BC8383; } +.function.unsafe { color: #E28C14; } .operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index 9516c7441..f5fb96f55 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -12,7 +12,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #BC8383; } +.function.unsafe { color: #E28C14; } .operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 0c74f7370..ed007c382 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -71,7 +71,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #BC8383; } +.function.unsafe { color: #E28C14; } .operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } -- cgit v1.2.3 From 2ca52bbb325d4842d9642fc5f9e368b590c4ce41 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Tue, 2 Jun 2020 18:58:42 -0400 Subject: Revert ide highlighting changes (addressing on another branch) --- .../ra_ide/src/snapshots/highlight_injection.html | 2 +- crates/ra_ide/src/snapshots/highlight_strings.html | 2 +- crates/ra_ide/src/snapshots/highlight_unsafe.html | 53 ---------------------- crates/ra_ide/src/snapshots/highlighting.html | 2 +- .../ra_ide/src/snapshots/rainbow_highlighting.html | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 8 +--- crates/ra_ide/src/syntax_highlighting/html.rs | 2 +- crates/ra_ide/src/syntax_highlighting/tags.rs | 8 ++-- crates/ra_ide/src/syntax_highlighting/tests.rs | 31 ------------- 9 files changed, 10 insertions(+), 100 deletions(-) delete mode 100644 crates/ra_ide/src/snapshots/highlight_unsafe.html (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/snapshots/highlight_injection.html b/crates/ra_ide/src/snapshots/highlight_injection.html index 3ac6c4ae5..748f07625 100644 --- a/crates/ra_ide/src/snapshots/highlight_injection.html +++ b/crates/ra_ide/src/snapshots/highlight_injection.html @@ -13,7 +13,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .field { color: #94BFF3; } .function { color: #93E0E3; } .function.unsafe { color: #E28C14; } -.operator.unsafe { color: #BC8383; } +.operator.unsafe { color: #E28C14; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/snapshots/highlight_strings.html b/crates/ra_ide/src/snapshots/highlight_strings.html index 8556eb850..12a68ce62 100644 --- a/crates/ra_ide/src/snapshots/highlight_strings.html +++ b/crates/ra_ide/src/snapshots/highlight_strings.html @@ -13,7 +13,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .field { color: #94BFF3; } .function { color: #93E0E3; } .function.unsafe { color: #E28C14; } -.operator.unsafe { color: #BC8383; } +.operator.unsafe { color: #E28C14; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/snapshots/highlight_unsafe.html b/crates/ra_ide/src/snapshots/highlight_unsafe.html deleted file mode 100644 index 692307280..000000000 --- a/crates/ra_ide/src/snapshots/highlight_unsafe.html +++ /dev/null @@ -1,53 +0,0 @@ - - -
unsafe fn unsafe_fn() {}
-
-struct HasUnsafeFn;
-
-impl HasUnsafeFn {
-    unsafe fn unsafe_method(&self) {}
-}
-
-fn main() {
-    let x = &5 as *const usize;
-    unsafe {
-        unsafe_fn();
-        HasUnsafeFn.unsafe_method();
-        let y = *x;
-        let z = -x;
-    }
-}
\ No newline at end of file diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 47403b367..d093a6266 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -13,7 +13,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .field { color: #94BFF3; } .function { color: #93E0E3; } .function.unsafe { color: #E28C14; } -.operator.unsafe { color: #BC8383; } +.operator.unsafe { color: #E28C14; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index f5fb96f55..192d564a6 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -13,7 +13,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .field { color: #94BFF3; } .function { color: #93E0E3; } .function.unsafe { color: #E28C14; } -.operator.unsafe { color: #BC8383; } +.operator.unsafe { color: #E28C14; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 028b55902..fb4f2ce38 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -605,13 +605,7 @@ fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { Definition::Field(_) => HighlightTag::Field, Definition::ModuleDef(def) => match def { hir::ModuleDef::Module(_) => HighlightTag::Module, - hir::ModuleDef::Function(func) => { - let mut h = HighlightTag::Function.into(); - if func.is_unsafe(db) { - h |= HighlightModifier::Unsafe; - } - return h; - } + hir::ModuleDef::Function(_) => HighlightTag::Function, hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum, hir::ModuleDef::Adt(hir::Adt::Union(_)) => HighlightTag::Union, diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index ed007c382..3477610e5 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -72,7 +72,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .field { color: #94BFF3; } .function { color: #93E0E3; } .function.unsafe { color: #E28C14; } -.operator.unsafe { color: #BC8383; } +.operator.unsafe { color: #E28C14; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index e8e251cfc..b9bea4729 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -25,7 +25,6 @@ pub enum HighlightTag { EnumVariant, EscapeSequence, Field, - FormatSpecifier, Function, Generic, Keyword, @@ -33,7 +32,6 @@ pub enum HighlightTag { Macro, Module, NumericLiteral, - Operator, SelfKeyword, SelfType, Static, @@ -45,6 +43,8 @@ pub enum HighlightTag { Union, Local, UnresolvedReference, + FormatSpecifier, + Operator, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -77,7 +77,6 @@ impl HighlightTag { HighlightTag::EnumVariant => "enum_variant", HighlightTag::EscapeSequence => "escape_sequence", HighlightTag::Field => "field", - HighlightTag::FormatSpecifier => "format_specifier", HighlightTag::Function => "function", HighlightTag::Generic => "generic", HighlightTag::Keyword => "keyword", @@ -85,7 +84,6 @@ impl HighlightTag { HighlightTag::Macro => "macro", HighlightTag::Module => "module", HighlightTag::NumericLiteral => "numeric_literal", - HighlightTag::Operator => "operator", HighlightTag::SelfKeyword => "self_keyword", HighlightTag::SelfType => "self_type", HighlightTag::Static => "static", @@ -97,6 +95,8 @@ impl HighlightTag { HighlightTag::Union => "union", HighlightTag::Local => "variable", HighlightTag::UnresolvedReference => "unresolved_reference", + HighlightTag::FormatSpecifier => "format_specifier", + HighlightTag::Operator => "operator", } } } diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index facdc42b7..b7fad9719 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -370,34 +370,3 @@ fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) { fs::write(dst_file, &actual_html).unwrap(); assert_eq_text!(expected_html, actual_html); } - -#[test] -fn test_unsafe_highlighting() { - let (analysis, file_id) = single_file( - r#" -unsafe fn unsafe_fn() {} - -struct HasUnsafeFn; - -impl HasUnsafeFn { - unsafe fn unsafe_method(&self) {} -} - -fn main() { - let x = &5 as *const usize; - unsafe { - unsafe_fn(); - HasUnsafeFn.unsafe_method(); - let y = *x; - let z = -x; - } -} -"# - .trim(), - ); - let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_unsafe.html"); - let actual_html = &analysis.highlight_as_html(file_id, false).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 From b1992b469cae689f7de01ea9031962735a409198 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sat, 27 Jun 2020 11:20:02 -0400 Subject: Remove unneeded code, filename from tests, fix rebasing issues --- .../ra_ide/src/snapshots/highlight_injection.html | 4 +- crates/ra_ide/src/snapshots/highlight_strings.html | 4 +- crates/ra_ide/src/snapshots/highlight_unsafe.html | 53 ++++++++++++++++++++++ crates/ra_ide/src/snapshots/highlighting.html | 4 +- .../ra_ide/src/snapshots/rainbow_highlighting.html | 4 +- crates/ra_ide/src/syntax_highlighting.rs | 8 +++- crates/ra_ide/src/syntax_highlighting/html.rs | 4 +- crates/ra_ide/src/syntax_highlighting/tags.rs | 4 +- 8 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 crates/ra_ide/src/snapshots/highlight_unsafe.html (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/snapshots/highlight_injection.html b/crates/ra_ide/src/snapshots/highlight_injection.html index 748f07625..1b0349bae 100644 --- a/crates/ra_ide/src/snapshots/highlight_injection.html +++ b/crates/ra_ide/src/snapshots/highlight_injection.html @@ -12,8 +12,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #E28C14; } -.operator.unsafe { color: #E28C14; } +.function.unsafe { color: #BC8383; } +.operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/snapshots/highlight_strings.html b/crates/ra_ide/src/snapshots/highlight_strings.html index 12a68ce62..d184b5691 100644 --- a/crates/ra_ide/src/snapshots/highlight_strings.html +++ b/crates/ra_ide/src/snapshots/highlight_strings.html @@ -12,8 +12,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #E28C14; } -.operator.unsafe { color: #E28C14; } +.function.unsafe { color: #BC8383; } +.operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/snapshots/highlight_unsafe.html b/crates/ra_ide/src/snapshots/highlight_unsafe.html new file mode 100644 index 000000000..6936e949f --- /dev/null +++ b/crates/ra_ide/src/snapshots/highlight_unsafe.html @@ -0,0 +1,53 @@ + + +
unsafe fn unsafe_fn() {}
+
+struct HasUnsafeFn;
+
+impl HasUnsafeFn {
+    unsafe fn unsafe_method(&self) {}
+}
+
+fn main() {
+    let x = &5 as *const usize;
+    unsafe {
+        unsafe_fn();
+        HasUnsafeFn.unsafe_method();
+        let y = *(x);
+        let z = -x;
+    }
+}
\ No newline at end of file diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index d093a6266..8d0b38f95 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -12,8 +12,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #E28C14; } -.operator.unsafe { color: #E28C14; } +.function.unsafe { color: #BC8383; } +.operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index 192d564a6..9516c7441 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -12,8 +12,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #E28C14; } -.operator.unsafe { color: #E28C14; } +.function.unsafe { color: #BC8383; } +.operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index fb4f2ce38..028b55902 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -605,7 +605,13 @@ fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { Definition::Field(_) => HighlightTag::Field, Definition::ModuleDef(def) => match def { hir::ModuleDef::Module(_) => HighlightTag::Module, - hir::ModuleDef::Function(_) => HighlightTag::Function, + hir::ModuleDef::Function(func) => { + let mut h = HighlightTag::Function.into(); + if func.is_unsafe(db) { + h |= HighlightModifier::Unsafe; + } + return h; + } hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum, hir::ModuleDef::Adt(hir::Adt::Union(_)) => HighlightTag::Union, diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 3477610e5..0c74f7370 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -71,8 +71,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } -.function.unsafe { color: #E28C14; } -.operator.unsafe { color: #E28C14; } +.function.unsafe { color: #BC8383; } +.operator.unsafe { color: #BC8383; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index b9bea4729..13d9dd195 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -77,6 +77,7 @@ impl HighlightTag { HighlightTag::EnumVariant => "enum_variant", HighlightTag::EscapeSequence => "escape_sequence", HighlightTag::Field => "field", + HighlightTag::FormatSpecifier => "format_specifier", HighlightTag::Function => "function", HighlightTag::Generic => "generic", HighlightTag::Keyword => "keyword", @@ -84,6 +85,7 @@ impl HighlightTag { HighlightTag::Macro => "macro", HighlightTag::Module => "module", HighlightTag::NumericLiteral => "numeric_literal", + HighlightTag::Operator => "operator", HighlightTag::SelfKeyword => "self_keyword", HighlightTag::SelfType => "self_type", HighlightTag::Static => "static", @@ -95,8 +97,6 @@ impl HighlightTag { HighlightTag::Union => "union", HighlightTag::Local => "variable", HighlightTag::UnresolvedReference => "unresolved_reference", - HighlightTag::FormatSpecifier => "format_specifier", - HighlightTag::Operator => "operator", } } } -- cgit v1.2.3