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

-A --allow should take precedence over -D --deny in CLI #4778

Closed
tyranron opened this issue Nov 6, 2019 · 1 comment · Fixed by rust-lang/rust#67885
Closed

-A --allow should take precedence over -D --deny in CLI #4778

tyranron opened this issue Nov 6, 2019 · 1 comment · Fixed by rust-lang/rust#67885

Comments

@tyranron
Copy link

tyranron commented Nov 6, 2019

I have a weird issue, where I cannot disable a single lint via command line.

Running the following

cargo +beta clippy --all -- -D clippy::pedantic -D warnings \
	                    -A clippy::must_use_candidate

still results in lint being applied:

error: this method could have a `#[must_use]` attribute
  --> crates/tracerr/src/trace.rs:50:5
   |
50 |     fn deref(&self) -> &Vec<Frame> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn deref(&self) -> &Vec<Frame>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate

Changing the order of the CLI arguments doesn't affect anything.

While disabling lint via !#[allow(clippy::must_use_candidate)] attribute in crate's root works OK, as expected.

I suggest that things listed in allow (no matter where) as a white list should take precedence over deny as a black list.

❯ cargo +beta clippy -- --version
clippy 0.0.212 (c8e3cfbd 2019-10-28)
@flip1995
Copy link
Member

flip1995 commented Nov 6, 2019

The logic of handling command line lint flags is in rustc, not in Clippy:
https://github.com/rust-lang/rust/blob/61a551b4939ec1d5596e585351038b8fbd0124ba/src/librustc/lint/levels.rs#L68-L75

To check if this is a Clippy issue: What is the result of rustc -D unused -A dead_code main.rs?


Answer:

$ rustc -Dunused -Adead_code src/main.rs
error: function is never used: `foo`
 --> src/main.rs:5:1
  |
5 | fn foo() {}
  | ^^^^^^^^
  |
  = note: `-D dead-code` implied by `-D unused`

error: aborting due to previous error

So yeah this has to be addressed in rustc, not in Clippy. I keep this issue open, because, this behavior would also be nice to have from the Clippy perspective.

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 a pull request may close this issue.

2 participants