Skip to content

Suggest format!("{x}") syntax when possible #8675

Closed
@digama0

Description

@digama0

What it does

Given a use of a format macro, suggest to use the format!("{x}") syntax when applicable.

Lint Name

format_args_capture

Category

pedantic

Advantage

  • Code is shorter and more readable
  • Increases awareness of the new syntax

Drawbacks

  • Increases MSRV for projects that care about that

Example

let x = 2;
println!("{}", x);
println!("{x}", x = x);
println!("{y}", y = x); // untouched because variable name doesn't match

Could be written as:

let x = 2;
println!("{x}");
println!("{x}");
println!("{y}", y = x); // untouched because variable name doesn't match

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions