about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorblyxyas <blyxyas@gmail.com>2023-02-11 00:53:19 +0100
committerMichael Goulet <michael@errs.io>2023-02-22 21:53:16 +0000
commite39fe374df14334be3b5eb081a006fad8e4419f7 (patch)
tree231e42a28035a481a79f1271407cf3a21fcda562 /tests
parentfdbc4329cb781c7768ffa6d76c8fa2d032d3fe20 (diff)
downloadrust-e39fe374df14334be3b5eb081a006fad8e4419f7.tar.gz
rust-e39fe374df14334be3b5eb081a006fad8e4419f7.zip
Add check for invalid \`#[macro_export]\` arguments
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/attributes/invalid_macro_export_argument.rs26
-rw-r--r--tests/ui/attributes/invalid_macro_export_argument.stderr16
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/attributes/invalid_macro_export_argument.rs b/tests/ui/attributes/invalid_macro_export_argument.rs
new file mode 100644
index 00000000000..85d009f11a6
--- /dev/null
+++ b/tests/ui/attributes/invalid_macro_export_argument.rs
@@ -0,0 +1,26 @@
+// check-pass
+#[macro_export(hello, world)] //~ WARN `#[macro_export]` can only take 1 or 0 arguments
+macro_rules! a {
+    () => ()
+}
+
+#[macro_export(not_local_inner_macros)] //~ WARN `not_local_inner_macros` isn't a valid `#[macro_export]` argument
+macro_rules! b {
+    () => ()
+}
+
+#[macro_export]
+macro_rules! c {
+    () => ()
+}
+#[macro_export(local_inner_macros)]
+macro_rules! d {
+    () => ()
+}
+
+#[macro_export()]
+macro_rules! e {
+    () => ()
+}
+
+fn main() {}
diff --git a/tests/ui/attributes/invalid_macro_export_argument.stderr b/tests/ui/attributes/invalid_macro_export_argument.stderr
new file mode 100644
index 00000000000..a4e17642c2a
--- /dev/null
+++ b/tests/ui/attributes/invalid_macro_export_argument.stderr
@@ -0,0 +1,16 @@
+warning: `#[macro_export]` can only take 1 or 0 arguments
+  --> $DIR/invalid_macro_export_argument.rs:2:1
+   |
+LL | #[macro_export(hello, world)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(invalid_macro_export_arguments)]` on by default
+
+warning: `not_local_inner_macros` isn't a valid `#[macro_export]` argument
+  --> $DIR/invalid_macro_export_argument.rs:7:16
+   |
+LL | #[macro_export(not_local_inner_macros)]
+   |                ^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 2 warnings emitted
+