Add error code for privacy error on exported signature

This commit is contained in:
Guillaume Gomez 2015-09-09 11:08:35 +02:00
parent 5e9bfcd6d6
commit c4a3936327
2 changed files with 29 additions and 1 deletions

View File

@ -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)
}
}
```
"##,
}

View File

@ -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)