Closed
Description
Using the following flags
--force-warn redundant_semicolons
this code:
macro_rules! m {
($stmt:stmt) => { #[allow(bad_style)] $stmt }
}
fn main() {
m!(;);
}
caused the following diagnostics:
Checking _snippet_238 v0.1.0 (/tmp/icemaker_global_tempdir.VQhomPU3g4RT/icemaker_clippyfix_tempdir.OwDhgUUlGTjy/_snippet_238)
warning: unnecessary trailing semicolon
--> src/main.rs:2:43
|
2 | ($stmt:stmt) => { #[allow(bad_style)] $stmt }
| ^^^^^ help: remove this semicolon
...
6 | m!(;);
| ----- in this macro invocation
|
= note: requested on the command line with `--force-warn redundant-semicolons`
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: `_snippet_238` (bin "_snippet_238") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
However after applying these diagnostics, the resulting code:
macro_rules! m {
($stmt:stmt) => { #[allow(bad_style)] }
}
fn main() {
m!(;);
}
no longer compiled:
Checking _snippet_238 v0.1.0 (/tmp/icemaker_global_tempdir.VQhomPU3g4RT/icemaker_clippyfix_tempdir.OwDhgUUlGTjy/_snippet_238)
error: macro expansion ends with an incomplete expression: expected expression
--> src/main.rs:2:42
|
2 | ($stmt:stmt) => { #[allow(bad_style)] }
| ^ expected expression
error: could not compile `_snippet_238` (bin "_snippet_238") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_snippet_238` (bin "_snippet_238" test) due to 1 previous error
Version:
rustc 1.89.0-nightly (44f415c1d 2025-06-06)
binary: rustc
commit-hash: 44f415c1d617ebc7b931a243b7b321ef8a6ca47c
commit-date: 2025-06-06
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Category: This is a bug.Diagnostics: A structured suggestion resulting in incorrect code.Lint: redundant_semicolonsRelevant to the compiler team, which will review and decide on the PR/issue.