Add test suggest-remove-semi-in-macro-expansion-issue-142143.rs

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
xizheyin 2025-06-17 22:37:24 +08:00
parent 55d436467c
commit 1ab8ff57d6
No known key found for this signature in database
GPG key ID: 0A0D90BE99CEDEAD
2 changed files with 29 additions and 0 deletions

View file

@ -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!(;);
}

View file

@ -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