]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/clone_on_ref_ptr.txt
Rollup merge of #101740 - andrewpollack:add-ignore-fuchsia-ui-tests, r=tmandry
[rust.git] / src / tools / clippy / src / docs / clone_on_ref_ptr.txt
1 ### What it does
2 Checks for usage of `.clone()` on a ref-counted pointer,
3 (`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified
4 function syntax instead (e.g., `Rc::clone(foo)`).
5
6 ### Why is this bad?
7 Calling '.clone()' on an Rc, Arc, or Weak
8 can obscure the fact that only the pointer is being cloned, not the underlying
9 data.
10
11 ### Example
12 ```
13 let x = Rc::new(1);
14
15 x.clone();
16 ```
17
18 Use instead:
19 ```
20 Rc::clone(&x);
21 ```