Skip to content

Commit

Permalink
Merge #9990
Browse files Browse the repository at this point in the history
9990: RES: Fix resolve of custom macros with same name as in prelude r=vlad20012 a=dima74

Fixes #9915

changelog: Fix resolve of custom macros with the same name as in prelude

Co-authored-by: Dmitry Murzin <diralik@yandex.ru>
  • Loading branch information
bors[bot] and dima74 committed Jan 16, 2023
2 parents b91c5de + 37aa682 commit 3fd4380
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/kotlin/org/rust/lang/core/resolve2/FacadeResolve.kt
Expand Up @@ -137,8 +137,10 @@ private fun ModData.processMacros(
if (processor.process(name, macro)) return true
}

info.defMap.prelude?.let { prelude ->
if (prelude.processScopedMacros(processor, info)) return true
if (!isHanging) {
info.defMap.prelude?.let { prelude ->
if (prelude.processScopedMacros(processor, info)) return true
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/rust/openapiext/psi.kt
Expand Up @@ -135,9 +135,10 @@ private class RsWithMacrosRecursiveElementWalkingVisitor(
}

private fun processMacro(element: RsPossibleMacroCall, path: RsElement?) {
val expansion = element.expansion ?: return
val visitor = RsWithMacrosRecursiveElementWalkingVisitor(processor)
if (path != null) visitor.visitElement(path)

val expansion = element.expansion ?: return
for (expandedElement in expansion.elements) {
visitor.visitElement(expandedElement)
}
Expand Down
Expand Up @@ -1080,4 +1080,17 @@ class RsUnusedImportInspectionTest : RsInspectionsTestBase(RsUnusedImportInspect
}
}
""")

@ProjectDescriptor(WithStdlibRustProjectDescriptor::class)
fun `test custom column macro`() = checkByFileTree("""
//- lib.rs
#[macro_export]
macro_rules! column { () => {} }
//- main.rs
/*caret*/
use test_package::column;
fn main() {
column!();
}
""")
}

0 comments on commit 3fd4380

Please sign in to comment.