]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0609.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0609.md
1 Attempted to access a non-existent field in a struct.
2
3 Erroneous code example:
4
5 ```compile_fail,E0609
6 struct StructWithFields {
7     x: u32,
8 }
9
10 let s = StructWithFields { x: 0 };
11 println!("{}", s.foo); // error: no field `foo` on type `StructWithFields`
12 ```
13
14 To fix this error, check that you didn't misspell the field's name or that the
15 field actually exists. Example:
16
17 ```
18 struct StructWithFields {
19     x: u32,
20 }
21
22 let s = StructWithFields { x: 0 };
23 println!("{}", s.x); // ok!
24 ```