about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorDaniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>2020-10-14 21:12:03 +0200
committerDaniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>2021-01-06 15:13:38 +0100
commitd3a33eb1f9803da21460b675f2452b2784d9f63b (patch)
tree747ea96975d539aae6c64351768595e17c4e725c /src/test
parent7d03870882aa05fc4c600afa3585251f54d299c4 (diff)
Fix type/value namespace clashes + test for that
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc/auxiliary/macro_pub_in_module.rs13
-rw-r--r--src/test/rustdoc/macro_pub_in_module.rs36
2 files changed, 47 insertions, 2 deletions
diff --git a/src/test/rustdoc/auxiliary/macro_pub_in_module.rs b/src/test/rustdoc/auxiliary/macro_pub_in_module.rs
new file mode 100644
index 00000000000..fa987689ec6
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/macro_pub_in_module.rs
@@ -0,0 +1,13 @@
+// edition:2018
+
+#![feature(decl_macro)]
+#![crate_name = "external_crate"]
+
+pub mod some_module {
+    /* == Make sure the logic is not affected by a re-export == */
+    mod private {
+        pub macro external_macro() {}
+    }
+    // @has external_crate/some_module/macro.external_macro.html
+    pub use private::external_macro;
+}
diff --git a/src/test/rustdoc/macro_pub_in_module.rs b/src/test/rustdoc/macro_pub_in_module.rs
index 035d2a8c441..7d92246279f 100644
--- a/src/test/rustdoc/macro_pub_in_module.rs
+++ b/src/test/rustdoc/macro_pub_in_module.rs
@@ -1,11 +1,18 @@
+// aux-build:macro_pub_in_module.rs
+// edition:2018
+// build-aux-docs
+// @has external_crate/some_module/macro.external_macro.html
+
 //! See issue #74355
 #![feature(decl_macro, no_core, rustc_attrs)]
 #![crate_name = "krate"]
 #![no_core]
 
+extern crate external_crate;
+
 pub mod inner {
-    // @has krate/inner/macro.my_macro.html
-    pub macro my_macro() {}
+    // @has krate/inner/macro.raw_const.html
+    pub macro raw_const() {}
 
     // @has krate/inner/macro.test.html
     #[rustc_builtin_macro]
@@ -14,4 +21,29 @@ pub mod inner {
     // @has krate/inner/macro.Clone.html
     #[rustc_builtin_macro]
     pub macro Clone($item:item) {}
+
+    // Make sure the logic is not affected by a re-export.
+    mod private {
+        pub macro m() {}
+    }
+    // @has krate/inner/macro.renamed.html
+    pub use private::m as renamed;
+
+    // @has krate/inner/macro.external_macro.html
+    pub use ::external_crate::some_module::external_macro;
+}
+
+// Namespaces: Make sure the logic does not mix up a function name with a module name…
+fn both_fn_and_mod() {
+    pub macro m() {}
+}
+pub mod both_fn_and_mod {
+    // @!has krate/both_fn_and_mod/macro.m.html
+}
+
+const __: () = {
+    pub macro m() {}
+};
+pub mod __ {
+    // @!has krate/__/macro.m.html
 }