-#![allow(
- unused,
- clippy::many_single_char_names,
- clippy::redundant_clone,
- clippy::if_then_panic
-)]
+#![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
#![warn(clippy::ptr_arg)]
use std::borrow::Cow;
}
fn do_vec_mut(x: &mut Vec<i64>) {
- // no error here
//Nothing here
}
}
fn do_str_mut(x: &mut String) {
- // no error here
//Nothing here either
}
}
fn do_path_mut(x: &mut PathBuf) {
- // no error here
//Nothing here either
}
let e = x.clone();
let f = e.clone(); // OK
let g = x;
- let h = g.clone(); // Alas, we cannot reliably detect this without following data.
+ let h = g.clone();
let i = (e).clone();
x.clone()
}
let _ = str.clone().clone();
}
}
+
+fn mut_vec_slice_methods(v: &mut Vec<u32>) {
+ v.copy_within(1..5, 10);
+}
+
+fn mut_vec_vec_methods(v: &mut Vec<u32>) {
+ v.clear();
+}
+
+fn vec_contains(v: &Vec<u32>) -> bool {
+ [vec![], vec![0]].as_slice().contains(v)
+}
+
+fn fn_requires_vec(v: &Vec<u32>) -> bool {
+ vec_contains(v)
+}
+
+fn impl_fn_requires_vec(v: &Vec<u32>, f: impl Fn(&Vec<u32>)) {
+ f(v);
+}
+
+fn dyn_fn_requires_vec(v: &Vec<u32>, f: &dyn Fn(&Vec<u32>)) {
+ f(v);
+}
+
+// No error for types behind an alias (#7699)
+type A = Vec<u8>;
+fn aliased(a: &A) {}
+
+// Issue #8366
+pub trait Trait {
+ fn f(v: &mut Vec<i32>);
+ fn f2(v: &mut Vec<i32>) {}
+}