]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | ||
3 | #![allow( | |
4 | unused, | |
5 | clippy::redundant_clone, | |
6 | clippy::deref_addrof, | |
7 | clippy::no_effect, | |
8 | clippy::unnecessary_operation, | |
cdc7bbd5 XL |
9 | clippy::vec_init_then_push, |
10 | clippy::toplevel_ref_arg | |
f20569fa XL |
11 | )] |
12 | ||
13 | use std::cell::RefCell; | |
14 | use std::rc::{self, Rc}; | |
15 | use std::sync::{self, Arc}; | |
16 | ||
17 | fn main() {} | |
18 | ||
19 | fn is_ascii(ch: char) -> bool { | |
20 | ch.is_ascii() | |
21 | } | |
22 | ||
23 | fn clone_on_copy() { | |
24 | 42.clone(); | |
25 | ||
26 | vec![1].clone(); // ok, not a Copy type | |
27 | Some(vec![1]).clone(); // ok, not a Copy type | |
28 | (&42).clone(); | |
29 | ||
30 | let rc = RefCell::new(0); | |
31 | rc.borrow().clone(); | |
32 | ||
cdc7bbd5 XL |
33 | let x = 0u32; |
34 | x.clone().rotate_left(1); | |
35 | ||
36 | #[derive(Clone, Copy)] | |
37 | struct Foo; | |
38 | impl Foo { | |
39 | fn clone(&self) -> u32 { | |
40 | 0 | |
41 | } | |
42 | } | |
43 | Foo.clone(); // ok, this is not the clone trait | |
44 | ||
45 | macro_rules! m { | |
46 | ($e:expr) => {{ $e }}; | |
47 | } | |
48 | m!(42).clone(); | |
49 | ||
50 | struct Wrap([u32; 2]); | |
51 | impl core::ops::Deref for Wrap { | |
52 | type Target = [u32; 2]; | |
53 | fn deref(&self) -> &[u32; 2] { | |
54 | &self.0 | |
55 | } | |
56 | } | |
57 | let x = Wrap([0, 0]); | |
58 | x.clone()[0]; | |
59 | ||
60 | let x = 42; | |
61 | let ref y = x.clone(); // ok, binds by reference | |
62 | let ref mut y = x.clone(); // ok, binds by reference | |
63 | ||
f20569fa XL |
64 | // Issue #4348 |
65 | let mut x = 43; | |
66 | let _ = &x.clone(); // ok, getting a ref | |
67 | 'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate | |
68 | is_ascii('z'.clone()); | |
69 | ||
70 | // Issue #5436 | |
71 | let mut vec = Vec::new(); | |
72 | vec.push(42.clone()); | |
73 | } |