1 // does not test any rustfixable lints
3 #![warn(clippy::clone_on_ref_ptr)]
4 #![allow(unused, clippy::redundant_clone)]
6 use std::cell::RefCell;
7 use std::rc::{self, Rc};
8 use std::sync::{self, Arc};
12 impl SomeTrait for SomeImpl {}
16 fn is_ascii(ch: char) -> bool {
23 vec![1].clone(); // ok, not a Copy type
24 Some(vec![1]).clone(); // ok, not a Copy type
27 let rc = RefCell::new(0);
32 let _ = &x.clone(); // ok, getting a ref
33 'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
34 is_ascii('z'.clone());
37 let mut vec = Vec::new();
41 fn clone_on_ref_ptr() {
42 let rc = Rc::new(true);
43 let arc = Arc::new(true);
45 let rcweak = Rc::downgrade(&rc);
46 let arc_weak = Arc::downgrade(&arc);
55 rc::Weak::clone(&rcweak);
58 sync::Weak::clone(&arc_weak);
60 let x = Arc::new(SomeImpl);
61 let _: Arc<dyn SomeTrait> = x.clone();
64 fn clone_on_copy_generic<T: Copy>(t: T) {
70 fn clone_on_double_ref() {
73 let z: &Vec<_> = y.clone();
75 println!("{:p} {:p}", *y, z);
83 #[derive(Copy, Clone)]
86 macro_rules! impl_deref {
87 ($src:ident, $dst:ident) => {
88 impl std::ops::Deref for $src {
90 fn deref(&self) -> &Self::Target {
100 impl std::ops::Deref for D {
101 type Target = &'static E;
102 fn deref(&self) -> &Self::Target {
109 let _: E = a.clone();
113 fn check(mut encoded: &[u8]) {
114 let _ = &mut encoded.clone();
115 let _ = &encoded.clone();