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

Implementation of tool lints. #52018

Merged
merged 4 commits into from
Jul 6, 2018
Merged

Implementation of tool lints. #52018

merged 4 commits into from
Jul 6, 2018

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Jul 3, 2018

Tracking issue: #44690

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2018
@flip1995
Copy link
Member Author

flip1995 commented Jul 3, 2018

r? @petrochenkov

@@ -308,6 +315,10 @@ impl MetaItem {
pub fn is_meta_item_list(&self) -> bool {
self.meta_item_list().is_some()
}

pub fn is_scoped(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this return an option of the first segment and then use that segment in the is_known_lint_tool function (and maybe to use a more fine-grained span for the diagnostic)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good idea!

@bors
Copy link
Contributor

bors commented Jul 3, 2018

☔ The latest upstream changes (presumably #52014) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 4, 2018

@bors r+

lgtm

@bors
Copy link
Contributor

bors commented Jul 4, 2018

📌 Commit c394900 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 4, 2018
@petrochenkov petrochenkov assigned oli-obk and unassigned petrochenkov Jul 5, 2018
@bors
Copy link
Contributor

bors commented Jul 6, 2018

⌛ Testing commit c394900 with merge 3ea16c3...

bors added a commit that referenced this pull request Jul 6, 2018
Implementation of tool lints.

Tracking issue: #44690
@bors
Copy link
Contributor

bors commented Jul 6, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 3ea16c3 to master...

@bors bors merged commit c394900 into rust-lang:master Jul 6, 2018
@flip1995 flip1995 deleted the rfc2103 branch July 7, 2018 12:50
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Aug 1, 2018
Make the tool_lints actually usable

cc rust-lang#44690

Necessary for rust-lang/rust-clippy#2955 and rust-lang/rust-clippy#2977

This PR makes it possible for lint tools (at the moment only for Clippy) to implement the `tool_lints`, like it was documented in rust-lang#52018.

Because the `declare_lint` macro is pretty cluttered right now, there was not really a good way to add the `tool_name` as an additional argument of the macro. That's why I chose to introduce the new `declare_tool_lint` macro.

The switch from `&str` to `String` in the `lint_groups` `FxHashMap` is because I got weird error messages in the `check_lint_name` method. And the `by_name` field of the `LintStore` also uses `String`.

### What comes with this PR:

If this PR lands and Clippy switches to the `tool_lints`, the currently used methods
```rust
#[cfg_attr(feature = "cargo-clippy", allow(clippy_lint))]
#[allow(unknown_lints, clippy_lint)]
```
to `allow`/`warn`/`deny`/`forbid` Clippy lints, won't have any effects anymore, but also won't produce a warning. That is because the name of `clippy_lint` will then be `clippy::clippy_lint`. (Maybe we can add a clippy lint to search for `cfg_attr` appearances with the `cargo-clippy` feature?)

r? @oli-obk
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Aug 1, 2018
Make the tool_lints actually usable

cc rust-lang#44690

Necessary for rust-lang/rust-clippy#2955 and rust-lang/rust-clippy#2977

This PR makes it possible for lint tools (at the moment only for Clippy) to implement the `tool_lints`, like it was documented in rust-lang#52018.

Because the `declare_lint` macro is pretty cluttered right now, there was not really a good way to add the `tool_name` as an additional argument of the macro. That's why I chose to introduce the new `declare_tool_lint` macro.

The switch from `&str` to `String` in the `lint_groups` `FxHashMap` is because I got weird error messages in the `check_lint_name` method. And the `by_name` field of the `LintStore` also uses `String`.

### What comes with this PR:

If this PR lands and Clippy switches to the `tool_lints`, the currently used methods
```rust
#[cfg_attr(feature = "cargo-clippy", allow(clippy_lint))]
#[allow(unknown_lints, clippy_lint)]
```
to `allow`/`warn`/`deny`/`forbid` Clippy lints, won't have any effects anymore, but also won't produce a warning. That is because the name of `clippy_lint` will then be `clippy::clippy_lint`. (Maybe we can add a clippy lint to search for `cfg_attr` appearances with the `cargo-clippy` feature?)

r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants