Skip to content

Named format arguments introduce implicit positional arguments #93378

Closed
@Veetaha

Description

@Veetaha

I tried this code:

fn main() {
    let a = "a";
    let b = "b";
    
    println!("{a} {b} {} {} {c} {}", c = "c");
}

I expected to see a compile error that says that there are missing positional arguments or that it is prohibited to mix positional and named parameters.

Instead, this compiles and prints the following:

a b c a c b

This code is available on the playground.

Meta

rustc --version --verbose:

rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0

Metadata

Metadata

Assignees

Labels

A-fmtArea: `core::fmt`C-bugCategory: This is a bug.P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions