]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/clone_on_copy.rs
Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup
[rust.git] / src / tools / clippy / tests / ui / clone_on_copy.rs
1 // run-rustfix
2
3 #![allow(
4     unused,
5     clippy::redundant_clone,
6     clippy::deref_addrof,
7     clippy::no_effect,
8     clippy::unnecessary_operation
9 )]
10
11 use std::cell::RefCell;
12 use std::rc::{self, Rc};
13 use std::sync::{self, Arc};
14
15 fn main() {}
16
17 fn is_ascii(ch: char) -> bool {
18     ch.is_ascii()
19 }
20
21 fn clone_on_copy() {
22     42.clone();
23
24     vec![1].clone(); // ok, not a Copy type
25     Some(vec![1]).clone(); // ok, not a Copy type
26     (&42).clone();
27
28     let rc = RefCell::new(0);
29     rc.borrow().clone();
30
31     // Issue #4348
32     let mut x = 43;
33     let _ = &x.clone(); // ok, getting a ref
34     'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
35     is_ascii('z'.clone());
36
37     // Issue #5436
38     let mut vec = Vec::new();
39     vec.push(42.clone());
40 }