]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0446.md
Rollup merge of #68288 - RalfJung:fmt, r=oli-obk
[rust.git] / src / librustc_error_codes / error_codes / E0446.md
1 A private type was used in a public type signature.
2
3 Erroneous code example:
4
5 ```compile_fail,E0446
6 #![deny(private_in_public)]
7
8 mod Foo {
9     struct Bar(u32);
10
11     pub fn bar() -> Bar { // error: private type in public interface
12         Bar(0)
13     }
14 }
15
16 fn main() {}
17 ```
18
19 To solve this error, please ensure that the type is also public. The type
20 can be made inaccessible if necessary by placing it into a private inner
21 module, but it still has to be marked with `pub`.
22 Example:
23
24 ```
25 mod Foo {
26     pub struct Bar(u32); // we set the Bar type public
27
28     pub fn bar() -> Bar { // ok!
29         Bar(0)
30     }
31 }
32
33 fn main() {}
34 ```