Skip to content

Add suggestion to remove visibility qualifier in error[E0449]: visibility qualifiers are not permitted here for cargo fix #123529

Closed
@ElectrifyPro

Description

@ElectrifyPro

Code

trait Fun {
    pub fn test() {}
}

Current output

error[E0449]: visibility qualifiers are not permitted here
 --> src/main.rs:2:5
  |
2 |     pub fn test() {}
  |     ^^^
  |
  = note: trait items always share the visibility of their trait

Desired output

error[E0449]: visibility qualifiers are not permitted here
 --> src/main.rs:2:5
  |
2 |     pub fn test() {}
  |     ^^^
  |
  = note: trait items always share the visibility of their trait
help: remove the qualifier
  |
2 |     fn test() {}
  |

Rationale and extra context

This error has a very trivial no-nonsense solution, and it would be nice for the compiler to provide a suggestion so that it can can easily be fixed with cargo fix.

Other cases

No response

Rust Version

$ rustc --version --verbose
rustc 1.79.0-nightly (0ad927c0c 2024-03-21)
binary: rustc
commit-hash: 0ad927c0c07b65fc0dae37105e09c877c87c296a
commit-date: 2024-03-21
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions