]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/clone_on_copy.rs
5 clippy
::redundant_clone
,
8 clippy
::unnecessary_operation
,
9 clippy
::vec_init_then_push
,
10 clippy
::toplevel_ref_arg
13 use std
::cell
::RefCell
;
14 use std
::rc
::{self, Rc}
;
15 use std
::sync
::{self, Arc}
;
19 fn is_ascii(ch
: char) -> bool
{
26 vec
![1].clone(); // ok, not a Copy type
27 Some(vec
![1]).clone(); // ok, not a Copy type
30 let rc
= RefCell
::new(0);
34 x
.clone().rotate_left(1);
36 #[derive(Clone, Copy)]
39 fn clone(&self) -> u32 {
43 Foo
.clone(); // ok, this is not the clone trait
46 ($e
:expr
) => {{ $e }
};
50 struct Wrap([u32; 2]);
51 impl core
::ops
::Deref
for Wrap
{
52 type Target
= [u32; 2];
53 fn deref(&self) -> &[u32; 2] {
61 let ref y
= x
.clone(); // ok, binds by reference
62 let ref mut y
= x
.clone(); // ok, binds by reference
66 let _
= &x
.clone(); // ok, getting a ref
67 'a'
.clone().make_ascii_uppercase(); // ok, clone and then mutate
68 is_ascii('z'
.clone());
71 let mut vec
= Vec
::new();