summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/redundant_clone.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/redundant_clone.txt')
-rw-r--r--src/tools/clippy/src/docs/redundant_clone.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/redundant_clone.txt b/src/tools/clippy/src/docs/redundant_clone.txt
new file mode 100644
index 000000000..b29aed0b5
--- /dev/null
+++ b/src/tools/clippy/src/docs/redundant_clone.txt
@@ -0,0 +1,23 @@
+### What it does
+Checks for a redundant `clone()` (and its relatives) which clones an owned
+value that is going to be dropped without further use.
+
+### Why is this bad?
+It is not always possible for the compiler to eliminate useless
+allocations and deallocations generated by redundant `clone()`s.
+
+### Known problems
+False-negatives: analysis performed by this lint is conservative and limited.
+
+### Example
+```
+{
+ let x = Foo::new();
+ call(x.clone());
+ call(x.clone()); // this can just pass `x`
+}
+
+["lorem", "ipsum"].join(" ").to_string();
+
+Path::new("/a/b").join("c").to_path_buf();
+``` \ No newline at end of file