Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add foreign formatting directive detection. #37613

Merged
merged 1 commit into from
Nov 12, 2016

Commits on Nov 11, 2016

  1. Add foreign formatting directive detection.

    This teaches `format_args!` how to interpret format printf- and
    shell-style format directives.  This is used in cases where there are
    unused formatting arguments, and the reason for that *might* be because
    the programmer is trying to use the wrong kind of formatting string.
    
    This was prompted by an issue encountered by simulacrum on the #rust IRC
    channel.  In short: although `println!` told them that they weren't using
    all of the conversion arguments, the problem was in using printf-syle
    directives rather than ones `println!` would undertand.
    
    Where possible, `format_args!` will tell the programmer what they should
    use instead.  For example, it will suggest replacing `%05d` with `{:0>5}`,
    or `%2$.*3$s` with `{1:.3$}`.  Even if it cannot suggest a replacement,
    it will explicitly note that Rust does not support that style of directive,
    and direct the user to the `std::fmt` documentation.
    DanielKeep committed Nov 11, 2016
    Configuration menu
    Copy the full SHA
    455723c View commit details
    Browse the repository at this point in the history