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

Rustc does not parse tool name for lints controlled by the command line #86628

Closed
eholk opened this issue Jun 25, 2021 · 3 comments · Fixed by #86639
Closed

Rustc does not parse tool name for lints controlled by the command line #86628

eholk opened this issue Jun 25, 2021 · 3 comments · Fixed by #86639
Assignees
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eholk
Copy link
Contributor

eholk commented Jun 25, 2021

Problem

This came up during the discussion of rust-lang/cargo#5034. Lints can be broken into rustc builtin lints, and lints supplied by a tool such as clippy. For clippy lints, they are prefixed by clippy::. The idea is that external lints are supposed to be ignored if the tool is not active. This works for lints controlled through attributes, such as #![allow(clippy::foo)].

Unfortunately the same thing doesn't work when allowing the lint through the command line, doing rustc -A clippy::foo.

Steps

  1. Run rustc -A clippy::foo test.rs

Possible Solution(s)

The problem is at:

let db = match self.check_lint_name(lint_name, None) {

There is a hard-coded None passed in as the tool name in check_lint_name.

@eholk eholk added the C-bug Category: This is a bug. label Jun 25, 2021
@eholk
Copy link
Contributor Author

eholk commented Jun 25, 2021

I'm working on a fix at https://github.com/eholk/rust/tree/lint-tool. The fix there so far is doing an ad-hoc parsing, although it seems like it'd be better to reuse the rustc parser for paths, since that is how the attribute version is parsed. I'm going to clean it up some more, make sure to add tests, etc. before filing an PR.

@eholk
Copy link
Contributor Author

eholk commented Jun 25, 2021

@rustbot claim

@inquisitivecrystal
Copy link
Contributor

inquisitivecrystal commented Jun 28, 2021

@rustbot label A-lint T-compiler

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. labels Jun 28, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 7, 2021
Support lint tool names in rustc command line options

When rustc is running without a lint tool such as clippy enabled, options for lints such as `clippy::foo` are meant to be ignored. This was already working for those specified by attrs, such as `#![allow(clippy::foo)]`, but this did not work for command line arguments like `-A clippy::foo`. This PR fixes that issue.

Note that we discovered this issue while discussing rust-lang/cargo#5034.

Fixes rust-lang#86628.
@bors bors closed this as completed in c2d3f5f Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants