Skip to content

Commit 11c49a6

Browse files
committed
Fix highlighting for extern crate in doc comments
1 parent 5373014 commit 11c49a6

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs

+1
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ fn highlight_name_ref_by_syntax(
703703
};
704704

705705
match parent.kind() {
706+
EXTERN_CRATE => HlTag::Symbol(SymbolKind::Module).into(),
706707
METHOD_CALL_EXPR => ast::MethodCallExpr::cast(parent)
707708
.and_then(|it| highlight_method_call(sema, krate, &it, edition))
708709
.unwrap_or_else(|| SymbolKind::Method.into()),

src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<span class="comment documentation">//!</span><span class="comment documentation"> </span><span class="keyword injected">fn</span><span class="none injected"> </span><span class="function declaration injected">test</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span>
5151
<span class="comment documentation">//! ```</span>
5252

53+
<span class="comment documentation">//! ```rust</span>
54+
<span class="comment documentation">//!</span><span class="comment documentation"> </span><span class="keyword injected">extern</span><span class="none injected"> </span><span class="keyword injected">crate</span><span class="none injected"> </span><span class="module injected">Krate</span><span class="semicolon injected">;</span>
55+
<span class="comment documentation">//! ```</span>
5356
<span class="keyword">mod</span> <span class="module declaration">outline_module</span><span class="semicolon">;</span>
5457

5558
<span class="comment documentation">/// ```</span>

src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@ fn test_highlight_doc_comment() {
722722
//! fn test() {}
723723
//! ```
724724
725+
//! ```rust
726+
//! extern crate Krate;
727+
//! ```
725728
mod outline_module;
726729
727730
/// ```

0 commit comments

Comments
 (0)