-#![feature(tool_lints)]
-
-#![allow(unused, clippy::many_single_char_names)]
+#![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
#![warn(clippy::ptr_arg)]
use std::borrow::Cow;
//Nothing here
}
-fn do_vec_mut(x: &mut Vec<i64>) { // no error here
+fn do_vec_mut(x: &mut Vec<i64>) {
+ // no error here
//Nothing here
}
//Nothing here either
}
-fn do_str_mut(x: &mut String) { // no error here
+fn do_str_mut(x: &mut String) {
+ // no error here
//Nothing here either
}
-fn main() {
-}
+fn main() {}
trait Foo {
type Item;
let a = x.clone();
let b = x.clone();
let c = b.clone();
- let d = a.clone()
- .clone()
- .clone();
+ let d = a.clone().clone().clone();
x.clone()
}
}
fn false_positive_capacity_too(x: &String) -> String {
- if x.capacity() > 1024 { panic!("Too large!"); }
+ if x.capacity() > 1024 {
+ panic!("Too large!");
+ }
x.clone()
}
#[allow(dead_code)]
-fn test_cow_with_ref(c: &Cow<[i32]>) {
-}
+fn test_cow_with_ref(c: &Cow<[i32]>) {}
-#[allow(dead_code)]
fn test_cow(c: Cow<[i32]>) {
let _c = c;
}
+
+trait Foo2 {
+ fn do_string(&self);
+}
+
+// no error for &self references where self is of type String (#2293)
+impl Foo2 for String {
+ fn do_string(&self) {}
+}
+
+// Check that the allow attribute on parameters is honored
+mod issue_5644 {
+ use std::borrow::Cow;
+
+ fn allowed(
+ #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
+ #[allow(clippy::ptr_arg)] _s: &String,
+ #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
+ ) {
+ }
+
+ struct S {}
+ impl S {
+ fn allowed(
+ #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
+ #[allow(clippy::ptr_arg)] _s: &String,
+ #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
+ ) {
+ }
+ }
+
+ trait T {
+ fn allowed(
+ #[allow(clippy::ptr_arg)] _v: &Vec<u32>,
+ #[allow(clippy::ptr_arg)] _s: &String,
+ #[allow(clippy::ptr_arg)] _c: &Cow<[i32]>,
+ ) {
+ }
+ }
+}