]> git.lizzy.rs Git - rust.git/blob - src/docs/use_self.txt
Merge remote-tracking branch 'upstream/master' into rustup
[rust.git] / src / docs / use_self.txt
1 ### What it does
2 Checks for unnecessary repetition of structure name when a
3 replacement with `Self` is applicable.
4
5 ### Why is this bad?
6 Unnecessary repetition. Mixed use of `Self` and struct
7 name
8 feels inconsistent.
9
10 ### Known problems
11 - Unaddressed false negative in fn bodies of trait implementations
12 - False positive with associated types in traits (#4140)
13
14 ### Example
15 ```
16 struct Foo;
17 impl Foo {
18     fn new() -> Foo {
19         Foo {}
20     }
21 }
22 ```
23 could be
24 ```
25 struct Foo;
26 impl Foo {
27     fn new() -> Self {
28         Self {}
29     }
30 }
31 ```