1
1
// check-pass
2
2
3
3
#![ allow( unused) ]
4
- #![ warn( noop_method_call) ]
4
+ #![ warn( noop_method_call, clone_double_ref ) ]
5
5
6
6
use std:: borrow:: Borrow ;
7
7
use std:: ops:: Deref ;
@@ -15,6 +15,7 @@ fn main() {
15
15
let non_clone_type_ref = & PlainType ( 1u32 ) ;
16
16
let non_clone_type_ref_clone: & PlainType < u32 > = non_clone_type_ref. clone ( ) ;
17
17
//~^ 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>`
18
19
19
20
let clone_type_ref = & CloneType ( 1u32 ) ;
20
21
let clone_type_ref_clone: CloneType < u32 > = clone_type_ref. clone ( ) ;
@@ -23,6 +24,7 @@ fn main() {
23
24
// peels the outer reference off
24
25
let clone_type_ref = & & CloneType ( 1u32 ) ;
25
26
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>`
26
28
27
29
let non_deref_type = & PlainType ( 1u32 ) ;
28
30
let non_deref_type_deref: & PlainType < u32 > = non_deref_type. deref ( ) ;
@@ -42,6 +44,7 @@ fn main() {
42
44
43
45
let xs = [ "a" , "b" , "c" ] ;
44
46
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`
45
48
}
46
49
47
50
fn generic < T > ( non_clone_type : & PlainType < T > ) {
0 commit comments