Repository: intellij-rust/intellij-rust
Issue: Auto import doesn't show anything in own crate

## Environment

* **Intellij-Rust plugin version:** 0.2.98.2125-191
* **Rust toolchain version:** 1.35.0
* **IDE name and version:** CLION 2019.1.4
* **Operating system:** macOS 10.13.6

## Problem description
Auto-import hint doesn't show any things in the crate I created but only shows things in `std` and extern crates. I tried `Alt + Enter` but got nothing.

## Steps to reproduce


Changed files:
src/test/kotlin/org/rust/ide/inspections/import/AutoImportFixTest.kt, src/main/kotlin/org/rust/ide/inspections/import/AutoImportFix.kt

diff --git a/src/main/kotlin/org/rust/ide/inspections/import/AutoImportFix.kt b/src/main/kotlin/org/rust/ide/inspections/import/AutoImportFix.kt
index cc5ae5a8f..8f8a669ed 100644
--- a/src/main/kotlin/org/rust/ide/inspections/import/AutoImportFix.kt
+++ b/src/main/kotlin/org/rust/ide/inspections/import/AutoImportFix.kt
@@ -216,6 +216,7 @@ class AutoImportFix(element: RsElement) : LocalQuickFixOnPsiElement(element), Hi
         // but in our case `mod` is always same and `mod` needs only to get set of its super mods
         // so we pass `superMods` instead of `mod` for optimization
         private fun QualifiedNamedItem.canBeImported(superMods: LinkedHashSet<RsMod>): ImportInfo? {
+            check(superMods.isNotEmpty())
             if (item !is RsVisible) return null
 
             val ourSuperMods = this.superMods ?: return null
@@ -249,10 +250,16 @@ class AutoImportFix(element: RsElement) : LocalQuickFixOnPsiElement(element), Hi
                     needInsertExternCrateItem, depth, crateRelativePath)
                 ourSuperMods to importInfo
             } else {
+                val targetMod = superMods.first()
+                val relativePath = if (targetMod.isEdition2018) {
+                    "crate::$crateRelativePath"
+                } else {
+                    crateRelativePath
+                }
                 // if current item is direct child of some ancestor of `mod` then it can be not public
-                if (parentMod == lca) return ImportInfo.LocalImportInfo(crateRelativePath)
+                if (parentMod == lca) return ImportInfo.LocalImportInfo(relativePath)
                 if (!isPublic) return null
-                ourSuperMods.takeWhile { it != lca }.dropLast(1) to ImportInfo.LocalImportInfo(crateRelativePath)
+                ourSuperMods.takeWhile { it != lca }.dropLast(1) to ImportInfo.LocalImportInfo(relativePath)
             }
             return if (shouldBePublicMods.all { it.isPublic }) return importInfo else null
         }
@@ -486,7 +493,7 @@ fun ImportCandidate.import(context: RsElement) {
         }
     }
     val prefix = when (relativeDepth) {
-        null -> if (info is ImportInfo.LocalImportInfo && isEdition2018) "crate::" else ""
+        null -> ""
         0 -> "self::"
         else -> "super::".repeat(relativeDepth)
     }
diff --git a/src/test/kotlin/org/rust/ide/inspections/import/AutoImportFixTest.kt b/src/test/kotlin/org/rust/ide/inspections/import/AutoImportFixTest.kt
index 0f4132c07..8e16a8efc 100644
--- a/src/test/kotlin/org/rust/ide/inspections/import/AutoImportFixTest.kt
+++ b/src/test/kotlin/org/rust/ide/inspections/import/AutoImportFixTest.kt
@@ -1534,6 +1534,23 @@ class AutoImportFixTest : AutoImportFixTestBase() {
         }
     """)
 
+    @MockEdition(CargoWorkspace.Edition.EDITION_2018)
+    fun `test import item from root module (edition 2018)`() = checkAutoImportFixByText("""
+        struct Foo;
+
+        mod bar {
+            type T = <error descr="Unresolved reference: `Foo`">Foo/*caret*/</error>;
+        }
+    """, """
+        struct Foo;
+
+        mod bar {
+            use crate::Foo;
+
+            type T = Foo;
+        }
+    """)
+
     fun `test import inside nested module`() = checkAutoImportFixByText("""
         mod b {
             pub struct S;