You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggest enclosing {:?}/{:#?}/{} in "" when used as a format argument #155508
error: expected expression, found `:`
--> src/main.rs:7:15
|
7 | println!({:?}, UwU::QwQ)
| ^ expected expression
|
help: maybe write a path separator here
|
7 | println!({::?}, UwU::QwQ)
| +
error: format argument must be a string literal
--> src/main.rs:7:14
|
7 | println!({:?}, UwU::QwQ)
| ^^^^
|
help: you might be missing a string literal to format with
|
7 | println!("{} {}", {:?}, UwU::QwQ)
| ++++++++
error: could not compile `playground` (bin "playground") due to 2 previous errors
Desired output
error: expected expression, found `:`
--> src/main.rs:7:15
|
7 | println!({:?}, UwU::QwQ)
| ^ expected expression
|
help: maybe write a path separator here
|
7 | println!({::?}, UwU::QwQ)
| +
error: format argument must be a string literal
--> src/main.rs:7:14
|
7 | println!({:?}, UwU::QwQ)
| ^^^^
|
help: you might be missing a string literal to format with
|
7 | println!("{} {}", {:?}, UwU::QwQ)
| ++++++++
help: you might want to enclose `{:?}`in`""`|
7 | println!("{:?}", UwU::QwQ)
| ++++++
error: could not compile `playground` (bin "playground") due to 2 previous errors
Rationale and extra context
I think this is most likely what users intended when writing something like {}, {:?} or {:#?} in this context, and usually the slight difference between "{:?}" and {:?} is easy to miss at a glance, so I think this suggestion could be helpful.
Activity
cclfmht commentedon Apr 23, 2026
Hi, I think this would be very helpful and I want to work on this issue.
@rustbot claim
Rollup merge of rust-lang#155693 - cclfmht:fix/issue-155508, r=ShoyuV…
Rollup merge of rust-lang#155693 - cclfmht:fix/issue-155508, r=ShoyuV…
Rollup merge of rust-lang#155693 - cclfmht:fix/issue-155508, r=ShoyuV…
Unrolled build for #155693
Rollup merge of #155693 - cclfmht:fix/issue-155508, r=ShoyuVanilla
makai410 commentedon Jun 25, 2026
Hi! @cclfmht Thanks for working on this! I was wondering what's the current status of this issue? Can we close this?
cclfmht commentedon Jun 25, 2026
The issue has been implemented into rustc, so I think it's OK to close it.