1 #![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
2 #![warn(clippy::ptr_arg)]
5 use std::path::PathBuf;
7 fn do_vec(x: &Vec<i64>) {
11 fn do_vec_mut(x: &mut Vec<i64>) {
16 fn do_str(x: &String) {
20 fn do_str_mut(x: &mut String) {
25 fn do_path(x: &PathBuf) {
29 fn do_path_mut(x: &mut PathBuf) {
38 fn do_vec(x: &Vec<i64>);
39 fn do_item(x: &Self::Item);
44 // no error, in trait impl (#425)
47 fn do_vec(x: &Vec<i64>) {}
48 fn do_item(x: &Vec<u8>) {}
51 fn cloned(x: &Vec<u8>) -> Vec<u8> {
53 let f = e.clone(); // OK
55 let h = g.clone(); // Alas, we cannot reliably detect this without following data.
60 fn str_cloned(x: &String) -> String {
64 let d = a.clone().clone().clone();
68 fn path_cloned(x: &PathBuf) -> PathBuf {
72 let d = a.clone().clone().clone();
76 fn false_positive_capacity(x: &Vec<u8>, y: &String) {
82 fn false_positive_capacity_too(x: &String) -> String {
83 if x.capacity() > 1024 {
90 fn test_cow_with_ref(c: &Cow<[i32]>) {}
92 fn test_cow(c: Cow<[i32]>) {
100 // no error for &self references where self is of type String (#2293)
101 impl Foo2 for String {
102 fn do_string(&self) {}
105 // Check that the allow attribute on parameters is honored
107 use std::borrow::Cow;
108 use std::path::PathBuf;
111 #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
112 #[allow(clippy::ptr_arg)] _s: &String,
113 #[allow(clippy::ptr_arg)] _p: &PathBuf,
114 #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
121 #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
122 #[allow(clippy::ptr_arg)] _s: &String,
123 #[allow(clippy::ptr_arg)] _p: &PathBuf,
124 #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
131 #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
132 #[allow(clippy::ptr_arg)] _s: &String,
133 #[allow(clippy::ptr_arg)] _p: &PathBuf,
134 #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
141 use std::path::PathBuf;
143 fn foo_vec(vec: &Vec<u8>) {
144 let _ = vec.clone().pop();
145 let _ = vec.clone().clone();
148 fn foo_path(path: &PathBuf) {
149 let _ = path.clone().pop();
150 let _ = path.clone().clone();
153 fn foo_str(str: &PathBuf) {
154 let _ = str.clone().pop();
155 let _ = str.clone().clone();