Closed
Description
What it does
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.
Drawbacks
No response
Example
trait Foo {
fn bar(self) -> i32;
}
impl Foo for () {
#[must_use]
fn bar(self) -> i32 {
1
}
}
Could be written as:
trait Foo {
#[must_use]
fn bar(self) -> i32;
}
impl Foo for () {
fn bar(self) -> i32 {
1
}
}