Skip to content

Commit

Permalink
Merge #9152
Browse files Browse the repository at this point in the history
9152: COMP: Fix redundant macro completion in mod item name r=vlad20012 a=dima74

Fixes #7780

changelog: Fix redundant macro completion in mod item name

Co-authored-by: Dmitry Murzin <diralik@yandex.ru>
  • Loading branch information
bors[bot] and dima74 committed Aug 7, 2022
2 parents 6a3e161 + 9c1cc00 commit 65fe1e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Expand Up @@ -19,6 +19,7 @@ import org.rust.lang.core.RsPsiPattern
import org.rust.lang.core.psi.RsElementTypes.COLONCOLON
import org.rust.lang.core.psi.RsElementTypes.IDENTIFIER
import org.rust.lang.core.psi.RsMacro
import org.rust.lang.core.psi.RsModItem
import org.rust.lang.core.psi.ext.*
import org.rust.lang.core.psi.unescapedText
import org.rust.lang.core.psiElement
Expand All @@ -45,6 +46,7 @@ object RsMacroCompletionProvider : RsCompletionProvider() {
val position = parameters.position
val rsElement = position.ancestorStrict<RsElement>() ?: return
val mod = rsElement.ancestorOrSelf<RsMod>()
if (mod is RsModItem && mod.identifier == position) return

val leftSiblings = position.leftSiblings
.filter { it !is PsiWhiteSpace && it !is PsiComment && it !is PsiErrorElement }
Expand Down
Expand Up @@ -642,6 +642,11 @@ class RsCompletionTest : RsCompletionTestBase() {
}
""")

fun `test macro don't suggests as mod name`() = checkNoCompletion("""
macro_rules! foo_bar { () => () }
mod foo/*caret*/ {}
""")

fun `test complete macro2`() = doSingleCompletion("""
macro foo() {}
fn main() {
Expand Down

0 comments on commit 65fe1e5

Please sign in to comment.