Skip to content

Unused format arguments are hard errors #2868

@CohenArthur

Description

@CohenArthur
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
macro_rules! format_args {
    () => {};
}

fn main() {
    let s = format_args!("Heyo", 15, 14);
    let s = format_args!("Heyo", a = 15, b = 14);
}

errors out with:

error: multiple unused formatting arguments
  --> test.rs:11:34
   |
11 |     let s = format_args!("Heyo", 15, 14);
   |                          ------  ^^  ^^ argument never used
   |                          |       |
   |                          |       argument never used
   |                          multiple missing formatting specifiers

error: multiple unused formatting arguments
  --> test.rs:12:38
   |
12 |     let s = format_args!("Heyo", a = 15, b = 14);
   |                          ------      ^^      ^^ named argument never used
   |                          |           |
   |                          |           named argument never used
   |                          multiple missing formatting specifiers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions