Repository: intellij-rust/intellij-rust
Issue: Cannot resolve macro in implicit extern crates

## Environment

* **Intellij-Rust plugin version: master branch (5295b4b)**

## Problem description
IntelliJ doesn't correctly resolve external crate macros when not explicitly marked in main/lib file and with a `#[macro_use]`.
At a guess, I'm assuming intellij-rust doesn't look into a crate to resolve a macro when the attr isn't there.
However, with the new uniform paths, we don't need that attr anymore, or even declare the crate itself.
So leads me to think that there is some support for not declaring the crate, but it defaults to not checking macros.
As a result, it won't resolve them.

## Steps to reproduce

Create a new project:  
`cargo new macro-expansion-test`  

Jump in and add a crate as a dependency. (Obviously, something that declares a macro)
eg: `nom = "*"`

Jump into the `main.rs` file, and add:

```rust
#[macro_use]
extern crate nom;

use nom::*;

fn main() {
}

struct Test;

named!(parse<Test>, value!(Test));
```

It should correctly resolve the macro, but if you remove the `#[macro_use]` or the attr and `extern crate`, then it'll fail to resolve.



Changed files:
src/main/kotlin/org/rust/lang/core/resolve/NameResolution.kt, src/test/kotlin/org/rust/lang/core/resolve/RsPackageLibraryResolveTest.kt

diff --git a/src/main/kotlin/org/rust/lang/core/resolve/NameResolution.kt b/src/main/kotlin/org/rust/lang/core/resolve/NameResolution.kt
index ce490e69a..3a82dd701 100644
--- a/src/main/kotlin/org/rust/lang/core/resolve/NameResolution.kt
+++ b/src/main/kotlin/org/rust/lang/core/resolve/NameResolution.kt
@@ -869,15 +869,16 @@ private fun collect2segmentPaths(rootSpeck: RsUseSpeck): List<TwoSegmentPath> {
     val result = mutableListOf<TwoSegmentPath>()
 
     fun go(speck: RsUseSpeck) {
+        val starImport = speck.isStarImport
         val path = speck.path
-        val qualifier = path?.qualifier
+        val qualifier = path?.qualifier ?: speck.qualifier
         val group = speck.useGroup
         if (path != null && qualifier != null && qualifier.qualifier != null) return
         val firstSegment = qualifier ?: path
         val lastSegment = path ?: qualifier
         when {
-            group == null && firstSegment != null && (path != null || speck.isStarImport) -> {
-                result += TwoSegmentPath(firstSegment.referenceName, path?.referenceName)
+            group == null && firstSegment != null && (path != null || starImport) -> {
+                result += TwoSegmentPath(firstSegment.referenceName, if (starImport) null else path?.referenceName)
             }
             group != null && firstSegment == lastSegment -> {
                 group.useSpeckList.forEach { go(it) }
diff --git a/src/test/kotlin/org/rust/lang/core/resolve/RsPackageLibraryResolveTest.kt b/src/test/kotlin/org/rust/lang/core/resolve/RsPackageLibraryResolveTest.kt
index 4e6091682..a3abd7d1b 100644
--- a/src/test/kotlin/org/rust/lang/core/resolve/RsPackageLibraryResolveTest.kt
+++ b/src/test/kotlin/org/rust/lang/core/resolve/RsPackageLibraryResolveTest.kt
@@ -203,6 +203,20 @@ class RsPackageLibraryResolveTest : RsResolveTestBase() {
         }
     """, NameResolutionTestmarks.missingMacroUse)
 
+    fun `test import macro by use item wildcard`() = stubOnlyResolve("""
+    //- lib.rs
+        extern crate dep_lib_target;
+        use dep_lib_target::*;
+        fn bar() {
+            foo!();
+        } //^ dep-lib/lib.rs
+    //- dep-lib/lib.rs
+        #[macro_export]
+        macro_rules! foo {
+            () => {};
+        }
+    """, NameResolutionTestmarks.missingMacroUse)
+
     fun `test import macro by use item without extern crate`() = stubOnlyResolve("""
     //- lib.rs
         use dep_lib_target::foo;
@@ -216,6 +230,19 @@ class RsPackageLibraryResolveTest : RsResolveTestBase() {
         }
     """)
 
+    fun `test import macro by use item wildcard without extern crate`() = stubOnlyResolve("""
+    //- lib.rs
+        use dep_lib_target::*;
+        fn bar() {
+            foo!();
+        } //^ dep-lib/lib.rs
+    //- dep-lib/lib.rs
+        #[macro_export]
+        macro_rules! foo {
+            () => {};
+        }
+    """)
+
     fun `test import macro by complex use item without extern crate`() = stubOnlyResolve("""
     //- lib.rs
         use {{dep_lib_target::{{foo}}}};
@@ -229,6 +256,19 @@ class RsPackageLibraryResolveTest : RsResolveTestBase() {
         }
     """)
 
+    fun `test import macro by complex use item wildcard without extern crate`() = stubOnlyResolve("""
+    //- lib.rs
+        use {{dep_lib_target::{{*}}}};
+        fn bar() {
+            foo!();
+        } //^ dep-lib/lib.rs
+    //- dep-lib/lib.rs
+        #[macro_export]
+        macro_rules! foo {
+            () => {};
+        }
+    """)
+
     fun `test local definition wins over imported by use item`() = stubOnlyResolve("""
     //- lib.rs
         use dep_lib_target::foo;