Repository: intellij-rust/intellij-rust
Issue: Changing variable name during indexing leads to IndexNotReadyException

## Environment

* **IntelliJ Rust plugin version:** 0.3.142.3661-211-nightly
* **Rust toolchain version:** 1.52.0-nightly (e9920ef77 2021-02-11) x86_64-pc-windows-msvc
* **IDE name and version:** CLion 2021.1 EAP (CL-211.5787.12)
* **Operating system:** Windows 10 10.0
* **Macro expansion engine:** new
* **Name resolution engine:** new

## Problem description

```
com.intellij.openapi.project.IndexNotReadyException: Please change caller according to com.intellij.openapi.project.IndexNotReadyException documentation
	at com.intellij.openapi.project.IndexNotReadyException.create(IndexNotReadyException.java:67)
	at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:758)
	at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:710)
	at com.intellij.psi.stubs.StubIndexImpl.getContainingIds(StubIndexImpl.java:487)
	at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:302)
	at com.intellij.psi.stubs.StubIndex.processElements(StubIndex.java:49)
	at org.rust.lang.core.stubs.index.RsModulesIndex$Companion$getDeclarationsFor$1.invoke(RsModulesIndex.kt:43)
	at org.rust.lang.core.stubs.index.RsModulesIndex$Companion.getDeclarationsFor(RsModulesIndex.kt:52)
	at org.rust.lang.core.psi.RsFile$declarations$1.compute(RsFile.kt:233)
	at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
	at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
	at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
	at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
	at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42)
	at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
	at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
	at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
	at org.rust.lang.core.psi.RsFile.getDeclarations(RsFile.kt:232)
	at org.rust.lang.core.psi.RsFile.getDeclaration(RsFile.kt:217)
	at org.rust.lang.core.psi.RsFile.doGetCachedData(RsFile.kt:117)
	at org.rust.lang.core.psi.RsFile.access$doGetCachedData(RsFile.kt:72)
	at org.rust.lang.core.psi.RsFile$cachedData$1$value$1.compute(RsFile.kt:97)
	at org.rust.lang.core.psi.RsFile$cachedData$1$value$1.compute(RsFile.kt:72)
	at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
	at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42)
	at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
	at org.rust.openapiext.UtilsKt.recursionGuard(utils.kt:68)
	at org.rust.openapiext.UtilsKt.recursionGuard$default(utils.kt:67)
	at org.rust.lang.core.psi.RsFile$cachedData$1.compute(RsFile.kt:97)
	at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
	at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
	at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
	at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
	at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42)
	at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
	at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
	at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
	at org.rust.lang.core.psi.RsFile.getCachedData(RsFile.kt:96)
	at org.rust.lang.core.psi.RsFile.getCrate(RsFile.kt:80)
	at org.rust.lang.core.psi.ext.RsElementKt.getContainingCrate(RsElement.kt:63)
	at org.rust.lang.core.psi.ext.RsDocAndAttributeOwnerKt.evaluateCfg(RsDocAndAttributeOwner.kt:326)
	at org.rust.lang.core.psi.ext.RsDocAndAttributeOwnerKt.evaluateCfg$default(RsDocAndAttributeOwner.kt:318)
	at org.rust.lang.core.psi.ext.RsDocAndAttributeOwnerKt.isEnabledByCfgSelf(RsDocAndAttributeOwner.kt:304)
	at org.rust.lang.core.psi.ext.RsItemsOwnerKt.processItem(RsItemsOwner.kt:146)
	at org.rust.lang.core.psi.ext.RsItemsOwnerKt.processExpandedItemsInternal(RsItemsOwner.kt:142)
	at org.rust.lang.core.psi.ext.RsItemsOwnerKt.access$processExpandedItemsInternal(RsItemsOwner.kt:1)
	at org.rust.lang.core.psi.ext.RsItemsOwnerKt$expandedItemsCached$1.compute(RsItemsOwner.kt:65)
	at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
	at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
	at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
	at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
	at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42)
	at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
	at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
	at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
	at org.rust.lang.core.psi.ext.RsItemsOwnerKt.getExpandedItemsCached(RsItemsOwner.kt:60)
	at org.rust.lang.core.resolve.ItemResolutionKt.processItemDeclarations(ItemResolution.kt:87)
	at org.rust.lang.core.resolve.NameResolutionKt.processLexicalDeclarations(NameResolution.kt:1522)
	at org.rust.lang.core.resolve.NameResolutionKt.access$processLexicalDeclarations(NameResolution.kt:1)
	at org.rust.lang.core.resolve.NameResolutionKt$processNestedScopesUpwards$stop$2.invoke(NameResolution.kt:1578)
	at org.rust.lang.core.resolve.NameResolutionKt$processNestedScopesUpwards$stop$2.invoke(NameResolution.kt)
	at org.rust.lang.core.resolve.NameResolutionKt.walkUp(NameResolution.kt:1708)
	at org.rust.lang.core.resolve.NameResolutionKt.walkUp$default(NameResolution.kt:1701)
	at org.rust.lang.core.resolve.NameResolutionKt.processNestedScopesUpwards(NameResolution.kt:1571)
	at org.rust.lang.core.resolve.NameResolutionKt.processNestedScopesUpwards(NameResolution.kt:1557)
	at org.rust.lang.core.resolve.NameResolutionKt.processPatBindingResolveVariants(NameResolution.kt:685)
	at org.rust.lang.core.resolve.ref.RsPatBindingReferenceImpl$resolveInner$1.invoke(RsPatBindingReferenceImpl.kt:23)
	at org.rust.lang.core.resolve.ref.RsPatBindingReferenceImpl$resolveInner$1.invoke(RsPatBindingReferenceImpl.kt:18)
	at org.rust.lang.core.resolve.ProcessorsKt.collectResolveVariants(Processors.kt:120)
	at org.rust.lang.core.resolve.ref.RsPatBindingReferenceImpl.resolveInner(RsPatBindingReferenceImpl.kt:23)
	at org.rust.lang.core.resolve.ref.RsReferenceCached$Resolver.invoke(RsReferenceCached.kt:34)
	at org.rust.lang.core.resolve.ref.RsReferenceCached$Resolver.invoke(RsReferenceCached.kt:32)
	at org.rust.lang.core.resolve.ref.RsResolveCache$resolveWithCaching$$inlined$run$lambda$1.compute(RsResolveCache.kt:100)
	at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
	at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:42)
	at org.rust.lang.core.resolve.ref.RsResolveCache.resolveWithCaching(RsResolveCache.kt:100)
	at org.rust.lang.core.resolve.ref.RsReferenceCached.cachedMultiResolve(RsReferenceCached.kt:27)
	at org.rust.lang.core.resolve.ref.RsReferenceCached.multiResolve(RsReferenceCached.kt:20)
	at com.intellij.psi.PsiPolyVariantReferenceBase.resolve(PsiPolyVariantReferenceBase.java:47)
	at org.rust.lang.core.resolve.ref.RsReferenceBase.resolve(RsReferenceBase.kt:28)
	at org.rust.lang.core.psi.ext.RsPatBindingKt.isReferenceToConstant(RsPatBinding.kt:51)
	at org.rust.ide.refactoring.suggested.RsSuggestedRefactoringSupport.isDeclaration(RsSuggestedRefactoringSupport.kt:30)
	at com.intellij.refactoring.suggested.SuggestedRefactoringSupportKt.declarationByOffset(SuggestedRefactoringSupport.kt:208)
	at com.intellij.refactoring.suggested.SuggestedRefactoringChangeListener$processBeforeFirstChangeWithPsiAndDocumentInSync$2.invoke(SuggestedRefactoringChangeListener.kt:112)
	at com.intellij.refactoring.suggested.SuggestedRefactoringChangeListener.processBeforeFirstChangeWithPsiAndDocumentInSync(SuggestedRefactoringChangeListener.kt:119)
	at com.intellij.refactoring.suggested.SuggestedRefactoringChangeListener.access$processBeforeFirstChangeWithPsiAndDocumentInSync(SuggestedRefactoringChangeListener.kt:22)
	at com.intellij.refactoring.suggested.SuggestedRefactoringChangeListener$MyDocumentListener.beforeDocumentChange(SuggestedRefactoringChangeListener.kt:210)
	at jdk.internal.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.intellij.util.EventDispatcher.dispatchVoidMethod(EventDispatcher.java:123)
	at com.intellij.util.EventDispatcher.lambda$createMulticaster$1(EventDispatcher.java:86)
	at com.sun.proxy.$Proxy81.beforeDocumentChange(Unknown Source)
	at com.intellij.openapi.editor.impl.DocumentImpl.beforeChangedUpdate(DocumentImpl.java:877)
	at com.intellij.openapi.editor.impl.DocumentImpl.updateText(DocumentImpl.java:815)
	at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:660)
	at com.intellij.openapi.editor.impl.DocumentImpl.replaceText(DocumentImpl.java:527)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl$3.run(FileDocumentManagerImpl.java:701)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:960)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$reloadFromDisk$6(FileDocumentManagerImpl.java:687)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:215)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:162)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.reloadFromDisk(FileDocumentManagerImpl.java:687)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.contentsChanged(FileDocumentManagerImpl.java:667)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl$MyAsyncFileListener$1.afterVfsChange(FileDocumentManagerImpl.java:608)
	at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.afterVfsChange(AsyncEventSupport.java:139)
	at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.processEventsFromRefresh(AsyncEventSupport.java:159)
	at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEventsInWriteAction(RefreshSessionImpl.java:227)
	at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.lambda$fireEvents$1(RefreshSessionImpl.java:205)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runEdtProgressWriteAction$11(ApplicationImpl.java:924)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.util.PotemkinProgress.runInSwingThread(PotemkinProgress.java:197)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runEdtProgressWriteAction$12(ApplicationImpl.java:924)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:948)
	at com.intellij.openapi.application.impl.ApplicationImpl.runEdtProgressWriteAction(ApplicationImpl.java:922)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithNonCancellableProgressInDispatchThread(ApplicationImpl.java:903)
	at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.lambda$fireEvents$2(RefreshSessionImpl.java:199)
	at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:105)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:948)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:974)
	at com.intellij.openapi.application.WriteAction.run(WriteAction.java:104)
	at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEvents(RefreshSessionImpl.java:198)
	at com.intellij.openapi.vfs.newvfs.RefreshQueueImpl.lambda$runAsyncListeners$8(RefreshQueueImpl.java:154)
	at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$safeTransferToEdt$6(NonBlockingReadActionImpl.java:577)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:218)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:200)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:782)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:319)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:972)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:838)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:448)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:447)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:782)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:495)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
```

## Steps to reproduce

Try to rename any local variable while indexing

Changed files:
src/test/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringTest.kt
src/test/kotlin/org/rust/ide/actions/mover/RsCommaListElementUpDownMoverTest.kt
src/main/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringSupport.kt
src/test/kotlin/org/rust/ide/refactoring/suggested/RsRenameSuggestedRefactoringTest.kt

diff --git a/src/main/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringSupport.kt b/src/main/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringSupport.kt
index cdd2aa05a..634eb0964 100644
--- a/src/main/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringSupport.kt
+++ b/src/main/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringSupport.kt
@@ -16,7 +16,7 @@ import org.rust.lang.core.psi.ext.isReferenceToConstant
 
 class RsSuggestedRefactoringSupport : SuggestedRefactoringSupport {
     override val availability: SuggestedRefactoringAvailability
-        get() = SuggestedRefactoringAvailability.RenameOnly(this)
+        get() = RsSuggestedRefactoringAvailability(this)
     override val execution: SuggestedRefactoringExecution
         get() = SuggestedRefactoringExecution.RenameOnly(this)
     override val stateChanges: SuggestedRefactoringStateChanges
@@ -27,7 +27,10 @@ class RsSuggestedRefactoringSupport : SuggestedRefactoringSupport {
     override fun importsRange(psiFile: PsiFile): TextRange? = null
 
     override fun isDeclaration(psiElement: PsiElement): Boolean = when (psiElement) {
-        is RsPatBinding -> psiElement.parent is RsPatIdent && !psiElement.isReferenceToConstant
+        // May return true for const pat binding since we can't distinguish them
+        // without name resolution that forbidden here.
+        // Refactoring for constants is suppressed by `RsSuggestedRefactoringAvailability`
+        is RsPatBinding -> psiElement.parent is RsPatIdent
         is RsNameIdentifierOwner -> true
         else -> false
     }
@@ -41,3 +44,14 @@ class RsSuggestedRefactoringSupport : SuggestedRefactoringSupport {
     private fun getRange(declaration: PsiElement): TextRange? =
         (declaration as? RsNameIdentifierOwner)?.nameIdentifier?.textRange
 }
+
+private class RsSuggestedRefactoringAvailability(
+    refactoringSupport: SuggestedRefactoringSupport
+) : SuggestedRefactoringAvailability.RenameOnly(refactoringSupport) {
+
+    override fun shouldSuppressRefactoringForDeclaration(state: SuggestedRefactoringState): Boolean {
+        if (state.declaration !is RsPatBinding) return false
+        val restoredDeclaration = state.restoredDeclarationCopy() as? RsPatBinding ?: return false
+        return restoredDeclaration.isReferenceToConstant
+    }
+}
diff --git a/src/test/kotlin/org/rust/ide/actions/mover/RsCommaListElementUpDownMoverTest.kt b/src/test/kotlin/org/rust/ide/actions/mover/RsCommaListElementUpDownMoverTest.kt
index 2a41b4860..d0924fc29 100644
--- a/src/test/kotlin/org/rust/ide/actions/mover/RsCommaListElementUpDownMoverTest.kt
+++ b/src/test/kotlin/org/rust/ide/actions/mover/RsCommaListElementUpDownMoverTest.kt
@@ -5,15 +5,6 @@
 
 package org.rust.ide.actions.mover
 
-import org.rust.UseOldResolve
-
-// These test may implicitly invoke `RsSuggestedRefactoringSupport.isDeclaration` during indexing.
-// `RsSuggestedRefactoringSupport.isDeclaration` may invoke name resolution and in combination with new name resolution engine
-// (which loads stubs itself) lead to "Outdated stub in index" error
-//
-// So force using old name resolution engine here for now.
-// Annotation should be removed when https://github.com/intellij-rust/intellij-rust/issues/6833 will be fixed
-@UseOldResolve
 class RsCommaListElementUpDownMoverTest : RsStatementUpDownMoverTestBase() {
     fun `test function parameter`() = moveDownAndBackUp("""
         fn foo(
diff --git a/src/test/kotlin/org/rust/ide/refactoring/suggested/RsRenameSuggestedRefactoringTest.kt b/src/test/kotlin/org/rust/ide/refactoring/suggested/RsRenameSuggestedRefactoringTest.kt
index 44cdbc05e..d4c80fe14 100644
--- a/src/test/kotlin/org/rust/ide/refactoring/suggested/RsRenameSuggestedRefactoringTest.kt
+++ b/src/test/kotlin/org/rust/ide/refactoring/suggested/RsRenameSuggestedRefactoringTest.kt
@@ -56,9 +56,21 @@ class RsRenameSuggestedRefactoringTest : RsSuggestedRefactoringTestBase() {
             let b = a;
         }
     """) {
-            myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DELETE)
-            myFixture.type("5")
+        myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DELETE)
+        myFixture.type("5")
+    }
+
+    fun `test do not rename constant`() = doUnavailableTest("""
+        const C: i32 = 1;
+        fn foo() {
+            match 1 {
+                C/*caret*/ => println!("Oops"),
+                X => println!("{}", X)
+            };
         }
+    """) {
+        myFixture.type("1")
+    }
 
     fun `test rename nested binding`() = doTestRename("""
         fn foo() {
diff --git a/src/test/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringTest.kt b/src/test/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringTest.kt
index 330d5f10d..2c898d7bc 100644
--- a/src/test/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringTest.kt
+++ b/src/test/kotlin/org/rust/ide/refactoring/suggested/RsSuggestedRefactoringTest.kt
@@ -11,11 +11,12 @@ import com.intellij.openapi.command.executeCommand
 import com.intellij.psi.PsiDocumentManager
 import com.intellij.psi.impl.source.PostprocessReformattingAspect
 import com.intellij.refactoring.RefactoringBundle
+import org.intellij.lang.annotations.Language
 import org.rust.RsTestBase
 
 abstract class RsSuggestedRefactoringTestBase : RsTestBase() {
     protected fun doUnavailableTest(
-        initialText: String,
+        @Language("Rust") initialText: String,
         editingAction: () -> Unit
     ) {
         InlineFile(initialText).withCaret()
@@ -28,8 +29,8 @@ abstract class RsSuggestedRefactoringTestBase : RsTestBase() {
     }
 
     protected fun doTestRename(
-        initialText: String,
-        textAfterRefactoring: String,
+        @Language("Rust") initialText: String,
+        @Language("Rust") textAfterRefactoring: String,
         oldName: String,
         newName: String,
         editingAction: () -> Unit