Skip to content

Generalize string literal inlining into format-like macros #10739

Description

@nyurik

Description

A common pattern format!("...{}...", "foo") has a number of related lints like:

we also have the uninlined_format_args which is more generic, but focuses on variables, not string literals.

I think these approaches should be combined, either as part of the uninlined_format_args, or as a new lint (and possibly sunset/remove the print/write literal?).

Mixed cases like format!("{}{}", foo, "bar") may cause issues with multiple lints trying to fix the same, so a single lint might be better, but uninlined_format_args focuses on vars, so expanding its scope might be confusing? Although technically this is also inlining an argument, so might be ok?

Version

rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-unknown-linux-gnu
release: 1.69.0
LLVM version: 15.0.7

Additional Labels

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions