Unexpected semicolon_in_expressions_from_macros warning
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
cro_rules! log {
($level: ident, $($t:tt)*) => {
#[cfg(feature = "log")]
{ log::$level!($($t)*) }
// Silence unused variables warnings.
#[cfg(not(feature = "log"))]
{ if false { let _ = ( $($t)* ); } }
}
}
Current output
error: trailing semicolon in macro used in expression position
--> src/macros.rs:93:11
|
93 | { log::$level!($($t)*) }
| ^^^^^^^^^^^^^^^^^^^^
|
::: src/poll.rs:580:9
|
580 | / trace!(
581 | | "registering event source with poller: token={:?}, interests={:?}",
582 | | token,
583 | | interests
584 | | );
| |_________- in this macro invocation
|
= note: macro invocations at the end of a block are treated as expressions
= note: to ignore the value produced by the macro, add a semicolon after the invocation of `trace`
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: `#[deny(semicolon_in_expressions_from_macros)]` (part of `#[deny(future_incompatible)]`) on by default
= note: this error originates in the macro `log::trace` which comes from the expansion of the macro `trace` (in Nightly builds, run with -Z macro-backtrace for more info)
Desired output
I wouldn't expect an error here.
Rationale and extra context
Relevant code is https://github.com/tokio-rs/mio at commit 4b055e560301477e11a140e06beaf90f5d01cb78.
- Macro definiton: https://github.com/tokio-rs/mio/blob/4b055e560301477e11a140e06beaf90f5d01cb78/src/macros.rs#L90-L98
- Usage: https://github.com/tokio-rs/mio/blob/4b055e560301477e11a140e06beaf90f5d01cb78/src/poll.rs#L580-L584
Other cases
Rust Version
rustc 1.98.0-nightly (ce9954c0c 2026-06-26)
binary: rustc
commit-hash: ce9954c0cfc4bf26b82aef16e6fd8b020c237992
commit-date: 2026-06-26
host: aarch64-apple-darwin
release: 1.98.0-nightly
LLVM version: 22.1.8
Anything else?
PR to fix/silence the warning: https://github.com/tokio-rs/mio/pull/1975.
Original comment: https://github.com/rust-lang/rust/issues/79813#issuecomment-4991879370.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic with the macro in mio's src/macros.rs and its invocation in src/poll.rs at commit 4b055e560301477e11a140e06beaf90f5d01cb78. Read rust-lang/rust issue #79813 and compare mio PR #1975 to understand the semicolon_in_expressions_from_macros behavior. Done means the provided case no longer produces the unexpected error, with regression coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100