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

new uninlined_format_args lint to inline explicit arguments #9233

Merged
merged 1 commit into from
Sep 26, 2022

Commits on Sep 25, 2022

  1. new uninlined_format_args lint to inline explicit arguments

    Implement rust-lang#8368 - a new
    lint to inline format arguments such as `print!("{}", var)` into
    `print!("{var}")`.
    
    code | suggestion | comment
    ---|---|---
    `print!("{}", var)` | `print!("{var}")` |  simple variables
    `print!("{0}", var)` | `print!("{var}")` |  positional variables
    `print!("{v}", v=var)` | `print!("{var}")` |  named variables
    `print!("{0} {0}", var)` | `print!("{var} {var}")` |  aliased variables
    `print!("{0:1$}", var, width)` | `print!("{var:width$}")` |  width
    support
    `print!("{0:.1$}", var, prec)` | `print!("{var:.prec$}")` |  precision
    support
    `print!("{:.*}", prec, var)` | `print!("{var:.prec$}")` |  asterisk
    support
    
    code | suggestion | comment
    ---|---|---
    `print!("{0}={1}", var, 1+2)` | `print!("{var}={0}", 1+2)` | Format
    string uses an indexed argument that cannot be inlined.  Supporting this
    case requires re-indexing of the format string.
    
    changelog: [`uninlined_format_args`]: A new lint to inline format
    arguments, i.e. `print!("{}", var)` into `print!("{var}")`
    nyurik committed Sep 25, 2022
    Configuration menu
    Copy the full SHA
    5a71bbd View commit details
    Browse the repository at this point in the history