You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lint should warn if #[must_use] is applied to a function in an impl Trait for Type { .... } block, and suggest applying it to the trait definition instead.
Advantage
As per the reference, #[must_use] in the impl Trait for Type block does absolutely nothing, and is therefore almost surely a mistake. On the other hand, #[must_use] in the trait definition applies to all implementations of the trait.
Maybe this should be an extension to rustc's unused_attributes lint instead? That one is already used as a general lint for any kind of attribute used in some places where it doesn't do anything.
What it does
The lint should warn if
#[must_use]
is applied to a function in animpl Trait for Type { .... }
block, and suggest applying it to the trait definition instead.Advantage
As per the reference,
#[must_use]
in theimpl Trait for Type
block does absolutely nothing, and is therefore almost surely a mistake. On the other hand,#[must_use]
in the trait definition applies to all implementations of the trait.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: