diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 43594ccaf73a..33df4a8a13d8 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -413,6 +413,10 @@ fn highlight_name_ref( if is_from_builtin_crate { h |= HlMod::DefaultLibrary; } + let is_deprecated = resolved_krate.attrs(sema.db).by_key(sym::deprecated).exists(); + if is_deprecated { + h |= HlMod::Deprecated; + } h |= HlMod::CrateRoot; h } diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html b/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html index 1bf127c01bfc..41d3dff8ed9e 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html @@ -43,6 +43,7 @@
#![deprecated]
 use crate as _;
+extern crate bar;
 #[deprecated]
 macro_rules! macro_ {
     () => {};
@@ -68,4 +69,5 @@
 #[deprecated]
 type Alias = ();
 #[deprecated]
-static STATIC: () = ();
\ No newline at end of file +static STATIC: () = (); + \ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 59e7a66f6ebc..b7510e3abaea 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -1516,8 +1516,10 @@ fn main() { fn test_deprecated_highlighting() { check_highlighting( r#" +//- /foo.rs crate:foo deps:bar #![deprecated] use crate as _; +extern crate bar; #[deprecated] macro_rules! macro_ { () => {}; @@ -1544,6 +1546,8 @@ trait Trait {} type Alias = (); #[deprecated] static STATIC: () = (); +//- /bar.rs crate:bar +#![deprecated] "#, expect_file!["./test_data/highlight_deprecated.html"], false,