-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Cargo clippy #6759
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
Merged
Merged
Cargo clippy #6759
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a05afe4
WIP cargo-clippy command
Manishearth 30da772
fix clippy help text, check for clippy-driver
yaahc 4051b0c
fix: mark clippy-preview unstable, remove cruft
yaahc 9852087
fix: remove profile arg, exe check, add rustup check
yaahc 1f8c1c4
fix: remove dbg macro calls
yaahc e2f2c8d
fix: non rustup clippy missing error
yaahc 0389edc
impl centralized RustcWrapper logic
yaahc 116c053
totally unnecessary template type because its fun
yaahc d2ab686
fix not passing tests
yaahc bccc0ee
actually fix it so cargo fix kinda works with new wrapper stuff
yaahc 47c82f0
remove unnecessary rustc env for cargo fix
yaahc a23f811
fix comments
yaahc 842da62
Remove no longer needed fields in `BuildConfig`
alexcrichton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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()); | ||
yaahc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
let wrapper = util::process("clippy-driver"); | ||
compile_opts.build_config.rustc_wrapper = Some(wrapper); | ||
|
||
ops::compile(&ws, &compile_opts)?; | ||
Ok(()) | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.