mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
back in tip top shape
This commit is contained in:
parent
6fb65f1e4f
commit
8b1f599dfd
@ -78,14 +78,6 @@ pub fn cli() -> App {
|
|||||||
.help("Get fix suggestions from clippy instead of rustc")
|
.help("Get fix suggestions from clippy instead of rustc")
|
||||||
.hidden(true),
|
.hidden(true),
|
||||||
)
|
)
|
||||||
.arg(
|
|
||||||
Arg::with_name("clippy-arg")
|
|
||||||
.long("clippy-arg")
|
|
||||||
.help("Args to pass through to clippy, implies --clippy")
|
|
||||||
.hidden(true)
|
|
||||||
.multiple(true)
|
|
||||||
.number_of_values(1),
|
|
||||||
)
|
|
||||||
.after_help(
|
.after_help(
|
||||||
"\
|
"\
|
||||||
This Cargo subcommand will automatically take rustc's suggestions from
|
This Cargo subcommand will automatically take rustc's suggestions from
|
||||||
@ -139,7 +131,11 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
|||||||
// code as we can.
|
// code as we can.
|
||||||
let mut opts = args.compile_options(config, mode, Some(&ws))?;
|
let mut opts = args.compile_options(config, mode, Some(&ws))?;
|
||||||
|
|
||||||
let clippy_args = args.values_of_lossy("clippy-args");
|
let clippy_args = args
|
||||||
|
.value_of("clippy") // always yields None
|
||||||
|
.map(|s| s.split(' ').map(|s| s.to_string()).collect())
|
||||||
|
.or_else(|| Some(vec![]));
|
||||||
|
|
||||||
let use_clippy = args.is_present("clippy") || clippy_args.is_some();
|
let use_clippy = args.is_present("clippy") || clippy_args.is_some();
|
||||||
|
|
||||||
if use_clippy && !config.cli_unstable().unstable_options {
|
if use_clippy && !config.cli_unstable().unstable_options {
|
||||||
@ -171,7 +167,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
|||||||
allow_no_vcs: args.is_present("allow-no-vcs"),
|
allow_no_vcs: args.is_present("allow-no-vcs"),
|
||||||
allow_staged: args.is_present("allow-staged"),
|
allow_staged: args.is_present("allow-staged"),
|
||||||
broken_code: args.is_present("broken-code"),
|
broken_code: args.is_present("broken-code"),
|
||||||
use_clippy,
|
|
||||||
clippy_args,
|
clippy_args,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
@ -1790,6 +1790,6 @@ impl Drop for PackageCacheLock<'_> {
|
|||||||
/// Allows override of the path via `CARGO_CLIPPY_DRIVER` env variable
|
/// Allows override of the path via `CARGO_CLIPPY_DRIVER` env variable
|
||||||
pub fn clippy_driver() -> PathBuf {
|
pub fn clippy_driver() -> PathBuf {
|
||||||
env::var("CARGO_CLIPPY_DRIVER")
|
env::var("CARGO_CLIPPY_DRIVER")
|
||||||
.unwrap_or_else(|_| "clippy_driver".into())
|
.unwrap_or_else(|_| "clippy-driver".into())
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::support::{clippy_is_available, is_nightly, process, project};
|
use crate::support::{clippy_is_available, is_nightly, project};
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn clippy() {
|
fn clippy() {
|
||||||
|
@ -3,7 +3,7 @@ use std::fs::File;
|
|||||||
use git2;
|
use git2;
|
||||||
|
|
||||||
use crate::support::git;
|
use crate::support::git;
|
||||||
use crate::support::{basic_manifest, project};
|
use crate::support::{basic_manifest, clippy_is_available, is_nightly, project};
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
@ -1318,8 +1318,17 @@ fn fix_with_clippy() {
|
|||||||
|
|
||||||
p.cargo("fix -Zunstable-options --clippy --allow-no-vcs")
|
p.cargo("fix -Zunstable-options --clippy --allow-no-vcs")
|
||||||
.masquerade_as_nightly_cargo()
|
.masquerade_as_nightly_cargo()
|
||||||
.diff_lines("", "", false)
|
|
||||||
.with_stderr(stderr)
|
.with_stderr(stderr)
|
||||||
.with_stdout("")
|
.with_stdout("")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
p.read_file("src/lib.rs"),
|
||||||
|
"
|
||||||
|
pub fn foo() {
|
||||||
|
let mut v = Vec::<String>::new();
|
||||||
|
let _ = v.iter_mut().filter(|a| a.is_empty());
|
||||||
|
}
|
||||||
|
"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user