summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/use_self.txt
blob: bd37ed1e0025634ec48508fc2e9e3f01529ec94d (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
### What it does
Checks for unnecessary repetition of structure name when a
replacement with `Self` is applicable.

### Why is this bad?
Unnecessary repetition. Mixed use of `Self` and struct
name
feels inconsistent.

### Known problems
- Unaddressed false negative in fn bodies of trait implementations
- False positive with associated types in traits (#4140)

### Example
```
struct Foo;
impl Foo {
    fn new() -> Foo {
        Foo {}
    }
}
```
could be
```
struct Foo;
impl Foo {
    fn new() -> Self {
        Self {}
    }
}
```