Skip to content

not all c style formatting specifiers are detected #89173

Closed
@lcnr

Description

@lcnr

i've tried

fn main() {
    let num = 0x0abcde;
    let width = 6;
    print!("%0*x", width, num);
}

i expected:

error: multiple unused formatting arguments
 --> src/main.rs:4:19
  |
4 |     print!("%0*x", width, num);
  |            -----  ^^^^^  ^^^ argument never used
  |            ||     |
  |            ||     argument never used
  |            |help: format specifiers use curly braces: `{1:00$x}`
  |            multiple missing formatting specifiers
  |
  = note: printf formatting not supported; see the documentation for `std::fmt`

the actual error message does not contain such a help message:

error: multiple unused formatting arguments
 --> src/main.rs:4:20
  |
4 |     print!("%0*x", width, num);
  |            ------  ^^^^^  ^^^ argument never used
  |            |       |
  |            |       argument never used
  |            multiple missing formatting specifiers

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`P-lowLow priorityT-compilerRelevant to the compiler 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