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
I have a simple trait that extends the iterators (just like itertools does). This trait has Iterator bound, but my function also has Iterator in its Self argument (just a more precise one).
Before #8229 it was fine, now it hits trait_duplication_in_bounds (which is great!) but the error message is misleading and points to the function's where-clause, however removing that bound does not solve this issue.
Clippy should definitely not be suggesting to remove the super trait as it's not superfluous. It adds a constraint to the type implementing Iter which would otherwise not exist. The where clause is only restricting the default function implementation so other implementations of the trait are only bound by them if they do not provide an implementation. Any type constrained by Iter will be able to make use of any of Iterator's items. e.g.
fnf<I:Iter>(muti:I) -> Option<I::Item>{
i.next()}
Removing the Iterator bound on the trait would make the previous code fail to compile.
With that said this is a false positive. The bound Self: Iterator<Item = (K, V)> can not be expressed without duplicating the bound on the trait.
Summary
I have a simple trait that extends the iterators (just like
itertools
does). This trait hasIterator
bound, but my function also hasIterator
in itsSelf
argument (just a more precise one).Before #8229 it was fine, now it hits
trait_duplication_in_bounds
(which is great!) but the error message is misleading and points to the function'swhere
-clause, however removing that bound does not solve this issue.Reproducer
I tried this code:
I expected to see this happen:
The lint should show that the trait bound is superfluous:
Instead, this happened:
The lint shows the real bound:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: