Repository: intellij-rust/intellij-rust
Issue: Exception on typing while file indexing

<!--
Hello and thank you for the issue!
If you would like to report a bug, we have added some points below that you can fill out.
Feel free to remove all the irrelevant text to request a new feature.
-->

## Environment

* **Intellij-Rust plugin version:** 0.2.94.2580-191-nightly
* **Rust toolchain version:** nightly-x86_64-apple-darwin
* **Rustc version:** 1.34.0-nightly (aadbc459b 2019-02-23)
* **IDE name and version:** CLion 2019.1 Beta (191.6183.6)
* **Operating system:** macOS Mojave 10.14.3 (18D109)

## Problem description

### stacktrace.txt
```
Error while indexing /Users/misha/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.7.1/src/deadlock.rs
To reindex this file IDEA has to be restarted

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:77)
	at com.intellij.util.indexing.FileBasedIndexImpl.handleDumbMode(FileBasedIndexImpl.java:777)
	at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:726)
	at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:709)
	at com.intellij.psi.stubs.StubIndexImpl.doProcessStubs(StubIndexImpl.java:305)
	at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:281)
	at com.intellij.psi.stubs.StubIndex.processElements(StubIndex.java:65)
	at org.rust.lang.core.stubs.index.RsModulesIndex$Companion.getDeclarationFor(RsModulesIndex.kt:33)
	at org.rust.lang.core.psi.RsFile$declaration$1.compute(RsFile.kt:102)
	at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:148)
	at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
	at com.intellij.util.CachedValueBase.lambda$getValueWithLock$0(CachedValueBase.java:236)
	at com.intellij.openapi.util.RecursionManager$1.doPreventingRecursion(RecursionManager.java:116)
	at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:237)
	at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValueFromExHolder(CachedValuesManagerImpl.java:72)
	at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:45)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:147)
	at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:129)
	at org.rust.lang.core.psi.RsFile.getDeclaration(RsFile.kt:100)
	at org.rust.lang.core.psi.RsFile.getSuper(RsFile.kt:51)
	at org.rust.lang.core.psi.ext.RsModKt$superMods$1.invoke(RsMod.kt:76)
	at org.rust.lang.core.psi.ext.RsModKt$superMods$1.invoke(RsMod.kt)
	at kotlin.sequences.GeneratorSequence$iterator$1.calcNext(Sequences.kt:546)
	at kotlin.sequences.GeneratorSequence$iterator$1.hasNext(Sequences.kt:564)
	at kotlin.sequences.TakeWhileSequence$iterator$1.calcNext(Sequences.kt:396)
	at kotlin.sequences.TakeWhileSequence$iterator$1.hasNext(Sequences.kt:423)
	at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:691)
	at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:721)
	at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:712)
	at org.rust.lang.core.psi.ext.RsModKt.getSuperMods(RsMod.kt:78)
	at org.rust.lang.core.psi.RsFile.getCrateRoot(RsFile.kt:38)
	at org.rust.lang.core.psi.ext.RsStubbedElementImpl.getCrateRoot(RsElement.kt:128)
	at org.rust.lang.core.psi.ext.RsStubbedElementImpl.getCrateRoot(RsElement.kt:128)
	at org.rust.lang.core.psi.ext.RsStubbedElementImpl.getCrateRoot(RsElement.kt:128)
	at org.rust.lang.core.psi.ext.RsStubbedElementImpl.getCrateRoot(RsElement.kt:128)
	at org.rust.lang.core.resolve.NameResolutionKt.processPathResolveVariants(NameResolution.kt:436)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImplKt$resolvePath$result$1.invoke(RsPathReferenceImpl.kt:69)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImplKt$resolvePath$result$1.invoke(RsPathReferenceImpl.kt)
	at org.rust.lang.core.resolve.ProcessorsKt.collectPathResolveVariants(Processors.kt:64)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImplKt.resolvePath(RsPathReferenceImpl.kt:68)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImplKt.resolvePath$default(RsPathReferenceImpl.kt:67)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImpl$Resolver.invoke(RsPathReferenceImpl.kt:62)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImpl$Resolver.invoke(RsPathReferenceImpl.kt:60)
	at org.rust.lang.core.resolve.ref.RsResolveCache$resolveWithCaching$$inlined$run$lambda$1.compute(RsResolveCache.kt:89)
	at com.intellij.openapi.util.RecursionManager$1.doPreventingRecursion(RecursionManager.java:116)
	at org.rust.lang.core.resolve.ref.RsResolveCache.resolveWithCaching(RsResolveCache.kt:89)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImpl.advancedCachedMultiResolve(RsPathReferenceImpl.kt:53)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImpl.advancedMultiResolve(RsPathReferenceImpl.kt:42)
	at org.rust.lang.core.resolve.ref.RsPathReferenceImpl.multiResolve(RsPathReferenceImpl.kt:45)
	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.RsVisibilityKt.getVisibility(RsVisibility.kt:76)
	at org.rust.lang.core.psi.ext.RsVisibilityOwner.getVisibility(RsVisibility.kt:21)
	at org.rust.lang.core.psi.ext.RsVisibilityKt.isPublic(RsVisibility.kt:24)
	at org.rust.lang.core.stubs.index.RsReexportIndex$Companion.index(RsReexportIndex.kt:51)
	at org.rust.lang.core.stubs.StubIndexingKt.indexUseSpeck(StubIndexing.kt:83)
	at org.rust.lang.core.stubs.RsUseSpeckStub$Type.indexStub(StubImplementations.kt:258)
	at org.rust.lang.core.stubs.RsUseSpeckStub$Type.indexStub(StubImplementations.kt:240)
	at com.intellij.psi.stubs.ObjectStubTree.indexStubTree(ObjectStubTree.java:69)
	at com.intellij.psi.stubs.StubUpdatingIndex.calcStubIndicesValueMap(StubUpdatingIndex.java:408)
	at com.intellij.psi.stubs.StubUpdatingIndex.access$300(StubUpdatingIndex.java:54)
	at com.intellij.psi.stubs.StubUpdatingIndex$3.lambda$map$0(StubUpdatingIndex.java:277)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:940)
	at com.intellij.psi.stubs.StubUpdatingIndex$3.map(StubUpdatingIndex.java:220)
	at com.intellij.psi.stubs.StubUpdatingIndex$3.map(StubUpdatingIndex.java:202)
	at com.intellij.util.indexing.impl.MapReduceIndex.mapInput(MapReduceIndex.java:264)
	at com.intellij.util.indexing.VfsAwareMapReduceIndex.calculateUpdateData(VfsAwareMapReduceIndex.java:83)
	at com.intellij.util.indexing.impl.MapReduceIndex.update(MapReduceIndex.java:212)
	at com.intellij.util.indexing.FileBasedIndexImpl.updateSingleIndex(FileBasedIndexImpl.java:1673)
	at com.intellij.util.indexing.FileBasedIndexImpl.lambda$doIndexFileContent$27(FileBasedIndexImpl.java:1601)
	at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.freezeFileTypeTemporarilyIn(FileTypeManagerImpl.java:522)
	at com.intellij.util.indexing.FileBasedIndexImpl.doIndexFileContent(FileBasedIndexImpl.java:1560)
	at com.intellij.util.indexing.FileBasedIndexImpl.indexFileContent(FileBasedIndexImpl.java:1547)
	at com.intellij.util.indexing.UnindexedFilesUpdater.lambda$indexFiles$0(UnindexedFilesUpdater.java:109)
	at com.intellij.openapi.project.CacheUpdateRunner$MyRunnable.lambda$run$0(CacheUpdateRunner.java:216)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1166)
	at com.intellij.openapi.project.CacheUpdateRunner$MyRunnable.lambda$run$1(CacheUpdateRunner.java:232)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:586)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:86)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
	at com.intellij.openapi.project.CacheUpdateRunner$MyRunnable.run(CacheUpdateRunner.java:229)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:311)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
```

### indexingStart.trace
```
java.lang.Throwable
	at com.intellij.openapi.project.DumbServiceImpl.queueAsynchronousTask(DumbServiceImpl.java:271)
	at com.intellij.openapi.project.DumbServiceImpl.queueTask(DumbServiceImpl.java:247)
	at com.intellij.openapi.roots.impl.ProjectRootManagerComponent.doSynchronizeRoots(ProjectRootManagerComponent.java:279)
	at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.fireRootsChanged(ProjectRootManagerImpl.java:388)
	at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.access$200(ProjectRootManagerImpl.java:35)
	at com.intellij.openapi.roots.impl.ProjectRootManagerImpl$BatchSession.rootsChanged(ProjectRootManagerImpl.java:93)
	at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:297)
	at org.rust.cargo.project.model.impl.CargoProjectImplKt$setupProjectRoots$1$$special$$inlined$runWriteAction$1.compute(actions.kt:75)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runWriteAction$19(ApplicationImpl.java:1064)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:1020)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1064)
	at org.rust.cargo.project.model.impl.CargoProjectImplKt$setupProjectRoots$1.run(CargoProjectImpl.kt:502)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
	at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:156)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:723)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:672)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:367)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
```

## Steps to reproduce

Open the [project](https://github.com/blackbeam/mysql_async) and start typing in the [file](https://github.com/blackbeam/mysql_async/blob/master/src/conn/mod.rs) before indexing is finished.


Changed files:
src/main/kotlin/org/rust/lang/core/stubs/index/RsReexportIndex.kt

diff --git a/src/main/kotlin/org/rust/lang/core/stubs/index/RsReexportIndex.kt b/src/main/kotlin/org/rust/lang/core/stubs/index/RsReexportIndex.kt
index 601ac3977..d1717c21e 100644
--- a/src/main/kotlin/org/rust/lang/core/stubs/index/RsReexportIndex.kt
+++ b/src/main/kotlin/org/rust/lang/core/stubs/index/RsReexportIndex.kt
@@ -13,7 +13,6 @@ import com.intellij.psi.stubs.StubIndexKey
 import org.rust.lang.core.psi.RsUseItem
 import org.rust.lang.core.psi.RsUseSpeck
 import org.rust.lang.core.psi.ext.ancestorStrict
-import org.rust.lang.core.psi.ext.isPublic
 import org.rust.lang.core.psi.ext.nameInScope
 import org.rust.lang.core.psi.ext.pathOrQualifier
 import org.rust.lang.core.stubs.RsFileStub
@@ -30,7 +29,7 @@ class RsReexportIndex : StringStubIndexExtension<RsUseSpeck>() {
 
         fun index(stub: RsUseSpeckStub, sink: IndexSink) {
             val useSpeck = stub.psi
-            val isPublic = useSpeck.ancestorStrict<RsUseItem>()?.isPublic == true
+            val isPublic = useSpeck.ancestorStrict<RsUseItem>()?.vis != null
             if (!isPublic) return
             val name = if (stub.isStarImport) {
                 useSpeck.pathOrQualifier?.referenceName