-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Emit helpful note
messages only once
#24690
Comments
note
messages only once per occurrencenote
messages only once
I think this is a good "E-easy" candidate. Relevant code is in src/librustc/lint/context.rs. |
We introduce a new `one_time_diagnostics` field on `rustc::session::Session` to hold a hashset of diagnostic messages we've set once but don't want to see again (as uniquified by span and message text), "lint level defined here" being the motivating example dealt with here. It is the responsibility of the caller setting a diagnostic to decide whether to add to `one_time_diagnostics`; there are other situations where we likely do want it to be possible for a note to appear twice on the same span with the same message (e.g., "prior assignment occurs here"). This is in the matter of rust-lang#24690.
We introduce a new `one_time_diagnostics` field on `rustc::session::Session` to hold a hashset of diagnostic messages we've set once but don't want to see again (as uniquified by span and message text), "lint level defined here" being the motivating example dealt with here. This is in the matter of rust-lang#24690.
Question -- in #37191, we get only "lint level defined here" per |
Jonathan D. Turner pointed out that we don't want to dedup in JSON mode. Since the compile-test runner uses JSON output, we regrettably need to revert the edits to existing tests; one imagines that testing for one-time diagnosticity for humans will have to be added as a UI test. This remains in the matter of rust-lang#24690.
Some lint-level attributes (like `bad-style`, or, more dramatically, `warnings`) can affect more than one lint; it seems fairer to point out the attribute once for each distinct lint affected. Also, a UI test is added. This remains in the matter of rust-lang#24690.
… r=nikomatsakis introing one-time diagnostics: only emit "lint level defined here" once This is a revised resubmission of PR #34084 (which was closed due to inactivity on account of time constraints on the author's part). --- We introduce a new `one_time_diagnostics` field on `rustc::session::Session` to hold a hashset of diagnostic messages we've set once but don't want to see again (as uniquified by span and message text), "lint level defined here" being the motivating example dealt with here. This is in the matter of #24690. --- r? @nikomatsakis
Can someone with perms close this? I forgot to use the magic words in #37191. |
Great! Fixed in #37191 |
Example: Adding
#![deny(lint_name)]
to a crate will point out the location of this line for every time the lint fires (note: lint level defined here
). This should be listed only once. It should be reasonably easy to deduplicate these based upon equal span and message.The text was updated successfully, but these errors were encountered: