]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_error_codes/src/error_codes/E0445.md
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0445.md
1 A private trait was used on a public type parameter bound.
2
3 Erroneous code examples:
4
5 ```compile_fail,E0445
6 #![deny(private_in_public)]
7
8 trait Foo {
9 fn dummy(&self) { }
10 }
11
12 pub trait Bar : Foo {} // error: private trait in public interface
13 pub struct Bar2<T: Foo>(pub T); // same error
14 pub fn foo<T: Foo> (t: T) {} // same error
15
16 fn main() {}
17 ```
18
19 To solve this error, please ensure that the trait is also public. The trait
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`. Example:
22
23 ```
24 pub trait Foo { // we set the Foo trait public
25 fn dummy(&self) { }
26 }
27
28 pub trait Bar : Foo {} // ok!
29 pub struct Bar2<T: Foo>(pub T); // ok!
30 pub fn foo<T: Foo> (t: T) {} // ok!
31
32 fn main() {}
33 ```