summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0449.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0449.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0449.md29
1 files changed, 20 insertions, 9 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0449.md b/compiler/rustc_error_codes/src/error_codes/E0449.md
index 9afc67689..a5876e075 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0449.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0449.md
@@ -1,4 +1,6 @@
-A visibility qualifier was used when it was unnecessary.
+A visibility qualifier was used where one is not permitted. Visibility
+qualifiers are not permitted on enum variants, trait items, impl blocks, and
+extern blocks, as they already share the visibility of the parent item.
Erroneous code examples:
@@ -9,15 +11,18 @@ trait Foo {
fn foo();
}
-pub impl Bar {} // error: unnecessary visibility qualifier
+enum Baz {
+ pub Qux, // error: visibility qualifiers are not permitted here
+}
+
+pub impl Bar {} // error: visibility qualifiers are not permitted here
-pub impl Foo for Bar { // error: unnecessary visibility qualifier
- pub fn foo() {} // error: unnecessary visibility qualifier
+pub impl Foo for Bar { // error: visibility qualifiers are not permitted here
+ pub fn foo() {} // error: visibility qualifiers are not permitted here
}
```
-To fix this error, please remove the visibility qualifier when it is not
-required. Example:
+To fix this error, simply remove the visibility qualifier. Example:
```
struct Bar;
@@ -26,12 +31,18 @@ trait Foo {
fn foo();
}
+enum Baz {
+ // Enum variants share the visibility of the enum they are in, so
+ // `pub` is not allowed here
+ Qux,
+}
+
// Directly implemented methods share the visibility of the type itself,
-// so `pub` is unnecessary here
+// so `pub` is not allowed here
impl Bar {}
-// Trait methods share the visibility of the trait, so `pub` is
-// unnecessary in either case
+// Trait methods share the visibility of the trait, so `pub` is not
+// allowed in either case
impl Foo for Bar {
fn foo() {}
}