Suggest macro import from crate root.

This commit suggests importing a macro from the root of a crate as the
intent may have been to import a macro from the definition location that
was annotated with `#[macro_export]`.
This commit is contained in:
David Wood 2019-04-07 19:56:41 +02:00
parent 126ac9ef6c
commit d84907bbcc
No known key found for this signature in database
GPG key ID: 01760B4F9F53F154
6 changed files with 134 additions and 41 deletions

View file

@ -0,0 +1,15 @@
// aux-build:issue-59764.rs
// compile-flags:--extern issue_59764
// edition:2018
// run-rustfix
use issue_59764::makro;
//~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]
makro!(bar);
//~^ ERROR cannot determine resolution for the macro `makro`
fn main() {
bar();
//~^ ERROR cannot find function `bar` in this scope [E0425]
}

View file

@ -1,6 +1,7 @@
// aux-build:issue-59764.rs
// compile-flags:--extern issue_59764
// edition:2018
// run-rustfix
use issue_59764::foo::makro;
//~^ ERROR unresolved import `issue_59764::foo::makro` [E0432]

View file

@ -1,11 +1,17 @@
error[E0432]: unresolved import `issue_59764::foo::makro`
--> $DIR/issue-59764.rs:5:5
--> $DIR/issue-59764.rs:6:5
|
LL | use issue_59764::foo::makro;
| ^^^^^^^^^^^^^^^^^^^^^^^ no `makro` in `foo`
|
= note: this could be because a macro annotated with `#[macro_export]` will be exported at the root of the crate instead of the module where it is defined
help: a macro with this name exists at the root of the crate
|
LL | use issue_59764::makro;
| ^^^^^^^^^^^^^^^^^^
error: cannot determine resolution for the macro `makro`
--> $DIR/issue-59764.rs:8:1
--> $DIR/issue-59764.rs:9:1
|
LL | makro!(bar);
| ^^^^^
@ -13,7 +19,7 @@ LL | makro!(bar);
= note: import resolution is stuck, try simplifying macro imports
error[E0425]: cannot find function `bar` in this scope
--> $DIR/issue-59764.rs:12:5
--> $DIR/issue-59764.rs:13:5
|
LL | bar();
| ^^^ not found in this scope