11// check-pass
22
33#![ allow( unused) ]
4- #![ warn( noop_method_call) ]
4+ #![ warn( noop_method_call, clone_double_ref ) ]
55
66use std:: borrow:: Borrow ;
77use std:: ops:: Deref ;
@@ -15,6 +15,7 @@ fn main() {
1515 let non_clone_type_ref = & PlainType ( 1u32 ) ;
1616 let non_clone_type_ref_clone: & PlainType < u32 > = non_clone_type_ref. clone ( ) ;
1717 //~^ WARNING call to `.clone()` on a reference in this situation does nothing
18+ //~| WARNING using `clone` on a double-reference, which copies the reference of type `PlainType<u32>`
1819
1920 let clone_type_ref = & CloneType ( 1u32 ) ;
2021 let clone_type_ref_clone: CloneType < u32 > = clone_type_ref. clone ( ) ;
@@ -23,6 +24,7 @@ fn main() {
2324 // peels the outer reference off
2425 let clone_type_ref = & & CloneType ( 1u32 ) ;
2526 let clone_type_ref_clone: & CloneType < u32 > = clone_type_ref. clone ( ) ;
27+ //~^ WARNING using `clone` on a double-reference, which copies the reference of type `CloneType<u32>`
2628
2729 let non_deref_type = & PlainType ( 1u32 ) ;
2830 let non_deref_type_deref: & PlainType < u32 > = non_deref_type. deref ( ) ;
@@ -42,6 +44,7 @@ fn main() {
4244
4345 let xs = [ "a" , "b" , "c" ] ;
4446 let _v: Vec < & str > = xs. iter ( ) . map ( |x| x. clone ( ) ) . collect ( ) ; // ok, but could use `*x` instead
47+ //~^ WARNING using `clone` on a double-reference, which copies the reference of type `str`
4548}
4649
4750fn generic < T > ( non_clone_type : & PlainType < T > ) {
0 commit comments