]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0592.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0592.md
1 This error occurs when you defined methods or associated functions with same
2 name.
3
4 Erroneous code example:
5
6 ```compile_fail,E0592
7 struct Foo;
8
9 impl Foo {
10     fn bar() {} // previous definition here
11 }
12
13 impl Foo {
14     fn bar() {} // duplicate definition here
15 }
16 ```
17
18 A similar error is E0201. The difference is whether there is one declaration
19 block or not. To avoid this error, you must give each `fn` a unique name.
20
21 ```
22 struct Foo;
23
24 impl Foo {
25     fn bar() {}
26 }
27
28 impl Foo {
29     fn baz() {} // define with different name
30 }
31 ```