-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
struct S;
impl std::fmt::Display for S {
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
S => write!("S"),
}
}
}Current output
error: unexpected end of macro invocation
--> src/lib.rs:5:28
|
5 | S => write!("S"),
| ^ missing tokens in macro arguments
|
note: while trying to match `,`
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/macros/mod.rs:611:15
|
611 | ($dst:expr, $($arg:tt)*) => {
| ^Desired output
For println we mention when we're missing the formatting string:
error: format argument must be a string literal
--> src/main.rs:13:14
|
13 | println!(val);
| ^^^
|
help: you might be missing a string literal to format with
|
13 | println!("{}", val);
| +++++We should do something similar for write and writeln. Potentially for macros in general (emit an error with "expected 2 comma separated arguments, only one passed" or the like).
Rust Version
Nightly channel
Build using the Nightly version: 1.95.0-nightly
(2026-02-10 9e79395f92bff6a8f536)Anything else?
Initially reported at https://users.rust-lang.org/t/implementing-the-display-trait-for-an-enum/138218
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.