]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0329.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0329.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 An attempt was made to access an associated constant through either a generic
4 type parameter or `Self`. This is not supported yet. An example causing this
5 error is shown below:
6
7 ```
8 trait Foo {
9     const BAR: f64;
10 }
11
12 struct MyStruct;
13
14 impl Foo for MyStruct {
15     const BAR: f64 = 0f64;
16 }
17
18 fn get_bar_bad<F: Foo>(t: F) -> f64 {
19     F::BAR
20 }
21 ```
22
23 Currently, the value of `BAR` for a particular type can only be accessed
24 through a concrete type, as shown below:
25
26 ```
27 trait Foo {
28     const BAR: f64;
29 }
30
31 struct MyStruct;
32
33 impl Foo for MyStruct {
34     const BAR: f64 = 0f64;
35 }
36
37 fn get_bar_good() -> f64 {
38     <MyStruct as Foo>::BAR
39 }
40 ```