fn check_duplicate_params<'tcx>(
tcx: TyCtxt<'tcx>,
impl1_substs: SubstsRef<'tcx>,
parent_substs: &Vec<GenericArg<'tcx>>,
span: Span
)
Expand description
Check that parameters of the derived impl don’t occur more than once in the equated substs of the base impl.
For example forbid the following:
ⓘ
impl<A> Tr for A { }
impl<B> Tr for (B, B) { }
Note that only consider the unconstrained parameters of the base impl:
ⓘ
impl<S, I: IntoIterator<Item = S>> Tr<S> for I { }
impl<T> Tr<T> for Vec<T> { }
The substs for the parent impl here are [T, Vec<T>]
, which repeats T
,
but S
is constrained in the parent impl, so parent_substs
is only
[Vec<T>]
. This means we allow this impl.