]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/needless_borrow.rs
3 #[warn(clippy::all, clippy::needless_borrow)]
4 #[allow(unused_variables, clippy::unnecessary_mut_passed)]
8 let _
= x(&a
); // no warning
9 let _
= x(&&a
); // warn
12 mut_ref(&mut b
); // no warning
13 mut_ref(&mut &mut b
); // warn
15 let s
= &String
::from("hi");
16 let s_ident
= f(&s
); // should not error, because `&String` implements Copy, but `String` does not
17 let g_val
= g(&Vec
::new()); // should not error, because `&Vec<T>` derefs to `&[T]`
19 let vec_val
= g(&vec
); // should not error, because `&Vec<T>` derefs to `&[T]`
20 h(&"foo"); // should not error, because the `&&str` is required, due to `&Trait`
21 let garbl
= match 42 {
50 #[allow(clippy::needless_borrowed_reference)]
51 fn x(y
: &i32) -> i32 {
55 fn mut_ref(y
: &mut i32) {
59 fn f
<T
: Copy
>(y
: &T
) -> T
{
63 fn g(y
: &[u8]) -> u8 {
69 impl<'a
> Trait
for &'a
str {}
71 fn h(_
: &dyn Trait
) {}