summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/mismatching_type_param_order.txt
blob: ffc7f32d0aad8ea2320dfba9b2058c8de82a6903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
### 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> {}
```