Skip to content

Commit 55ee7ec

Browse files
Merge pull request #21116 from xdBronch/push-okwnouotntqt
add deprecated semantic token for extern crate shorthand
2 parents 9328757 + c03bc5b commit 55ee7ec

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

crates/ide/src/syntax_highlighting/highlight.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ fn highlight_name_ref(
413413
if is_from_builtin_crate {
414414
h |= HlMod::DefaultLibrary;
415415
}
416+
let is_deprecated = resolved_krate.attrs(sema.db).by_key(sym::deprecated).exists();
417+
if is_deprecated {
418+
h |= HlMod::Deprecated;
419+
}
416420
h |= HlMod::CrateRoot;
417421
h
418422
}

crates/ide/src/syntax_highlighting/test_data/highlight_deprecated.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
</style>
4444
<pre><code><span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">!</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">deprecated</span><span class="attribute_bracket attribute">]</span>
4545
<span class="keyword">use</span> <span class="keyword crate_root deprecated public">crate</span> <span class="keyword">as</span> <span class="punctuation">_</span><span class="semicolon">;</span>
46+
<span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module crate_root deprecated library">bar</span><span class="semicolon">;</span>
4647
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">deprecated</span><span class="attribute_bracket attribute">]</span>
4748
<span class="keyword">macro_rules</span><span class="macro_bang">!</span> <span class="macro declaration deprecated public">macro_</span> <span class="brace">{</span>
4849
<span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="operator">=</span><span class="operator">&gt;</span> <span class="brace">{</span><span class="brace">}</span><span class="semicolon">;</span>
@@ -68,4 +69,5 @@
6869
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">deprecated</span><span class="attribute_bracket attribute">]</span>
6970
<span class="keyword">type</span> <span class="type_alias declaration deprecated">Alias</span> <span class="operator">=</span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
7071
<span class="attribute_bracket attribute">#</span><span class="attribute_bracket attribute">[</span><span class="builtin_attr attribute">deprecated</span><span class="attribute_bracket attribute">]</span>
71-
<span class="keyword">static</span> <span class="static declaration deprecated">STATIC</span><span class="colon">:</span> <span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="operator">=</span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span></code></pre>
72+
<span class="keyword">static</span> <span class="static declaration deprecated">STATIC</span><span class="colon">:</span> <span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="operator">=</span> <span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
73+
</code></pre>

crates/ide/src/syntax_highlighting/tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,10 @@ fn main() {
15161516
fn test_deprecated_highlighting() {
15171517
check_highlighting(
15181518
r#"
1519+
//- /foo.rs crate:foo deps:bar
15191520
#![deprecated]
15201521
use crate as _;
1522+
extern crate bar;
15211523
#[deprecated]
15221524
macro_rules! macro_ {
15231525
() => {};
@@ -1544,6 +1546,8 @@ trait Trait {}
15441546
type Alias = ();
15451547
#[deprecated]
15461548
static STATIC: () = ();
1549+
//- /bar.rs crate:bar
1550+
#![deprecated]
15471551
"#,
15481552
expect_file!["./test_data/highlight_deprecated.html"],
15491553
false,

0 commit comments

Comments
 (0)