]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0323.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0323.md
1 An associated const was implemented when another trait item was expected.
2
3 Erroneous code example:
4
5 ```compile_fail,E0323
6 trait Foo {
7     type N;
8 }
9
10 struct Bar;
11
12 impl Foo for Bar {
13     const N : u32 = 0;
14     // error: item `N` is an associated const, which doesn't match its
15     //        trait `<Bar as Foo>`
16 }
17 ```
18
19 Please verify that the associated const wasn't misspelled and the correct trait
20 was implemented. Example:
21
22 ```
23 struct Bar;
24
25 trait Foo {
26     type N;
27 }
28
29 impl Foo for Bar {
30     type N = u32; // ok!
31 }
32 ```
33
34 Or:
35
36 ```
37 struct Bar;
38
39 trait Foo {
40     const N : u32;
41 }
42
43 impl Foo for Bar {
44     const N : u32 = 0; // ok!
45 }
46 ```