]> git.lizzy.rs Git - rust.git/blob - src/docs/redundant_clone.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / redundant_clone.txt
1 ### What it does
2 Checks for a redundant `clone()` (and its relatives) which clones an owned
3 value that is going to be dropped without further use.
4
5 ### Why is this bad?
6 It is not always possible for the compiler to eliminate useless
7 allocations and deallocations generated by redundant `clone()`s.
8
9 ### Known problems
10 False-negatives: analysis performed by this lint is conservative and limited.
11
12 ### Example
13 ```
14 {
15     let x = Foo::new();
16     call(x.clone());
17     call(x.clone()); // this can just pass `x`
18 }
19
20 ["lorem", "ipsum"].join(" ").to_string();
21
22 Path::new("/a/b").join("c").to_path_buf();
23 ```