Skip to content

clippy::useless_format does not parse escaped braces correctly (as in format!("{{}}")) #3920

Closed
@zgtm

Description

@zgtm

When a format string is used to output braces, they need to be escaped by doubling them:format!("{{}}") creates a string containing "{}".

The clippy lint clippy::useless_format seems to not know that:

warning: useless use of `format!`

format!("{{}}")
^^^^^^^^^^^^^^^ help: consider using .to_string(): `"{{}}".to_string()`

Here, the recommendation should read "{}".to_string() instead.

Further information:

cargo clippy -V
clippy 0.0.212 (1b89724 2019-01-15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions