-
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
note individual lint name in messages set via lint group attribute #38103
note individual lint name in messages set via lint group attribute #38103
Conversation
@jonathandturner are you interested in reviewing (the reason I r?'d you is because you seemed to express interest in the issue comments), or should we tag someone else (perhaps @brson, the issue filer)? |
@zackmdavis - sorry for the delay. I'm currently on vacation so I haven't been doing much reviewing. Just taking a glance, I'd move that new message to a note (without a span) possibly. Cool that it's there now, though. |
Oh, sorry to bother you! (I can only hope that my bad luck of accidentally bothering people on vacation does not become a trend.)
And presumably also the |
Updated:
|
|
r? @brson |
I don't mind reviewing this. @zackmdavis -- I would rather expect these clarifications to appear on the "lint level defined here" note, rather than in the main heading. What do you think? |
oh, I missed the updated pics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good! It does seem like there are a few scenarios not tested though. Can you add UI tests for these cases:
- using command-line flags (
-W
etc) that affect a lint indirectly (and hence trigger the "implies" message) - using each of the various settings (-W etc)
You can customize a test to include compilation flags by putting a // compile-flags: ...
annotation in the test (ripgrep around for examples).
Thanks!
struct snake_case; //~ WARN type `snake_case` should have a camel case name | ||
struct snake_case; | ||
//~^ WARN type `snake_case` should have a camel case name | ||
//~| NOTE #[warn(bad_style)] implies #[warn(non_camel_case_types)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests should be made into "ui" tests -- see https://github.com/rust-lang/rust/blob/master/src/test/ui/README.md for some tips on how to work with those.
@nikomatsakis moved make-lint-group-style.rs to be a UI test rather than a compile fail test as you suggested (b4e7128), added UI tests for command-line -A/-W/-D/-F with a lint group (fc692f5), had to merge in master to get Travis to pass (babce29, 7e50b02) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good. =) I have a few more suggestions, curious as to your opinion.
Oh, and one other thing: can you rebase atop rust-lang/master (and squash, probably), rather than merging master into your branch? Just keeps the history a little cleaner. Thanks.
--> $DIR/multispan-import-lint.rs:11:16 | ||
| | ||
11 | use std::cmp::{Eq, Ord, min, PartialEq, PartialOrd}; | ||
| ^^ ^^^ ^^^^^^^^^ ^^^^^^^^^^ | ||
| | ||
= note: #[warn(unused_imports)] on by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very happy to see this moved into an auxiliary note. I've always been annoyed by having it on the main message line :)
src/test/ui/span/issue-24690.stderr
Outdated
@@ -4,6 +4,7 @@ error: unused variable: `theOtherTwo` | |||
20 | let theOtherTwo = 2; | |||
| ^^^^^^^^^^^ | |||
| | |||
= note: #[deny(warnings)] implies #[deny(unused_variables)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels like this should be attached to the message below (lint level defined here
), and also that it should only appear when that message appears (meaning only once), what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this is desirable, but doing it properly will involve addressing the FIXME
about generalizing one-time diagnostics beyond span_note
, which looks sufficiently complicated that I'd prefer to do it in a separate PR.
(The most obvious thing to do would be to extract the body of what is now diag_span_note_once
into a more general diag_once
that takes an enum argument to decide which method to call (span_note
or note
or warn
or &c.) on the diagnostic builder ... or are macros the way to go here? I think this is out-of-scope for this PR.)
14 | let _InappropriateCamelCasing = true; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-F bad-style` implies `-F non-snake-case` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep being surprised by the ordering here. What do you think about saying "-F non-snake-case
implied by -F bad-style
or something?
7e50b02
to
5bceb47
Compare
rebased and squashed previous work into 3 commits (down from 8); "implies" vs. "implied by" comment addressed in 5bceb47; prefer to defer the work to make implied-by-lint-group notes one-time |
@bors r+ |
📌 Commit 5bceb47 has been approved by |
@zackmdavis great! :) |
⌛ Testing commit 5bceb47 with merge 91d81d6... |
💔 Test failed - status-appveyor |
This little patch arises from the maelstrom of my purity born of pain. It's the pain of seeing rust-lang/rust#38103 in its perfect crystalline beauty waste away on page four of https://github.com/rust-lang/rust/pulls, waiting, ready, itching to land, dying with anticipation to bring the light of clearer lint group error messages to Rust users of all creeds and nations, only for its promise to be cruelly blocked by the fateful, hateful hand of circular dependency. For it is written in src/tools/cargotest/main.rs that the Cargo tests must pass before the PR can receive Appveyor's blessing, but the Cargo tests could not pass (because they depend on fine details of the output that the PR is meant to change), and the Cargo tests could not be changed (because updating the test expectation to match the proposed new compiler output, would fail with the current compiler). The Gordian knot is cut in the bowels of cargotest's very notion of comparison (of JSON objects) itself, by means of introducing a magic string literal `"{...}"`, which can server as a wildcard for any JSON sub-object. And so it will be for the children, and the children's children, and unto the 1.17.0 and 1.18.0 releases, that Cargo's build test expectations will faithfully expect the exact JSON output by Cargo itself, but the string literal `"{...}"` shall be a token upon the JSON output by rustc, and when I see `"{...}"`, I will pass over you, and the failure shall not be upon you. And this day shall be unto you for a memorial.
…ain, r=alexcrichton make build tests not depend on minutiae of rustc output This little patch arises from the maelstrom of my purity born of pain. It's the pain of seeing rust-lang/rust#38103 in its perfect crystalline beauty waste away on page four of https://github.com/rust-lang/rust/pulls, waiting, ready, itching to land, dying with anticipation to bring the light of clearer lint group error messages to Rust users of all creeds and nations, only for its promise to be cruelly blocked by the fateful, hateful hand of circular dependency. For it is written in src/tools/cargotest/main.rs that the Cargo tests must pass before the PR can receive Appveyor's blessing, but the Cargo tests could not pass (because they depend on fine details of the output that the PR is meant to change), and the Cargo tests could not be changed (because updating the test expectation to match the proposed new compiler output, would fail with the current compiler). The Gordian knot is cut in the bowels of cargotest's very notion of comparison (of JSON objects) itself, by means of introducing a magic string literal `"{...}"`, which can server as a wildcard for any JSON sub-object. And so it will be for the children, and the children's children, and unto the 1.17.0 and 1.18.0 releases, that Cargo's build test expectations will faithfully expect the exact JSON output by Cargo itself, but the string literal `"{...}"` shall be a token upon the JSON output by rustc, and when I see `"{...}"`, I will pass over you, and the failure shall not be upon you. And this day shall be unto you for a memorial. supersedes #3513 r? @alexcrichton
5bceb47
to
82e42d5
Compare
(force-pushed) @nikomatsakis Ready!! 🏃♀️ 🏁 💖 |
I almost want to ask if this can get p=1 just because it's been so long, but that's probably not fair |
@zackmdavis older PRs already get priority =) |
@bors r+ |
📌 Commit 82e42d5 has been approved by |
🔒 Merge conflict |
☔ The latest upstream changes (presumably #36320) made this pull request unmergeable. Please resolve the merge conflicts. |
Warning or error messages set via a lint group attribute (e.g. `#[deny(warnings)]`) should still make it clear which individual lint (by name) was triggered, similarly to how we include "on by default" language for default lints. This—and, while we're here, the existing "on by default" language—can be tucked into a note rather than cluttering the main error message. This occasions the slightest of refactorings (we now have to get the diagnostic-builder with the main message first, before matching on the lint source). This is in the matter of rust-lang#36846.
Previously, the note/message for the source of a lint being the command line unconditionally named the individual lint, even if the actual command specified a lint group (e.g., `-D warnings`); here, we take note of the actual command options so we can be more specific. This remains in the matter of rust-lang#36846.
As suggested by Niko Matsakis in review (rust-lang#38103 (comment)) regarding the endeavor prompted by rust-lang#36846.
82e42d5
to
72af42e
Compare
@bors: r=nikomatsakis |
📌 Commit 72af42e has been approved by |
⌛ Testing commit 72af42e with merge d7777ae... |
…ups_or_warnings_meta-lint_obscure_the_original_lint_name, r=nikomatsakis note individual lint name in messages set via lint group attribute ![lint_errors_resulting_from_lint_groups_obscure](https://cloud.githubusercontent.com/assets/1076988/20783614/c107d5c8-b749-11e6-85de-eada7f67c986.png) Resolves #36846. r? @jonathandturner ----- ***Update*** 16 December (new commits): ![lint_group_makeover_party](https://cloud.githubusercontent.com/assets/1076988/21284540/ff1ae2fc-c3d2-11e6-93be-d0689f5fa7a8.png)
☀️ Test successful - status-appveyor, status-travis |
This little patch arises from the maelstrom of my purity born of pain. It's the pain of seeing rust-lang/rust#38103 in its perfect crystalline beauty waste away on page four of https://github.com/rust-lang/rust/pulls, waiting, ready, itching to land, dying with anticipation to bring the light of clearer lint group error messages to Rust users of all creeds and nations, only for its promise to be cruelly blocked by the fateful, hateful hand of circular dependency. For it is written in src/tools/cargotest/main.rs that the Cargo tests must pass before the PR can receive Appveyor's blessing, but the Cargo tests could not pass (because they depend on fine details of the output that the PR is meant to change), and the Cargo tests could not be changed (because updating the test expectation to match the proposed new compiler output, would fail with the current compiler). The Gordian knot is cut in the bowels of cargotest's very notion of comparison (of JSON objects) itself, by means of introducing a magic string literal `"{...}"`, which can server as a wildcard for any JSON sub-object. And so it will be for the children, and the children's children, and unto the 1.17.0 and 1.18.0 releases, that Cargo's build test expectations will faithfully expect the exact JSON output by Cargo itself, but the string literal `"{...}"` shall be a token upon the JSON output by rustc, and when I see `"{...}"`, I will pass over you, and the failure shall not be upon you. And this day shall be unto you for a memorial.
From review discussion on rust-lang#38103 (rust-lang#38103 (comment)).
…the_first_time, r=eddyb make lint on-by-default/implied-by messages appear only once From review discussion on rust-lang#38103 (rust-lang#38103 (comment)). ![we_heard](https://user-images.githubusercontent.com/1076988/27564103-6284b78e-5a8a-11e7-9d35-f7f297ca9573.png) r? @nikomatsakis
Resolves #36846.
r? @jonathandturner
Update 16 December (new commits):