diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 8f8d8face4..ee07343966 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -465,7 +465,8 @@ pub(super) fn highlight_def(
}
Definition::BuiltinType(_) => Highlight::new(HlTag::BuiltinType),
Definition::Static(s) => {
- let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Static));
+ let mut h =
+ Highlight::new(HlTag::Symbol(SymbolKind::Static)) | HlMod::Static | HlMod::Const;
if s.is_mut(db) {
h |= HlMod::Mutable;
@@ -478,7 +479,7 @@ pub(super) fn highlight_def(
Definition::GenericParam(it) => match it {
hir::GenericParam::TypeParam(_) => Highlight::new(HlTag::Symbol(SymbolKind::TypeParam)),
hir::GenericParam::ConstParam(_) => {
- Highlight::new(HlTag::Symbol(SymbolKind::ConstParam))
+ Highlight::new(HlTag::Symbol(SymbolKind::ConstParam)) | HlMod::Const
}
hir::GenericParam::LifetimeParam(_) => {
Highlight::new(HlTag::Symbol(SymbolKind::LifetimeParam))
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_block_mod_items.html b/crates/ide/src/syntax_highlighting/test_data/highlight_block_mod_items.html
index 4c817629c1..f86197d739 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_block_mod_items.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_block_mod_items.html
@@ -58,7 +58,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
foo!(Bar);
fn func() {
mod inner {
- struct Innerest<const C: usize> { field: [(); {C}] }
+ struct Innerest<const C: usize> { field: [(); {C}] }
}
}
}
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
index c9460da6f3..01f50346b4 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html
@@ -119,8 +119,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
- fn foo<T, const X: usize>(arg: i32) {
- let x: T = X;
+ fn foo<T, const X: usize>(arg: i32) {
+ let x: T = X;
}
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_general.html b/crates/ide/src/syntax_highlighting/test_data/highlight_general.html
index cc60d36beb..5c67ea4add 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_general.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_general.html
@@ -119,9 +119,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
loop {}
}
-fn const_param<const FOO: usize>() -> usize {
- const_param::<{ FOO }>();
- FOO
+fn const_param<const FOO: usize>() -> usize {
+ const_param::<{ FOO }>();
+ FOO
}
use ops::Fn;
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html
index 6d4df43179..eb4afc83ef 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html
@@ -54,8 +54,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
*(&() as *const ())
};
}
-static mut MUT_GLOBAL: Struct = Struct { field: 0 };
-static GLOBAL: Struct = Struct { field: 0 };
+static mut MUT_GLOBAL: Struct = Struct { field: 0 };
+static GLOBAL: Struct = Struct { field: 0 };
unsafe fn unsafe_fn() {}
union Union {
@@ -112,8 +112,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
*x;
- MUT_GLOBAL.field;
- GLOBAL.field;
+ MUT_GLOBAL.field;
+ GLOBAL.field;
let packed = Packed { a: 0 };
diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs
index 4a4a7b72ef..d927f1f3e7 100644
--- a/crates/rust-analyzer/src/lsp/to_proto.rs
+++ b/crates/rust-analyzer/src/lsp/to_proto.rs
@@ -636,7 +636,6 @@ pub(crate) fn semantic_token_delta(
fn semantic_token_type_and_modifiers(
highlight: Highlight,
) -> (lsp_types::SemanticTokenType, semantic_tokens::ModifierSet) {
- let mut mods = semantic_tokens::ModifierSet::default();
let type_ = match highlight.tag {
HlTag::Symbol(symbol) => match symbol {
SymbolKind::Attribute => semantic_tokens::DECORATOR,
@@ -646,10 +645,7 @@ fn semantic_token_type_and_modifiers(
SymbolKind::Impl => semantic_tokens::TYPE_ALIAS,
SymbolKind::Field => semantic_tokens::PROPERTY,
SymbolKind::TypeParam => semantic_tokens::TYPE_PARAMETER,
- SymbolKind::ConstParam => {
- mods |= semantic_tokens::CONSTANT;
- semantic_tokens::CONST_PARAMETER
- }
+ SymbolKind::ConstParam => semantic_tokens::CONST_PARAMETER,
SymbolKind::LifetimeParam => semantic_tokens::LIFETIME,
SymbolKind::Label => semantic_tokens::LABEL,
SymbolKind::ValueParam => semantic_tokens::PARAMETER,
@@ -663,15 +659,8 @@ fn semantic_token_type_and_modifiers(
semantic_tokens::FUNCTION
}
}
- SymbolKind::Const => {
- mods |= semantic_tokens::CONSTANT;
- mods |= semantic_tokens::STATIC;
- semantic_tokens::VARIABLE
- }
- SymbolKind::Static => {
- mods |= semantic_tokens::STATIC;
- semantic_tokens::VARIABLE
- }
+ SymbolKind::Const => semantic_tokens::VARIABLE,
+ SymbolKind::Static => semantic_tokens::VARIABLE,
SymbolKind::Struct => semantic_tokens::STRUCT,
SymbolKind::Enum => semantic_tokens::ENUM,
SymbolKind::Variant => semantic_tokens::ENUM_MEMBER,
@@ -718,6 +707,7 @@ fn semantic_token_type_and_modifiers(
},
};
+ let mut mods = semantic_tokens::ModifierSet::default();
for modifier in highlight.mods.iter() {
let modifier = match modifier {
HlMod::Associated => continue,