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

note individual lint name in messages set via lint group attribute #38103

Conversation

zackmdavis
Copy link
Member

@zackmdavis zackmdavis commented Dec 1, 2016

lint_errors_resulting_from_lint_groups_obscure

Resolves #36846.

r? @jonathandturner


Update 16 December (new commits):
lint_group_makeover_party

@zackmdavis
Copy link
Member Author

@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)?

@sophiajt
Copy link
Contributor

@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.

@zackmdavis
Copy link
Member Author

I'm currently on vacation so

Oh, sorry to bother you! (I can only hope that my bad luck of accidentally bothering people on vacation does not become a trend.)

I'd move that new message to a note (without a span)

And presumably also the #[{}({})] on by default message on which it is based. Yes, I can do that (on the timescale of some days; I unfortunately don't have a development environment handy right now).

@zackmdavis
Copy link
Member Author

Updated:

  • 9603a5f moves the #[level(individual_lint)] on by default and #[level(lint_group)] implies #[level(individual_lint)] into a span-less note, rather than being part of the main lint message, as Jonathan suggests.
  • bb685b5 slightly broadens the scope of this pull request, but to a degree that I argue is entirely appropriate: it differentiates between an individual lint vs. a lint group having been set on the command line (analogously to the case of lints set via attributes, which inspired this endeavor)

@zackmdavis
Copy link
Member Author

  • and 7ba8b4d to update the UI tests because somehow make check weren't running them for me earlier (?!) although ./x.py test src/test/ui/ works

@zackmdavis
Copy link
Member Author

r? @brson

@rust-highfive rust-highfive assigned brson and unassigned sophiajt Dec 17, 2016
@aturon
Copy link
Member

aturon commented Dec 29, 2016

cc @nikomatsakis

@nikomatsakis
Copy link
Contributor

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?

@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned brson Dec 30, 2016
@nikomatsakis
Copy link
Contributor

oh, I missed the updated pics.

Copy link
Contributor

@nikomatsakis nikomatsakis left a 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)]
Copy link
Contributor

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.

@zackmdavis
Copy link
Member Author

@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)

Copy link
Contributor

@nikomatsakis nikomatsakis left a 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
Copy link
Contributor

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 :)

@@ -4,6 +4,7 @@ error: unused variable: `theOtherTwo`
20 | let theOtherTwo = 2;
| ^^^^^^^^^^^
|
= note: #[deny(warnings)] implies #[deny(unused_variables)]
Copy link
Contributor

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?

Copy link
Member Author

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`
Copy link
Contributor

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?

@zackmdavis zackmdavis force-pushed the lint_errors_resulting_from_lint_groups_or_warnings_meta-lint_obscure_the_original_lint_name branch from 7e50b02 to 5bceb47 Compare January 6, 2017 04:05
@zackmdavis
Copy link
Member Author

@nikomatsakis

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

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 6, 2017

📌 Commit 5bceb47 has been approved by nikomatsakis

@nikomatsakis
Copy link
Contributor

@zackmdavis great! :)

@bors
Copy link
Contributor

bors commented Jan 7, 2017

⌛ Testing commit 5bceb47 with merge 91d81d6...

@bors
Copy link
Contributor

bors commented Jan 7, 2017

💔 Test failed - status-appveyor

zackmdavis added a commit to zackmdavis/cargo that referenced this pull request Feb 2, 2017
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.
bors added a commit to rust-lang/cargo that referenced this pull request Feb 3, 2017
…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
@zackmdavis zackmdavis force-pushed the lint_errors_resulting_from_lint_groups_or_warnings_meta-lint_obscure_the_original_lint_name branch from 5bceb47 to 82e42d5 Compare February 3, 2017 07:13
@zackmdavis
Copy link
Member Author

(force-pushed) @nikomatsakis Ready!! 🏃‍♀️ 🏁 💖

@zackmdavis
Copy link
Member Author

I almost want to ask if this can get p=1 just because it's been so long, but that's probably not fair

@nikomatsakis
Copy link
Contributor

@zackmdavis older PRs already get priority =)

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Feb 3, 2017

📌 Commit 82e42d5 has been approved by nikomatsakis

@zackmdavis
Copy link
Member Author

👀 glances at queue

auuugh 82e42d5 is going to collide with #36320's b7f1d7a

😿 😭 💀 sobs in existential despair

@bors
Copy link
Contributor

bors commented Feb 4, 2017

🔒 Merge conflict

@bors
Copy link
Contributor

bors commented Feb 4, 2017

☔ 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.
@zackmdavis zackmdavis force-pushed the lint_errors_resulting_from_lint_groups_or_warnings_meta-lint_obscure_the_original_lint_name branch from 82e42d5 to 72af42e Compare February 4, 2017 18:52
@alexcrichton
Copy link
Member

@bors: r=nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 4, 2017

📌 Commit 72af42e has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 5, 2017

⌛ Testing commit 72af42e with merge d7777ae...

bors added a commit that referenced this pull request Feb 5, 2017
…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)
@bors
Copy link
Contributor

bors commented Feb 5, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing d7777ae to master...

@bors bors merged commit 72af42e into rust-lang:master Feb 5, 2017
alexcrichton pushed a commit to alexcrichton/cargo that referenced this pull request Mar 3, 2017
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.
zackmdavis added a commit to zackmdavis/rust that referenced this pull request Jun 26, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Jun 29, 2017
@zackmdavis zackmdavis deleted the lint_errors_resulting_from_lint_groups_or_warnings_meta-lint_obscure_the_original_lint_name branch January 13, 2018 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants