]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0639.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0639.md
1 This error indicates that the struct, enum or enum variant cannot be
2 instantiated from outside of the defining crate as it has been marked
3 as `non_exhaustive` and as such more fields/variants may be added in
4 future that could cause adverse side effects for this code.
5
6 Erroneous code example:
7
8 ```ignore (it only works cross-crate)
9 #[non_exhaustive]
10 pub struct NormalStruct {
11     pub first_field: u16,
12     pub second_field: u16,
13 }
14
15 let ns = NormalStruct { first_field: 640, second_field: 480 }; // error!
16 ```
17
18 It is recommended that you look for a `new` function or equivalent in the
19 crate's documentation.