Add error code for tuple struct constructor error

This commit is contained in:
Guillaume Gomez 2015-09-09 12:08:21 +02:00
parent 6090cea184
commit a056d5869e
2 changed files with 27 additions and 3 deletions

View File

@ -125,4 +125,28 @@ To fix this error, please remove the visibility qualifier when it is not
required.
"##,
E0450: r##"
A tuple constructor was invoked while some of its fields are private. Erroneous
code example:
```
mod Bar {
pub struct Foo(isize);
}
let f = Bar::Foo(0); // error: cannot invoke tuple struct constructor with
// private fields
```
To solve this issue, please ensure that all tuple's fields are public. Example:
```
mod Bar {
pub struct Foo(pub isize); // we set its field to public
}
let f = Bar::Foo(0); // ok!
```
"##,
}

View File

@ -931,9 +931,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
});
if any_priv {
self.tcx.sess.span_err(expr.span,
"cannot invoke tuple struct constructor \
with private fields");
span_err!(self.tcx.sess, expr.span, E0450,
"cannot invoke tuple struct constructor with private \
fields");
}
}
}