3 clippy::many_single_char_names,
4 clippy::redundant_clone,
7 #![warn(clippy::ptr_arg)]
10 use std::path::PathBuf;
12 fn do_vec(x: &Vec<i64>) {
16 fn do_vec_mut(x: &mut Vec<i64>) {
21 fn do_str(x: &String) {
25 fn do_str_mut(x: &mut String) {
30 fn do_path(x: &PathBuf) {
34 fn do_path_mut(x: &mut PathBuf) {
43 fn do_vec(x: &Vec<i64>);
44 fn do_item(x: &Self::Item);
49 // no error, in trait impl (#425)
52 fn do_vec(x: &Vec<i64>) {}
53 fn do_item(x: &Vec<u8>) {}
56 fn cloned(x: &Vec<u8>) -> Vec<u8> {
58 let f = e.clone(); // OK
60 let h = g.clone(); // Alas, we cannot reliably detect this without following data.
65 fn str_cloned(x: &String) -> String {
69 let d = a.clone().clone().clone();
73 fn path_cloned(x: &PathBuf) -> PathBuf {
77 let d = a.clone().clone().clone();
81 fn false_positive_capacity(x: &Vec<u8>, y: &String) {
87 fn false_positive_capacity_too(x: &String) -> String {
88 if x.capacity() > 1024 {
95 fn test_cow_with_ref(c: &Cow<[i32]>) {}
97 fn test_cow(c: Cow<[i32]>) {
105 // no error for &self references where self is of type String (#2293)
106 impl Foo2 for String {
107 fn do_string(&self) {}
110 // Check that the allow attribute on parameters is honored
112 use std::borrow::Cow;
113 use std::path::PathBuf;
116 #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
117 #[allow(clippy::ptr_arg)] _s: &String,
118 #[allow(clippy::ptr_arg)] _p: &PathBuf,
119 #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
126 #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
127 #[allow(clippy::ptr_arg)] _s: &String,
128 #[allow(clippy::ptr_arg)] _p: &PathBuf,
129 #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
136 #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
137 #[allow(clippy::ptr_arg)] _s: &String,
138 #[allow(clippy::ptr_arg)] _p: &PathBuf,
139 #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
146 use std::path::PathBuf;
148 fn foo_vec(vec: &Vec<u8>) {
149 let _ = vec.clone().pop();
150 let _ = vec.clone().clone();
153 fn foo_path(path: &PathBuf) {
154 let _ = path.clone().pop();
155 let _ = path.clone().clone();
158 fn foo_str(str: &PathBuf) {
159 let _ = str.clone().pop();
160 let _ = str.clone().clone();