Description
Summary
When I write code expanding dynamically changed template string, I encountered literal_string_with_formatting_args
.
I think calling replace("{var}", &var)
is likely to be intended to not treat as format string in rust.
Lint Name
literal_string_with_formatting_args
Reproducer
I tried this code:
fn lint_test(templete: &str) -> String {
let version = env!("CARGO_PKG_VERSION");
templete.replace("{version}", version)
}
I saw this happen:
warning: this looks like a formatting argument but it is not part of a formatting macro
--> vrc-get-gui/src/main.rs:3:23
|
3 | templete.replace("{version}", version)
| ^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#literal_string_with_formatting_args
= note: `#[warn(clippy::literal_string_with_formatting_args)]` on by default
I expected to see this happen:
No lint for this code.
Version
rustc 1.85.0-beta.1 (e30eefff4 2025-01-08)
binary: rustc
commit-hash: e30eefff41038ceea427009023627d6d66b36715
commit-date: 2025-01-08
host: aarch64-apple-darwin
release: 1.85.0-beta.1
LLVM version: 19.1.6
Additional Labels
the commit message and description of PR adds literal_string_with_formatting_args
says literal_string_with_formatting_args
is pedantic
so it might be it's a bug that literal_string_with_formatting_args
is categorized as suspicious
;
According to the edit history of the PR description, it's originally categorized as suspicious
and changed to pedantic
later, but code has not changed (or rebase miss in some point).
When I searched on github, I can see the thousands of similar false positive cases are exists.