about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-10-25 18:43:37 +0900
committerGitHub <noreply@github.com>2020-10-25 18:43:37 +0900
commit569d29d55c240eea3ff35d0a16572c2b81dd40bf (patch)
treef62e6c36ea47b873ea3028796bb96bf4e20d59dd /src/test
parent3e0dd24a6c0812eedbb02182a75c352f8a7e184a (diff)
parent283053a742277f9b949facdfc5f4996f503f3c4e (diff)
Rollup merge of #77984 - Aaron1011:fix/macro-mod-weird-parent, r=petrochenkov
Compute proper module parent during resolution

Fixes #75982

The direct parent of a module may not be a module
(e.g. `const _: () =  { #[path = "foo.rs"] mod foo; };`).

To find the parent of a module for purposes of resolution, we need to
walk up the tree until we hit a module or a crate root.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/macros/auxiliary/issue-75982.rs12
-rw-r--r--src/test/ui/macros/issue-75982-foreign-macro-weird-mod.rs13
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/macros/auxiliary/issue-75982.rs b/src/test/ui/macros/auxiliary/issue-75982.rs
new file mode 100644
index 00000000000..1e1a6126a10
--- /dev/null
+++ b/src/test/ui/macros/auxiliary/issue-75982.rs
@@ -0,0 +1,12 @@
+const _: () = {
+    #[macro_export]
+    macro_rules! first_macro {
+        () => {}
+    }
+    mod foo {
+        #[macro_export]
+        macro_rules! second_macro {
+            () => {}
+        }
+    }
+};
diff --git a/src/test/ui/macros/issue-75982-foreign-macro-weird-mod.rs b/src/test/ui/macros/issue-75982-foreign-macro-weird-mod.rs
new file mode 100644
index 00000000000..e76b09d4bb9
--- /dev/null
+++ b/src/test/ui/macros/issue-75982-foreign-macro-weird-mod.rs
@@ -0,0 +1,13 @@
+// aux-build:issue-75982.rs
+// check-pass
+
+// Regression test for issue #75982
+// Tests that don't ICE when invoking a foreign macro
+// that occurs inside a module with a weird parent.
+
+extern crate issue_75982;
+
+fn main() {
+    issue_75982::first_macro!();
+    issue_75982::second_macro!();
+}