Closed
Description
fn main() {
let what = "what?";
println!("{a}{}", a=what);
}
I expected to see this happen:
error: 1 positional argument in format string, but no arguments were given
--> <source>:3:18
|
3 | println!("{a}{}", a=what);
| ^^
Instead, this happened: explanation
Standard Error
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 1.94s
Running `target/debug/playground`
Standard Output
what?what?
Meta
This happens on current 1.60.0-nightly (2022-01-27 21b4a9c), and back to rustc 1.12.01. On rustc 1.11.0, it gives
<std macros>:3:11: 3:36 error: invalid reference to argument `0` (no arguments given)
<std macros>:3 print ! ( concat ! ( $ fmt , "\n" ) , $ ( $ arg ) * ) ) ;
^~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:3:11: 3:36 note: in this expansion of concat!
<std macros>:2:27: 2:58 note: in this expansion of format_args!
<std macros>:3:1: 3:54 note: in this expansion of print! (defined in <std macros>)
<source>:3:5: 3:37 note: in this expansion of println! (defined in <std macros>)
Given how old this "support" is, I don't know if this can be classified as a bug anymore, or if it's just more of a misfeature at this point. IMHO, this should at least get a lint, or even a future-compat lint if that's considered reasonable.
Footnotes
-
So I guess this would be considered regression-from-stable-to-stable? 🙃 ↩
Metadata
Metadata
Assignees
Labels
Area: The 2024 editionArea: `core::fmt`Area: Lints (warnings about flaws in source code) such as unused_mut.Category: Future-incompatibility lintsIssue: In need of a decision.Relevant to the library API team, which will review and decide on the PR/issue.This PR / issue is in PFCP or FCP with a disposition to close it.The final comment period is finished for this PR / Issue.