about summary refs log tree commit diff
path: root/src/libsyntax/error_codes.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-02 01:09:23 +0200
committerGitHub <noreply@github.com>2019-05-02 01:09:23 +0200
commiteabdce578bfe2e503bedbe42247539e4196a06d7 (patch)
tree69db2589e668aaa6006458cfded37f6391e23088 /src/libsyntax/error_codes.rs
parent9b67bd42b7cbf97f72d039afcba02f5177d0d68c (diff)
parent2be37ad42197f202dfb87c073cb0c6b5e9e5b2ec (diff)
downloadrust-eabdce578bfe2e503bedbe42247539e4196a06d7.tar.gz
rust-eabdce578bfe2e503bedbe42247539e4196a06d7.zip
Rollup merge of #59634 - DevQps:explain-E0704, r=estebank
Added an explanation for the E0704 error.

# Description
Adds an explanation on the E0704 error. I tried to stick as closely to the message that the compiler generates. It's the first time I am fixing error messages here, so if there is something I did wrong or should improve, please let me know.

closes #55398
Diffstat (limited to 'src/libsyntax/error_codes.rs')
-rw-r--r--src/libsyntax/error_codes.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/libsyntax/error_codes.rs b/src/libsyntax/error_codes.rs
index ac24475cab8..e2d212eb721 100644
--- a/src/libsyntax/error_codes.rs
+++ b/src/libsyntax/error_codes.rs
@@ -363,6 +363,35 @@ and likely to change in the future.
 
 "##,
 
+E0704: r##"
+This error indicates that a incorrect visibility restriction was specified.
+
+Example of erroneous code:
+
+```compile_fail,E0704
+mod foo {
+    pub(foo) struct Bar {
+        x: i32
+    }
+}
+```
+
+To make struct `Bar` only visible in module `foo` the `in` keyword should be
+used:
+```
+mod foo {
+    pub(in crate::foo) struct Bar {
+        x: i32
+    }
+}
+# fn main() {}
+```
+
+For more information see the Rust Reference on [Visibility].
+
+[Visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html
+"##,
+
 E0705: r##"
 A `#![feature]` attribute was declared for a feature that is stable in
 the current edition, but not in all editions.
@@ -417,6 +446,5 @@ register_diagnostics! {
     E0693, // incorrect `repr(align)` attribute format
     E0694, // an unknown tool name found in scoped attributes
     E0703, // invalid ABI
-    E0704, // incorrect visibility restriction
     E0717, // rustc_promotable without stability attribute
 }