fn check_duplicate_params<'tcx>(
    tcx: TyCtxt<'tcx>,
    impl1_args: GenericArgsRef<'tcx>,
    parent_args: Vec<GenericArg<'tcx>>,
    span: Span
) -> Result<(), ErrorGuaranteed>
Expand description

Check that parameters of the derived impl don’t occur more than once in the equated args 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 args for the parent impl here are [T, Vec<T>], which repeats T, but S is constrained in the parent impl, so parent_args is only [Vec<T>]. This means we allow this impl.