Skip to content

String interpolation filling in value instead of compile time error #93478

Closed
@ghost

Description

I tried this code:

fn main() {
    let tup = (500, 6.4, 1);

    let (x, y, z) = tup;

    println!("The value of x, y, z is: {x}, {}, {z}");
}

I expected to see this happen: Compile time error for providing an empty parenthesis in println!("The value of x, y, z is: {x}, {}, {z}");

Instead, this happened:

The value of x, y, z is: 500, 500, 1 The value of variable x (500) was filled in for the empty parenthesis.

Meta

rustc --version --verbose:

<version>
rustc 1.58.1 (db9d1b20b 2022-01-20)                                                                                                                                                 
binary: rustc                                                                                                                                                                       
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b                                                                                                                               
commit-date: 2022-01-20                                                                                                                                                             
host: x86_64-pc-windows-msvc                                                                                                                                                        
release: 1.58.1                                                                                                                                                                     
LLVM version: 13.0.0 
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions