@@ -112,6 +112,7 @@ mod useless_asref;
112112mod  utils; 
113113mod  vec_resize_to_zero; 
114114mod  verbose_file_reads; 
115+ mod  waker_clone_and_wake; 
115116mod  wrong_self_convention; 
116117mod  zst_offset; 
117118
@@ -3632,6 +3633,28 @@ declare_clippy_lint! {
36323633    "`as_str` used to call a method on `str` that is also available on `String`" 
36333634} 
36343635
3636+ declare_clippy_lint !  { 
3637+     /// ### What it does 
3638+      /// Checks for usage of `clone().wake_by_ref()` 
3639+      /// 
3640+      /// ### Why is this bad? 
3641+      /// Cloning the waker is not necessary, `wake_by_ref()` enables the same operation 
3642+      /// without extra cloning/dropping. 
3643+      /// 
3644+      /// ### Example 
3645+      /// ```rust,ignore 
3646+      /// waker.clone().wake(); 
3647+      /// ``` 
3648+      /// Should be written 
3649+      /// ```rust,ignore 
3650+      /// waker.wake_by_ref(); 
3651+      /// ``` 
3652+      #[ clippy:: version = "1.75.0" ] 
3653+     pub  WAKER_CLONE_AND_WAKE , 
3654+     perf, 
3655+     "cloning a `Waker` only to wake it" 
3656+ } 
3657+ 
36353658pub  struct  Methods  { 
36363659    avoid_breaking_exported_api :  bool , 
36373660    msrv :  Msrv , 
@@ -3777,6 +3800,7 @@ impl_lint_pass!(Methods => [
37773800    ITER_OUT_OF_BOUNDS , 
37783801    PATH_ENDS_WITH_EXT , 
37793802    REDUNDANT_AS_STR , 
3803+     WAKER_CLONE_AND_WAKE , 
37803804] ) ; 
37813805
37823806/// Extracts a method call name, args, and `Span` of the method name. 
@@ -4365,6 +4389,9 @@ impl Methods {
43654389                    } 
43664390                    unnecessary_literal_unwrap:: check ( cx,  expr,  recv,  name,  args) ; 
43674391                } , 
4392+                 ( "wake" ,  [ ] )  => { 
4393+                     waker_clone_and_wake:: check ( cx,  expr,  recv) ; 
4394+                 } 
43684395                ( "write" ,  [ ] )  => { 
43694396                    readonly_write_lock:: check ( cx,  expr,  recv) ; 
43704397                } 
0 commit comments