Skip to content

Commit 37b1dac

Browse files
committed
Improve diagnostics by suggesting to remove visibility qualifier
Resolves #123529
1 parent ca7d34e commit 37b1dac

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ ast_passes_visibility_not_permitted =
273273
.trait_impl = trait items always share the visibility of their trait
274274
.individual_impl_items = place qualifiers on individual impl items instead
275275
.individual_foreign_items = place qualifiers on individual foreign items instead
276+
.help = remove the qualifier
276277
277278
ast_passes_where_clause_after_type_alias = where clauses are not allowed after the type for type aliases
278279
.note = see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct InvalidLabel {
2626

2727
#[derive(Diagnostic)]
2828
#[diag(ast_passes_visibility_not_permitted, code = E0449)]
29+
#[help]
2930
pub struct VisibilityNotPermitted {
3031
#[primary_span]
3132
pub span: Span,

tests/ui/issue-123529.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait Fun {
2+
pub fn test() {}
3+
//~^ ERROR visibility qualifiers are not permitted here
4+
//~| NOTE trait items always share the visibility of their trait
5+
//~| HELP remove the qualifier
6+
}
7+
8+
fn main() {}

tests/ui/issue-123529.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0449]: visibility qualifiers are not permitted here
2+
--> $DIR/issue-123529.rs:2:5
3+
|
4+
LL | pub fn test() {}
5+
| ^^^
6+
|
7+
= help: remove the qualifier
8+
= note: trait items always share the visibility of their trait
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0449`.

0 commit comments

Comments
 (0)