about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-06-17 22:37:24 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-06-17 22:37:24 +0800
commit1ab8ff57d6fe41af9f22c75cbf41d07130bb3d60 (patch)
treeca6708350df3f4d6920dd93675cc246b0f350f88
parent55d436467c351b56253deeba209ae2553d1c243f (diff)
downloadrust-1ab8ff57d6fe41af9f22c75cbf41d07130bb3d60.tar.gz
rust-1ab8ff57d6fe41af9f22c75cbf41d07130bb3d60.zip
Add test suggest-remove-semi-in-macro-expansion-issue-142143.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
-rw-r--r--tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.rs11
-rw-r--r--tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.stderr18
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.rs b/tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.rs
new file mode 100644
index 00000000000..4360eb964a4
--- /dev/null
+++ b/tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.rs
@@ -0,0 +1,11 @@
+// Make sure we don't suggest remove redundant semicolon inside macro expansion.(issue #142143)
+
+#![deny(redundant_semicolons)]
+
+macro_rules! m {
+    ($stmt:stmt) => { #[allow(bad_style)] $stmt } //~ ERROR unnecessary trailing semicolon [redundant_semicolons]
+}
+
+fn main() {
+    m!(;);
+}
diff --git a/tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.stderr b/tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.stderr
new file mode 100644
index 00000000000..909c9f84d0b
--- /dev/null
+++ b/tests/ui/lint/redundant-semicolon/suggest-remove-semi-in-macro-expansion-issue-142143.stderr
@@ -0,0 +1,18 @@
+error: unnecessary trailing semicolon
+  --> $DIR/suggest-remove-semi-in-macro-expansion-issue-142143.rs:6:43
+   |
+LL |     ($stmt:stmt) => { #[allow(bad_style)] $stmt }
+   |                                           ^^^^^ help: remove this semicolon
+...
+LL |     m!(;);
+   |     ----- in this macro invocation
+   |
+note: the lint level is defined here
+  --> $DIR/suggest-remove-semi-in-macro-expansion-issue-142143.rs:3:9
+   |
+LL | #![deny(redundant_semicolons)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 1 previous error
+