Clippy lints / Performance
Clippy lint · Performance · checked with Clippy 0.1.99
clippy::waker_clone_wake: Checks for usage of waker.clone().wake()
What it meansChecks for usage of waker.clone().wake() It is in the performance group and warns by default.
Does it matter?
Cloning the waker is not necessary, wake_by_ref() enables the same operation without extra cloning/dropping.
Code that could be written to run faster. Warns by default.
How to fix it
Clippy can fix this one for you: run cargo clippy --fix (add --allow-dirty if you have uncommitted changes). Review the diff before you commit.
Flagged
waker.clone().wake();
Write this instead
waker.wake_by_ref();
Turn it off, or on
Allow it where it does not fit your code, as narrowly as you can:
On one item
#[allow(clippy::waker_clone_wake)]
fn my_function() { /* ... */ }Whole crate (Cargo.toml)
[lints.clippy]
waker_clone_wake = "allow"One run
cargo clippy -- -A clippy::waker-clone-wakeThe [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.
Clippy's own documentation
What it does
Checks for usage of waker.clone().wake()
Why is this bad?
Cloning the waker is not necessary, wake_by_ref() enables the same operation
without extra cloning/dropping.
Example
waker.clone().wake();
Should be written
waker.wake_by_ref();
From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.
Related lints
- large_enum_variantlarge size difference between variants
- useless_borrows_in_formattingredundant reference in `println!` argument
- useless_vecuseless use of `vec!`
- vec_init_then_pushcalls to `push` immediately after creation
All 847 Clippy lints · Rust compiler errors · Cargo.toml checker
Up next
Related lintclippy::large_enum_variantlarge size difference between variantsRead it next →Did this answer your question?