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
Ah, now I see your point. As any R that is R: AsyncReadExt has to be R: AsyncRead (due to pub trait AsyncReadExt: AsyncRead), and as all R: AsyncRead + ?Sized are AsyncReadExt due to impl<R: AsyncRead + ?Sized> AsyncReadExt for R, a trait bound R: AsyncReadExt is never more powerful than a R: AsyncRead.
I guess one could make a list of common(?) traits which have this property. Solving the general case is probably quite hard.
I've only ever seen people make the mistake with traits called StreamExt, AsyncReadExt, and AsyncWriteExt. (Though note that all of those names have multiple instances of them in different crates.)
What it does
It detects when an extension trait is used as a trait bound. The base trait should be used instead. For example:
In this case, it should suggest writing
R: AsyncRead
instead.To define "extension trait", one possibility is any trait of the following form:
Lint Name
extension-trait-as-trait-bound
Category
style
Advantage
Drawbacks
Somewhat unclear how "extension trait" should be defined. For example, should
+ ?Sized
be required for it to be an extension trait?It's also unclear if there are cases where this would be a false positive.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: