I want to disable multiple lints globally i.e. cargo clippy – -A clippy::lint_name1, lint_name2, lint_name3, lint_name4, lint_name5 … is it possible. If not then how could I do that. to check my own project with clippy
At the beginning of you
#![allow( first_lint_name, second_lint_name, third_lint_name, )]
Although untested, I guess
clippy lints should work too when prefixing the lint names with
#![allow( clippy::first_lint_name, clippy::second_lint_name, clippy::third_lint_name, )]
thanks Yandros, but if i don’t want to change my source code (of my project), then is there any other way…
As far as I read the documentation, you’ll either need to change your sources or create a script which contains all the lints you want to disable in the
cargo clippy command:
I have following error when made changes as per your directions.
error: an inner attribute is not permitted in this context --> src/main.rs:22:3 | 22 | #![allow( | ^ | = note: inner attributes, like
#![no_std], annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like
#[test], annotate the item following them. warning: unknown lint:
cast_ref_to_mut --> src/main.rs:23:3 | 23 | cast_ref_to_mut, | ^^^^^^^^^^^^^^^ | = note: #[warn(unknown_lints)] on by default
sorry , i placed your code before main that’s why it gives error… however when I placed it in the beginning of my file (main.rs) then there is no error during cargo clippy. BUT… still not successful to disable my llints…
Just a shot in the dark but have you tried to reload your editor?
- Tested on the Playground (you can run clippy on the top right)
hmm, you pretty much answered yourself at the beginning, that’s why I didn’t suggest that:
cargo clippy -- -A clippy::trivially_copy_pass_by_ref -A clippy::unreadable_literal
or, with a Unix shell
RUSTFLAGS="-A clippy::trivially_copy_pass_by_ref -A clippy::unreadable_literal" cargo clippy
This means you can just run
cargo clippyafter having run:
On a Unix shell:
export RUSTFLAGS="-A clippy::trivially_copy_pass_by_ref -A clippy::unreadable_literal"
cmd.exe, it should be something like:
set RUSTFLAGS="-A clippy::trivially_copy_pass_by_ref -A clippy::unreadable_literal"
thanks a lot … cargo clippy – -A clippy::trivially_copy_pass_by_ref -A clippy::unreadable_literal
it works for me …
I know you said you don’t want to change your source code, but encoding the list of lints you do / don’t expect to be used in the source files ensures that anyone else who runs clippy on your code gets the right results. (And saves you a lot of typing.)
yes i know … But i am not developing my project. I just want to test someone else project. However, I did changed src/main.rs file with following code in start of main.rs file
)]… it should be good but not working for me… I am not sure why…