diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-09-09 11:08:35 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-09-09 11:08:35 +0200 |
| commit | c4a3936327f2f1082e3ac52e3dc7b250e3a04506 (patch) | |
| tree | 0d04e998ed71acd0d33f19dd81aed89f93a41385 | |
| parent | 5e9bfcd6d6342240200ec38f65ef75e96daa1b7a (diff) | |
| download | rust-c4a3936327f2f1082e3ac52e3dc7b250e3a04506.tar.gz rust-c4a3936327f2f1082e3ac52e3dc7b250e3a04506.zip | |
Add error code for privacy error on exported signature
| -rw-r--r-- | src/librustc_privacy/diagnostics.rs | 27 | ||||
| -rw-r--r-- | src/librustc_privacy/lib.rs | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/librustc_privacy/diagnostics.rs b/src/librustc_privacy/diagnostics.rs index ff4163a53a1..cdd6af2d13d 100644 --- a/src/librustc_privacy/diagnostics.rs +++ b/src/librustc_privacy/diagnostics.rs @@ -35,4 +35,31 @@ pub trait Bar : Foo {} // ok! ``` "##, +E0446: r##" +A private type was used in an exported type signature. Erroneous code example: + +``` +mod Foo { + struct Bar(u32); + + pub fn bar() -> Bar { // error: private type in exported type signature + Bar(0) + } +} +``` + +To solve this error, please ensure the type is accessible at the same level of +the exported type signature. Example: + +``` +mod Foo { + pub struct Bar(u32); // we set the Bar type public + + pub fn bar() -> Bar { // ok! + Bar(0) + } +} +``` +"##, + } \ No newline at end of file diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 9d0c1a560da..7b14ef134eb 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1435,7 +1435,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { if let hir::TyPath(_, ref p) = t.node { if !self.tcx.sess.features.borrow().visible_private_types && self.path_is_private_type(t.id) { - self.tcx.sess.span_err(p.span, "private type in exported type signature"); + span_err!(self.tcx.sess, p.span, E0446, + "private type in exported type signature"); } } visit::walk_ty(self, t) |
