about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-15 12:02:05 +0900
committerGitHub <noreply@github.com>2022-06-15 12:02:05 +0900
commitb2d0e7838e2af58b9abeab10dcb954e39fa634b5 (patch)
tree0ea12520a01d8e23f5ee8120d697edfbaa4fbf4d /src
parent97b9347c93726e6f27b7d45d1d3bda62d6cff2b4 (diff)
parentd29915af79f4a372647b67e7d83f1fc4aabbb92a (diff)
Rollup merge of #98087 - TaKO8Ki:suggest-adding-macro-export, r=oli-obk
Suggest adding a `#[macro_export]` to a private macro

fixes #97628
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/privacy/macro-private-reexport.rs17
-rw-r--r--src/test/ui/privacy/macro-private-reexport.stderr29
-rw-r--r--src/test/ui/rust-2018/uniform-paths/macro-rules.stderr8
3 files changed, 50 insertions, 4 deletions
diff --git a/src/test/ui/privacy/macro-private-reexport.rs b/src/test/ui/privacy/macro-private-reexport.rs
new file mode 100644
index 00000000000..d0aab528ed4
--- /dev/null
+++ b/src/test/ui/privacy/macro-private-reexport.rs
@@ -0,0 +1,17 @@
+// edition:2021
+
+#![feature(decl_macro)]
+
+mod foo {
+    macro_rules! bar {
+        () => {};
+    }
+
+    pub use bar as _; //~ ERROR `bar` is only public within the crate, and cannot be re-exported outside
+
+    macro baz() {}
+
+    pub use baz as _; //~ ERROR `baz` is private, and cannot be re-exported
+}
+
+fn main() {}
diff --git a/src/test/ui/privacy/macro-private-reexport.stderr b/src/test/ui/privacy/macro-private-reexport.stderr
new file mode 100644
index 00000000000..b8768f3612e
--- /dev/null
+++ b/src/test/ui/privacy/macro-private-reexport.stderr
@@ -0,0 +1,29 @@
+error[E0364]: `bar` is only public within the crate, and cannot be re-exported outside
+  --> $DIR/macro-private-reexport.rs:10:13
+   |
+LL |     pub use bar as _;
+   |             ^^^^^^^^
+   |
+help: consider adding a `#[macro_export]` to the macro in the imported module
+  --> $DIR/macro-private-reexport.rs:6:5
+   |
+LL | /     macro_rules! bar {
+LL | |         () => {};
+LL | |     }
+   | |_____^
+
+error[E0364]: `baz` is private, and cannot be re-exported
+  --> $DIR/macro-private-reexport.rs:14:13
+   |
+LL |     pub use baz as _;
+   |             ^^^^^^^^
+   |
+note: consider marking `baz` as `pub` in the imported module
+  --> $DIR/macro-private-reexport.rs:14:13
+   |
+LL |     pub use baz as _;
+   |             ^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0364`.
diff --git a/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr b/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr
index 9e48e26b1df..9f8c928c32c 100644
--- a/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr
+++ b/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr
@@ -4,11 +4,11 @@ error[E0364]: `legacy_macro` is only public within the crate, and cannot be re-e
 LL |     pub use legacy_macro as _;
    |             ^^^^^^^^^^^^^^^^^
    |
-note: consider marking `legacy_macro` as `pub` in the imported module
-  --> $DIR/macro-rules.rs:11:13
+help: consider adding a `#[macro_export]` to the macro in the imported module
+  --> $DIR/macro-rules.rs:7:5
    |
-LL |     pub use legacy_macro as _;
-   |             ^^^^^^^^^^^^^^^^^
+LL |     macro_rules! legacy_macro { () => () }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0659]: `legacy_macro` is ambiguous
   --> $DIR/macro-rules.rs:31:13