summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/useless_format.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/useless_format.txt')
-rw-r--r--src/tools/clippy/src/docs/useless_format.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/useless_format.txt b/src/tools/clippy/src/docs/useless_format.txt
new file mode 100644
index 000000000..eb4819da1
--- /dev/null
+++ b/src/tools/clippy/src/docs/useless_format.txt
@@ -0,0 +1,22 @@
+### What it does
+Checks for the use of `format!("string literal with no
+argument")` and `format!("{}", foo)` where `foo` is a string.
+
+### Why is this bad?
+There is no point of doing that. `format!("foo")` can
+be replaced by `"foo".to_owned()` if you really need a `String`. The even
+worse `&format!("foo")` is often encountered in the wild. `format!("{}",
+foo)` can be replaced by `foo.clone()` if `foo: String` or `foo.to_owned()`
+if `foo: &str`.
+
+### Examples
+```
+let foo = "foo";
+format!("{}", foo);
+```
+
+Use instead:
+```
+let foo = "foo";
+foo.to_owned();
+``` \ No newline at end of file