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
Fires when a trait implementation relies on a default method. This is primarily useful for "delegating" trait implementations that want to do a bit of work in addition to a lower implementation
Lint Name
unintentional_default_trait_methods
Category
restriction
Advantage
If a new default trait is added, it will be more obvious that we need to update our code to account for that method.
Drawbacks
There may be new default methods that we do want to rely on. I don't actually know if it's possible, but if the lint could be parameterized to ignore specific default methods, that would be nice.
Example
traitExampleTrait{fnalpha(&mutself) -> bool{false}fnomega(&mutself) -> bool{false}}structOuterImplementation<T>{inner:T,count:usize,}// This is bad; we don't know what methods `T` implements.// If a new default function is added to `ExampleTrait`, we// won't be doing our additional work.impl<T:ExampleTrait>ExampleTraitforOuterImplementation<T>{fnalpha(&mutself) -> bool{self.count += 1;self.inner.alpha()}}
If #[deny(unintentional_default_trait_methods)] was added to the impl ExampleTrait for OuterImplementation line, then an error like
This implementation of `ExampleTrait` uses the default trait method `omega`, but it should be deliberately implemented
There could even be a fix-it that adds the method stub.
The text was updated successfully, but these errors were encountered:
What it does
Fires when a trait implementation relies on a default method. This is primarily useful for "delegating" trait implementations that want to do a bit of work in addition to a lower implementation
Lint Name
unintentional_default_trait_methods
Category
restriction
Advantage
If a new default trait is added, it will be more obvious that we need to update our code to account for that method.
Drawbacks
There may be new default methods that we do want to rely on. I don't actually know if it's possible, but if the lint could be parameterized to ignore specific default methods, that would be nice.
Example
If
#[deny(unintentional_default_trait_methods)]
was added to theimpl ExampleTrait for OuterImplementation
line, then an error likeThere could even be a fix-it that adds the method stub.
The text was updated successfully, but these errors were encountered: