diff options
Diffstat (limited to 'src/tools/clippy/src/docs/write_literal.txt')
-rw-r--r-- | src/tools/clippy/src/docs/write_literal.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/write_literal.txt b/src/tools/clippy/src/docs/write_literal.txt new file mode 100644 index 000000000..9c41a48f9 --- /dev/null +++ b/src/tools/clippy/src/docs/write_literal.txt @@ -0,0 +1,21 @@ +### What it does +This lint warns about the use of literals as `write!`/`writeln!` args. + +### Why is this bad? +Using literals as `writeln!` args is inefficient +(c.f., https://github.com/matthiaskrgr/rust-str-bench) and unnecessary +(i.e., just put the literal in the format string) + +### Known problems +Will also warn with macro calls as arguments that expand to literals +-- e.g., `writeln!(buf, "{}", env!("FOO"))`. + +### Example +``` +writeln!(buf, "{}", "foo"); +``` + +Use instead: +``` +writeln!(buf, "foo"); +```
\ No newline at end of file |