1 #![allow(non_snake_case)]
3 register_long_diagnostics! {
6 A private trait was used on a public type parameter bound. Erroneous code
10 #![deny(private_in_public)]
16 pub trait Bar : Foo {} // error: private trait in public interface
17 pub struct Bar2<T: Foo>(pub T); // same error
18 pub fn foo<T: Foo> (t: T) {} // same error
21 To solve this error, please ensure that the trait is also public. The trait
22 can be made inaccessible if necessary by placing it into a private inner
23 module, but it still has to be marked with `pub`. Example:
26 pub trait Foo { // we set the Foo trait public
30 pub trait Bar : Foo {} // ok!
31 pub struct Bar2<T: Foo>(pub T); // ok!
32 pub fn foo<T: Foo> (t: T) {} // ok!
37 A private type was used in a public type signature. Erroneous code example:
40 #![deny(private_in_public)]
45 pub fn bar() -> Bar { // error: private type in public interface
51 To solve this error, please ensure that the type is also public. The type
52 can be made inaccessible if necessary by placing it into a private inner
53 module, but it still has to be marked with `pub`.
58 pub struct Bar(u32); // we set the Bar type public
60 pub fn bar() -> Bar { // ok!
68 #### Note: this error code is no longer emitted by the compiler.
70 The `pub` keyword was used inside a function. Erroneous code example:
74 pub struct Bar; // error: visibility has no effect inside functions
78 Since we cannot access items defined inside a function, the visibility of its
79 items does not impact outer code. So using the `pub` keyword in this context
84 The `pub` keyword was used inside a public enum. Erroneous code example:
88 pub Bar, // error: unnecessary `pub` visibility
92 Since the enum is already public, adding `pub` on one its elements is
101 This is the correct syntax:
111 A struct constructor with private fields was invoked. Erroneous code example:
113 ```compile_fail,E0451
121 let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`
125 To fix this error, please ensure that all the fields of the struct are public,
126 or implement a function for easy instantiation. Examples:
132 pub b: isize, // we set `b` field public
136 let f = Bar::Foo{ a: 0, b: 0 }; // ok!
145 b: isize, // still private
149 pub fn new() -> Foo { // we create a method to instantiate `Foo`
155 let f = Bar::Foo::new(); // ok!
161 register_diagnostics! {
162 // E0450, moved into resolve