@@ -69,15 +69,48 @@ fn main() {
6969 //~^ ERROR: you are explicitly cloning with `.map()`
7070 let y = x. map ( Clone :: clone) ;
7171 //~^ ERROR: you are explicitly cloning with `.map()`
72+ //~| HELP: consider calling the dedicated `cloned` method
7273 let y = x. map ( String :: clone) ;
7374 //~^ ERROR: you are explicitly cloning with `.map()`
75+ //~| HELP: consider calling the dedicated `cloned` method
76+
77+ let x: Option < u32 > = Some ( 0 ) ;
78+ let x = x. as_ref ( ) ; // We do this to prevent triggering the `useless_asref` lint.
79+ let y = x. map ( |x| u32:: clone ( x) ) ;
80+ //~^ ERROR: you are explicitly cloning with `.map()`
81+ //~| HELP: consider calling the dedicated `copied` method
82+ let y = x. map ( |x| Clone :: clone ( x) ) ;
83+ //~^ ERROR: you are explicitly cloning with `.map()`
84+ //~| HELP: consider calling the dedicated `copied` method
85+
86+ // Should not suggest `copied` or `cloned` here since `T` is not a reference.
87+ let x: Option < u32 > = Some ( 0 ) ;
88+ let y = x. map ( |x| u32:: clone ( & x) ) ;
89+ let y = x. map ( |x| Clone :: clone ( & x) ) ;
7490
7591 // Testing with `Result` now.
7692 let x: Result < String , ( ) > = Ok ( String :: new ( ) ) ;
7793 let x = x. as_ref ( ) ; // We do this to prevent triggering the `useless_asref` lint.
7894 let y = x. map ( |x| String :: clone ( x) ) ;
7995 //~^ ERROR: you are explicitly cloning with `.map()`
80- let y = x. map ( |x| String :: clone ( x) ) ;
96+ //~| HELP: consider calling the dedicated `cloned` method
97+ let y = x. map ( |x| Clone :: clone ( x) ) ;
98+ //~^ ERROR: you are explicitly cloning with `.map()`
99+ //~| HELP: consider calling the dedicated `cloned` method
100+
101+ let x: Result < u32 , ( ) > = Ok ( 0 ) ;
102+ let x = x. as_ref ( ) ; // We do this to prevent triggering the `useless_asref` lint.
103+ let y = x. map ( |x| u32:: clone ( x) ) ;
104+ //~^ ERROR: you are explicitly cloning with `.map()`
105+ //~| HELP: consider calling the dedicated `copied` method
106+ let y = x. map ( |x| Clone :: clone ( x) ) ;
107+ //~^ ERROR: you are explicitly cloning with `.map()`
108+ //~| HELP: consider calling the dedicated `copied` method
109+
110+ // Should not suggest `copied` or `cloned` here since `T` is not a reference.
111+ let x: Result < u32 , ( ) > = Ok ( 0 ) ;
112+ let y = x. map ( |x| u32:: clone ( & x) ) ;
113+ let y = x. map ( |x| Clone :: clone ( & x) ) ;
81114
82115 // We ensure that no warning is emitted here because `useless_asref` is taking over.
83116 let x = Some ( String :: new ( ) ) ;
0 commit comments