Make "unneccesary visibility qualifier" error much more clear
This commit is contained in:
@@ -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 Foo for Bar { // error: unnecessary visibility qualifier
|
||||
pub fn foo() {} // error: unnecessary visibility qualifier
|
||||
pub impl Bar {} // error: visibility qualifiers are not permitted here
|
||||
|
||||
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() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user