-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Lint on no-op implementations of std::task::Wake which can likely be replaced by Waker::noop() in their use.
Advantage
(assuming the Wake implementer is used for the From<Arc<W>> for Waker implementation) Using Waker::noop instead is less code and more performant since it doesn't need to check the reference count on an Arc.
Drawbacks
People might do other things with the Wake trait other than using it to construct a Waker, and if they do then this would be a false positive. I haven't seen any code doing anything like that, but it might exist somewhere.
Example
struct NoopWaker;
impl Wake for NoopWaker {
fn wake(self: Arc<Self>) {}
fn wake_by_ref(self: &Arc<Self>) {}
}
let waker = Waker::from(Arc::new(NoopWaker));
let context = Context::from_waker(&waker);Could be written as:
let context = Context::from_waker(Waker::noop());Comparison with existing lints
I don't believe there are any similar lints
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints