]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_error_codes/src/error_codes/E0603.md
New upstream version 1.63.0+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0603.md
CommitLineData
60c5eb7d
XL
1A private item was used outside its scope.
2
3Erroneous code example:
4
5```compile_fail,E0603
923072b8 6mod foo {
60c5eb7d
XL
7 const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we
8 // can't use it outside of the
923072b8 9 // `foo` module.
60c5eb7d
XL
10}
11
923072b8 12println!("const value: {}", foo::PRIVATE); // error: constant `PRIVATE`
60c5eb7d
XL
13 // is private
14```
15
16In order to fix this error, you need to make the item public by using the `pub`
17keyword. Example:
18
19```
923072b8 20mod foo {
60c5eb7d
XL
21 pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the
22 // `pub` keyword.
23}
24
923072b8 25println!("const value: {}", foo::PRIVATE); // ok!
60c5eb7d 26```