diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-09-09 12:08:21 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2015-09-09 12:08:21 +0200 |
| commit | a056d5869e808b7f26cb536eca1aadda26a8188f (patch) | |
| tree | 32787838695ebbae267eb1e5881e1ce9e12c0829 | |
| parent | 6090cea18479f3a3bf12fe63034966cbe6eed2f7 (diff) | |
| download | rust-a056d5869e808b7f26cb536eca1aadda26a8188f.tar.gz rust-a056d5869e808b7f26cb536eca1aadda26a8188f.zip | |
Add error code for tuple struct constructor error
| -rw-r--r-- | src/librustc_privacy/diagnostics.rs | 24 | ||||
| -rw-r--r-- | src/librustc_privacy/lib.rs | 6 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/librustc_privacy/diagnostics.rs b/src/librustc_privacy/diagnostics.rs index 78f5cc4bbf2..ac83ee2b029 100644 --- a/src/librustc_privacy/diagnostics.rs +++ b/src/librustc_privacy/diagnostics.rs @@ -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! +``` +"##, + } \ No newline at end of file diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 2dbab840ba2..9f5387dd9d6 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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"); } } } |
