]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/write_literal.txt
Auto merge of #101846 - chenyukang:fix-101793, r=davidtwco
[rust.git] / src / tools / clippy / src / docs / write_literal.txt
1 ### What it does
2 This lint warns about the use of literals as `write!`/`writeln!` args.
3
4 ### Why is this bad?
5 Using literals as `writeln!` args is inefficient
6 (c.f., https://github.com/matthiaskrgr/rust-str-bench) and unnecessary
7 (i.e., just put the literal in the format string)
8
9 ### Known problems
10 Will also warn with macro calls as arguments that expand to literals
11 -- e.g., `writeln!(buf, "{}", env!("FOO"))`.
12
13 ### Example
14 ```
15 writeln!(buf, "{}", "foo");
16 ```
17
18 Use instead:
19 ```
20 writeln!(buf, "foo");
21 ```