Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement tool_lints #2977
Conversation
flip1995
referenced this pull request
Jul 30, 2018
Merged
Make the tool_lints actually usable #52851
flip1995
reviewed
Jul 30, 2018
| #[macro_use] | ||
| extern crate serde_derive; | ||
|
|
||
| /// Test that we do not lint for unused underscores in a `MacroAttribute` | ||
| /// expansion | ||
| #[deny(used_underscore_binding)] | ||
| #[deny(clippy::used_underscore_binding)] | ||
| #[derive(Deserialize)] |
This comment has been minimized.
This comment has been minimized.
flip1995
Jul 30, 2018
•
Author
Collaborator
FIXMEFIXED: I get a weird error here:
error: proc-macro derive panicked
--> tests/run-pass/used_underscore_binding_macro.rs:7:10
|
7 | #[derive(Deserialize)]
| ^^^^^^^^^^^
|
= help: message: called `Result::unwrap()` on an `Err` value: "failed to parse derive input: \"/// Test that we do not lint for unused underscores in a `MacroAttribute`\\n/// expansion\\n#[deny(clippy::used_underscore_binding)]\\nstruct MacroAttributesTest {\\n _foo: u32,\\n}\""That's because somehow syn fails to parse the new tool_lints...
See serde and syn
This comment has been minimized.
This comment has been minimized.
oli-obk
Aug 1, 2018
Collaborator
we just need to update our dependency version requirement to the most recent one, then it'll work
oli-obk
reviewed
Jul 30, 2018
| @@ -2,7 +2,7 @@ | |||
| //! floating-point literal expressions. | |||
|
|
|||
| use rustc::lint::*; | |||
| use rustc::{declare_lint, lint_array}; | |||
| use rustc::{declare_tool_lint, lint_array}; | |||
This comment has been minimized.
This comment has been minimized.
oli-obk
Jul 30, 2018
Collaborator
Why do we even need this imported here? Shouldn't declare_clippy_lint be enough? Maybe we need to import it in the expansion of declare_clippy_lint
This comment has been minimized.
This comment has been minimized.
flip1995
Jul 30, 2018
Author
Collaborator
Because we use the declare_clippy_lint! which expands to ...declare_(tool_)lint!....
Maybe we need to import it in the expansion of declare_clippy_lint
That would probably be cleaner.
This comment has been minimized.
This comment has been minimized.
flip1995
Jul 30, 2018
Author
Collaborator
Or not: If we use declare_clippy_lint multiple times in one file we would get multiple use rustc::declare_tool_lint. And that happens pretty often.
This comment has been minimized.
This comment has been minimized.
oli-obk
Jul 30, 2018
Collaborator
can we just call rustc::declare_tool_lint! instead of importing it?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
flip1995
Jul 30, 2018
Author
Collaborator
If we use rustc::declare_tool_lint! in the macro_rule, we have to import use rustc in each file, or else:
error[E0433]: failed to resolve. Use of undeclared type or module `rustc`
--> clippy_lints/src/lib.rs:24:9
|
24 | rustc::declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
| ^^^^^ Use of undeclared type or module `rustc`
|
::: clippy_lints/src/bit_mask.rs:87:1
This comment has been minimized.
This comment has been minimized.
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this pull request
Jul 31, 2018
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this pull request
Aug 1, 2018
This comment has been minimized.
This comment has been minimized.
|
Does rustc allow you to use the old way of specifying these? I feel like we should have a week or two where rustc will match both |
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this pull request
Aug 1, 2018
This comment has been minimized.
This comment has been minimized.
|
You can still use the I could have added a double check for My solution to this would be to write a lint for occurrences of We also need a lint for ...I should list this in #2955 |
flip1995
force-pushed the
flip1995:tool_lints
branch
from
699f686
to
a3c31c4
Aug 1, 2018
This comment has been minimized.
This comment has been minimized.
|
Whoops my update script for the ui-tests slipped a little bit there. I'll reduce the number of lines changed a bit |
This comment has been minimized.
This comment has been minimized.
|
@flip1995 I meant that we can introduce such a warning into the rustc codebase itself, yeah? "If you use a lint that shares a name with a tool lint, here's a warning" |
This comment has been minimized.
This comment has been minimized.
|
for tool lint groups we can temporarily make the registration API ask for a deprecated fallback name We're the only consumers of this API, we can make changes like this |
flip1995
force-pushed the
flip1995:tool_lints
branch
from
5501d43
to
a124642
Aug 1, 2018
This comment has been minimized.
This comment has been minimized.
|
I think I finished the ui-tests update. I looked through every |
This comment has been minimized.
This comment has been minimized.
|
Yes, we could lint in the rustc codebase for lints that are from tools aka Clippy. But this could only detect unscoped lints from Clippy if we compile the code with Clippy in the first place. In that case also Clippy can lint for usage of the unscoped lint names. (I'm sorry, if I'm missing the point of doing this in the compiler. Doing the ui-tests update was pretty
That makes sense to me. |
This comment has been minimized.
This comment has been minimized.
Yes, this is only if you're running with clippy.
Doing this in the compiler lets us have the lint allow still work. Otherwise the clippy user will get the deprecation warnings, as well as tons of unknown lint warnings and tons of silenced clippy warnings that get unsilenced. |
This comment has been minimized.
This comment has been minimized.
|
Ahh, I got it now! Thanks for the clarification! |
flip1995
force-pushed the
flip1995:tool_lints
branch
from
3c97aae
to
4b79a5e
Aug 1, 2018
This comment has been minimized.
This comment has been minimized.
|
Travis should be green with the next nightly now. Do not merge this until the backwards compatibility is implemented in rustc. |
flip1995
closed this
Aug 2, 2018
flip1995
reopened this
Aug 2, 2018
phansch
closed this
Aug 6, 2018
phansch
reopened this
Aug 6, 2018
This comment has been minimized.
This comment has been minimized.
|
@flip1995 looks like some conflicts appeared |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I currently working on the backwards compatibility of the tool_lints. After that I'll have to make adjustments here anyway. Also it will need a rebase. But I want to do this all at once. |
This comment has been minimized.
This comment has been minimized.
|
ping @flip1995 any update on the backwards compat? |
This comment has been minimized.
This comment has been minimized.
|
I will open a PR in rust-lang/rust by the end of this week |
This comment has been minimized.
This comment has been minimized.
|
It's almost finished, just need to prettify it a little. Sorry for the delay. |
flip1995
force-pushed the
flip1995:tool_lints
branch
2 times, most recently
from
a3aab0b
to
cbd178b
Aug 28, 2018
flip1995
force-pushed the
flip1995:tool_lints
branch
3 times, most recently
from
846fb4b
to
b4d31f4
Aug 28, 2018
flip1995
referenced this pull request
Aug 28, 2018
Merged
Backwards compatibility for tool/clippy lints #53762
flip1995
added some commits
Jul 28, 2018
Manishearth
force-pushed the
flip1995:tool_lints
branch
from
4f1e3f4
to
daa4f0a
Aug 29, 2018
This comment has been minimized.
This comment has been minimized.
|
Rebased and pushed, and pinned daa4f0a to the tool-lints branch on this repo. When rust-lang/rust#53762 lands, please ensure that that commit gets into clippy master via git merge (NOT rebase) |
Manishearth
added a commit
to flip1995/rust
that referenced
this pull request
Aug 29, 2018
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Aug 30, 2018
flip1995
changed the title
WIP: Implement tool_lints
Implement tool_lints
Aug 30, 2018
Manishearth
added some commits
Aug 31, 2018
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Sep 1, 2018
Manishearth
merged commit c81d70e
into
rust-lang:master
Sep 1, 2018
This comment has been minimized.
This comment has been minimized.
|
rust-lang/rust#53762 landed. I'll do a local test run and catch any merge issues that may have happened |
flip1995 commentedJul 30, 2018
•
edited
cc #2955
Waiting for rust-lang/rust#52851
The (ui-)tests need to be adapted to the tool lints, by renaming every
clippy_linttoclippy::clippy_lint. Also#![feature(tool_lints)]needs to be added to the tests, untiltool_lintsare stable.