-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #6759 - yaahallo:cargo-clippy, r=alexcrichton
Cargo clippy resolves rust-lang/rust-clippy#3837
- Loading branch information
Showing
13 changed files
with
129 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use crate::command_prelude::*; | ||
|
||
use cargo::ops; | ||
use cargo::util; | ||
|
||
pub fn cli() -> App { | ||
subcommand("clippy-preview") | ||
.about("Checks a package to catch common mistakes and improve your Rust code.") | ||
.arg_package_spec( | ||
"Package(s) to check", | ||
"Check all packages in the workspace", | ||
"Exclude packages from the check", | ||
) | ||
.arg_jobs() | ||
.arg_targets_all( | ||
"Check only this package's library", | ||
"Check only the specified binary", | ||
"Check all binaries", | ||
"Check only the specified example", | ||
"Check all examples", | ||
"Check only the specified test target", | ||
"Check all tests", | ||
"Check only the specified bench target", | ||
"Check all benches", | ||
"Check all targets", | ||
) | ||
.arg_release("Check artifacts in release mode, with optimizations") | ||
.arg_features() | ||
.arg_target_triple("Check for the target triple") | ||
.arg_target_dir() | ||
.arg_manifest_path() | ||
.arg_message_format() | ||
.after_help( | ||
"\ | ||
If the `--package` argument is given, then SPEC is a package ID specification | ||
which indicates which package should be built. If it is not given, then the | ||
current package is built. For more information on SPEC and its format, see the | ||
`cargo help pkgid` command. | ||
All packages in the workspace are checked if the `--all` flag is supplied. The | ||
`--all` flag is automatically assumed for a virtual manifest. | ||
Note that `--exclude` has to be specified in conjunction with the `--all` flag. | ||
To allow or deny a lint from the command line you can use `cargo clippy --` | ||
with: | ||
-W --warn OPT Set lint warnings | ||
-A --allow OPT Set lint allowed | ||
-D --deny OPT Set lint denied | ||
-F --forbid OPT Set lint forbidden | ||
You can use tool lints to allow or deny lints from your code, eg.: | ||
#[allow(clippy::needless_lifetimes)] | ||
", | ||
) | ||
} | ||
|
||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { | ||
let ws = args.workspace(config)?; | ||
|
||
let mode = CompileMode::Check { test: false }; | ||
let mut compile_opts = args.compile_options(config, mode, Some(&ws))?; | ||
|
||
if !config.cli_unstable().unstable_options { | ||
return Err(failure::format_err!( | ||
"`clippy-preview` is unstable, pass `-Z unstable-options` to enable it" | ||
) | ||
.into()); | ||
} | ||
|
||
let wrapper = util::process("clippy-driver"); | ||
compile_opts.build_config.rustc_wrapper = Some(wrapper); | ||
|
||
ops::compile(&ws, &compile_opts)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.