RS.CLIPPY.MISMATCHING_TYPE_PARAM_ORDER
Type parameter positioned inconsistently between type def and impl block
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: mismatching_type_param_order. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for type parameters which are positioned inconsistently between a type definition and impl block. Specifically, a parameter in an impl block which has the same name as a parameter in the type def, but is in a different place.
Why is this bad?
Type parameters are determined by their position rather than name. Naming type parameters inconsistently may cause you to refer to the wrong type parameter.
Limitations
This lint only applies to impl blocks with simple generic params, e.g.
A. If there is anything more complicated, such as a tuple, it will be
ignored.
Example
struct Foo<A, B> {
x: A,
y: B,
}
// inside the impl, B refers to Foo::A
impl<B, A> Foo<B, A> {}
Use instead:
struct Foo<A, B> {
x: A,
y: B,
}
impl<A, B> Foo<A, B> {}