Add error code for tuple struct constructor error
This commit is contained in:
parent
6090cea184
commit
a056d5869e
@ -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!
|
||||
```
|
||||
"##,
|
||||
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user