From 126ac9ef6c11ced54ba9191aba916dd7d5206159 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 7 Apr 2019 17:56:50 +0200 Subject: [PATCH] Add test with current behaviour. This commit adds a test demonstrating the current behaviour when a macro defined in a module with the `#[macro_export]` is imported from the module rather than the crate root. --- src/test/ui/auxiliary/issue-59764.rs | 8 ++++++++ src/test/ui/issue-59764.rs | 14 ++++++++++++++ src/test/ui/issue-59764.stderr | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/test/ui/auxiliary/issue-59764.rs create mode 100644 src/test/ui/issue-59764.rs create mode 100644 src/test/ui/issue-59764.stderr diff --git a/src/test/ui/auxiliary/issue-59764.rs b/src/test/ui/auxiliary/issue-59764.rs new file mode 100644 index 000000000000..0243ef5c6c74 --- /dev/null +++ b/src/test/ui/auxiliary/issue-59764.rs @@ -0,0 +1,8 @@ +pub mod foo { + #[macro_export] + macro_rules! makro { + ($foo:ident) => { + fn $foo() { } + } + } +} diff --git a/src/test/ui/issue-59764.rs b/src/test/ui/issue-59764.rs new file mode 100644 index 000000000000..8ac9b9eaba18 --- /dev/null +++ b/src/test/ui/issue-59764.rs @@ -0,0 +1,14 @@ +// aux-build:issue-59764.rs +// compile-flags:--extern issue_59764 +// edition:2018 + +use issue_59764::foo::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] +} diff --git a/src/test/ui/issue-59764.stderr b/src/test/ui/issue-59764.stderr new file mode 100644 index 000000000000..a428488b009e --- /dev/null +++ b/src/test/ui/issue-59764.stderr @@ -0,0 +1,24 @@ +error[E0432]: unresolved import `issue_59764::foo::makro` + --> $DIR/issue-59764.rs:5:5 + | +LL | use issue_59764::foo::makro; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `makro` in `foo` + +error: cannot determine resolution for the macro `makro` + --> $DIR/issue-59764.rs:8:1 + | +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 + | +LL | bar(); + | ^^^ not found in this scope + +error: aborting due to 3 previous errors + +Some errors occurred: E0425, E0432. +For more information about an error, try `rustc --explain E0425`.