]> git.lizzy.rs Git - rust.git/blob - src/librustc_privacy/diagnostics.rs
Add error code for privacy error on exported signature
[rust.git] / src / librustc_privacy / diagnostics.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_snake_case)]
12
13 register_long_diagnostics! {
14
15 E0445: r##"
16 A private trait was used on a "public" type. Erroneous code example:
17
18 ```
19 trait Foo {
20     fn dummy(&self) { }
21 }
22
23 pub trait Bar : Foo {} // error: private trait in exported type parameter bound
24 ```
25
26 To solve this error, please ensure the trait is accessible at the same level of
27 the type(s) on which it's implemented. Example:
28
29 ```
30 pub trait Foo { // we set the Foo trait public
31     fn dummy(&self) { }
32 }
33
34 pub trait Bar : Foo {} // ok!
35 ```
36 "##,
37
38 E0446: r##"
39 A private type was used in an exported type signature. Erroneous code example:
40
41 ```
42 mod Foo {
43     struct Bar(u32);
44
45     pub fn bar() -> Bar { // error: private type in exported type signature
46         Bar(0)
47     }
48 }
49 ```
50
51 To solve this error, please ensure the type is accessible at the same level of
52 the exported type signature. Example:
53
54 ```
55 mod Foo {
56     pub struct Bar(u32); // we set the Bar type public
57
58     pub fn bar() -> Bar { // ok!
59         Bar(0)
60     }
61 }
62 ```
63 "##,
64
65 }