]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/clone_on_copy.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / clone_on_copy.rs
CommitLineData
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,
9 clippy::vec_init_then_push
10)]
11
12use std::cell::RefCell;
13use std::rc::{self, Rc};
14use std::sync::{self, Arc};
15
16fn main() {}
17
18fn is_ascii(ch: char) -> bool {
19 ch.is_ascii()
20}
21
22fn clone_on_copy() {
23 42.clone();
24
25 vec![1].clone(); // ok, not a Copy type
26 Some(vec![1]).clone(); // ok, not a Copy type
27 (&42).clone();
28
29 let rc = RefCell::new(0);
30 rc.borrow().clone();
31
32 // Issue #4348
33 let mut x = 43;
34 let _ = &x.clone(); // ok, getting a ref
35 'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
36 is_ascii('z'.clone());
37
38 // Issue #5436
39 let mut vec = Vec::new();
40 vec.push(42.clone());
41}