diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs index d73575fb9549..829d1279a839 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs @@ -137,7 +137,7 @@ fn punctuation( } (T![!], MACRO_RULES) => HlPunct::MacroBang.into(), (T![!], NEVER_TYPE) => HlTag::BuiltinType.into(), - (T![!], PREFIX_EXPR) => HlOperator::Logical.into(), + (T![!], PREFIX_EXPR) => HlOperator::Negation.into(), (T![*], PTR_TYPE) => HlTag::Keyword.into(), (T![*], PREFIX_EXPR) => { let h = HlTag::Operator(HlOperator::Other).into(); diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs index 4b8762640c74..456a61298741 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tags.rs @@ -124,8 +124,10 @@ pub enum HlOperator { Bitwise, /// +, -, *, /, +=, -=, *=, /= Arithmetic, - /// &&, ||, ! + /// &&, || Logical, + /// ! + Negation, /// >, <, ==, >=, <=, != Comparison, /// Other operators @@ -194,6 +196,7 @@ impl HlTag { HlOperator::Arithmetic => "arithmetic", HlOperator::Logical => "logical", HlOperator::Comparison => "comparison", + HlOperator::Negation => "negation", HlOperator::Other => "operator", }, HlTag::StringLiteral => "string_literal", diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html index d99b29cfb8fa..d058191aef72 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_general.html @@ -148,7 +148,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let baz = (-42,); let baz = -baz.0; - let _ = !true; + let _ = !true; 'foo: loop { break 'foo; diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_operators.html b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_operators.html index 9c42401ed077..cceb159c9dd4 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_operators.html +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_operators.html @@ -41,7 +41,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
fn main() {
- 1 + 1 - 1 * 1 / 1 % 1 | 1 & 1 ! 1 ^ 1 >> 1 << 1;
+ 1 + 1 - 1 * 1 / 1 % 1 | 1 & 1 ! 1 ^ 1 >> 1 << 1;
let mut a = 0;
a += 1;
a -= 1;
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs
index 3c21e1992525..828118a0866d 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/semantic_tokens.rs
@@ -91,6 +91,7 @@ define_semantic_token_types![
(LIFETIME, "lifetime"),
(LOGICAL, "logical") => OPERATOR,
(MACRO_BANG, "macroBang") => MACRO,
+ (NEGATION, "negation") => OPERATOR,
(PARENTHESIS, "parenthesis"),
(PROC_MACRO, "procMacro") => MACRO,
(PUNCTUATION, "punctuation"),
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs
index 04b20033062e..024c13e1918d 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs
@@ -847,6 +847,7 @@ fn semantic_token_type_and_modifiers(
HlOperator::Bitwise => types::BITWISE,
HlOperator::Arithmetic => types::ARITHMETIC,
HlOperator::Logical => types::LOGICAL,
+ HlOperator::Negation => types::NEGATION,
HlOperator::Comparison => types::COMPARISON,
HlOperator::Other => types::OPERATOR,
},