trait_added_supertrait
should check for blanket impls and their bounds
#923
Labels
trait_added_supertrait
should check for blanket impls and their bounds
#923
The
trait_added_supertrait
lint (#441, #892) is unable to do precise-enough analysis of supertraits (including foreign traits, blocked on #638) since generics and bounds aren't modeled in our schema yet (#149).This can cause false-positives in (arguably, relatively pathological) cases such as:
Transitive blanket impls can also cause false-positives (an even more-pathological case):
In both of these cases, the added supertrait bound is trivially satisfied due to blanket impls, so it's not a major breaking change to add it.
Resolving this issue requires checking (transitively!) for universal blanket impls of the specific
ImplementedTrait
(trait + generics) that was added in the bound.It has to be
ImplementedTrait
("trait + generics") and not justTrait
because it's possible the blanket is only for that specific parameterization of the trait.For example:
impl<T> Blanket<'static, ()> for T {}
.Blankets that don't fit the added supertrait bound don't apply, and in such cases the change is still breaking.
For example:
impl<T, U: Copy> Blanket<U> for T {}
will not prevent a breaking change if a trait adds a bound liketrait Example<T>: Blanket<T>
, whereT: Copy
isn't part of the trait's bounds, or liketrait Example: Blanket<String>
whereString
isn'tCopy
.The text was updated successfully, but these errors were encountered: