]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0445.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / 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
17 To solve this error, please ensure that the trait is also public. The trait
18 can be made inaccessible if necessary by placing it into a private inner
19 module, but it still has to be marked with `pub`. Example:
20
21 ```
22 pub trait Foo { // we set the Foo trait public
23     fn dummy(&self) { }
24 }
25
26 pub trait Bar : Foo {} // ok!
27 pub struct Bar2<T: Foo>(pub T); // ok!
28 pub fn foo<T: Foo> (t: T) {} // ok!
29 ```