Skip to content

Commit 22160c4

Browse files
committed
fix NameRefClass misclassifying proc-macros
1 parent 9eed85b commit 22160c4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">Fn</span><span class="angle">&lt;</span><span class="type_param declaration">Args</span><span class="angle">&gt;</span><span class="colon">:</span> <span class="trait public">FnMut</span><span class="angle">&lt;</span><span class="type_param">Args</span><span class="angle">&gt;</span> <span class="brace">{</span><span class="brace">}</span>
5757
<span class="brace">}</span>
5858

59-
<span class="module crate_root library">proc_macros</span><span class="operator">::</span><span class="function library">mirror</span><span class="macro_bang">!</span> <span class="brace">{</span>
59+
<span class="module crate_root library">proc_macros</span><span class="operator">::</span><span class="macro library">mirror</span><span class="macro_bang">!</span> <span class="brace">{</span>
6060
<span class="brace">{</span>
6161
<span class="comma">,</span><span class="builtin_type">i32</span> <span class="colon">:</span><span class="field declaration public">x</span> <span class="keyword">pub</span>
6262
<span class="comma">,</span><span class="builtin_type">i32</span> <span class="colon">:</span><span class="field declaration public">y</span> <span class="keyword">pub</span>

crates/ide_db/src/defs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ impl NameRefClass {
416416
}
417417

418418
if let Some(path) = ast::PathSegment::cast(parent.clone()).map(|it| it.parent_path()) {
419-
if path.qualifier().is_none() {
419+
if path.parent_path().is_none() {
420420
if let Some(macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) {
421-
// Only use this to resolve single-segment macro calls like `foo!()`. Multi-segment
422-
// paths are handled below (allowing `log$0::info!` to resolve to the log crate).
421+
// Only use this to resolve to macro calls for last segments as qualifiers resolve
422+
// to modules below.
423423
if let Some(macro_def) = sema.resolve_macro_call(&macro_call) {
424424
return Some(NameRefClass::Definition(Definition::Macro(macro_def)));
425425
}

0 commit comments

Comments
 (0)