Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ElectrifyPro opened this issue Apr 6, 2024 · 2 comments · Fixed by #123841
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ElectrifyPro
Copy link
Contributor

ElectrifyPro commented Apr 6, 2024

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

@ElectrifyPro ElectrifyPro added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 6, 2024
@jieyouxu jieyouxu added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. labels Apr 6, 2024
@Kohei316
Copy link
Contributor

Kohei316 commented Apr 6, 2024

@rustbot claim

@colommar
Copy link

colommar commented Apr 6, 2024

@rustbot claim

@rustbot rustbot assigned colommar and unassigned Kohei316 Apr 6, 2024
@lqd lqd assigned Kohei316 and unassigned colommar Apr 6, 2024
Rajveer100 added a commit to Rajveer100/rust that referenced this issue Apr 7, 2024
Rajveer100 added a commit to Rajveer100/rust that referenced this issue Apr 7, 2024
@bors bors closed this as completed in 15a8b49 Apr 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 12, 2024
Rollup merge of rust-lang#123841 - Kohei316:remove_qualifier_sugg, r=wesleywiser

Improve diagnostic by suggesting to remove visibility qualifier

Resolves rust-lang#123529
This PR improve diagnostic by suggesting to remove visibility qualifier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants