mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
fmt
This commit is contained in:
parent
b3030e1b90
commit
0397e46ea5
21
src/main.rs
21
src/main.rs
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
use rustc_tools_util::VersionInfo;
|
use rustc_tools_util::VersionInfo;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::ffi::OsString;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{self, Command};
|
use std::process::{self, Command};
|
||||||
use std::ffi::OsString;
|
|
||||||
|
|
||||||
const CARGO_CLIPPY_HELP: &str = r#"Checks a package to catch common mistakes and improve your Rust code.
|
const CARGO_CLIPPY_HELP: &str = r#"Checks a package to catch common mistakes and improve your Rust code.
|
||||||
|
|
||||||
@ -60,11 +60,10 @@ struct ClippyCmd {
|
|||||||
unstable_options: bool,
|
unstable_options: bool,
|
||||||
cargo_subcommand: &'static str,
|
cargo_subcommand: &'static str,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
clippy_args: String
|
clippy_args: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClippyCmd
|
impl ClippyCmd {
|
||||||
{
|
|
||||||
fn new<I>(mut old_args: I) -> Self
|
fn new<I>(mut old_args: I) -> Self
|
||||||
where
|
where
|
||||||
I: Iterator<Item = String>,
|
I: Iterator<Item = String>,
|
||||||
@ -98,10 +97,7 @@ impl ClippyCmd
|
|||||||
args.insert(0, "+nightly".to_string());
|
args.insert(0, "+nightly".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let clippy_args: String =
|
let clippy_args: String = old_args.map(|arg| format!("{}__CLIPPY_HACKERY__", arg)).collect();
|
||||||
old_args
|
|
||||||
.map(|arg| format!("{}__CLIPPY_HACKERY__", arg))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
ClippyCmd {
|
ClippyCmd {
|
||||||
unstable_options,
|
unstable_options,
|
||||||
@ -160,7 +156,6 @@ impl ClippyCmd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn process<I>(old_args: I) -> Result<(), i32>
|
fn process<I>(old_args: I) -> Result<(), i32>
|
||||||
where
|
where
|
||||||
I: Iterator<Item = String>,
|
I: Iterator<Item = String>,
|
||||||
@ -195,7 +190,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fix_unstable() {
|
fn fix_unstable() {
|
||||||
let args = "cargo clippy --fix -Zunstable-options".split_whitespace().map(ToString::to_string);
|
let args = "cargo clippy --fix -Zunstable-options"
|
||||||
|
.split_whitespace()
|
||||||
|
.map(ToString::to_string);
|
||||||
let cmd = ClippyCmd::new(args);
|
let cmd = ClippyCmd::new(args);
|
||||||
assert_eq!("fix", cmd.cargo_subcommand);
|
assert_eq!("fix", cmd.cargo_subcommand);
|
||||||
assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env());
|
assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env());
|
||||||
@ -212,7 +209,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_unstable() {
|
fn check_unstable() {
|
||||||
let args = "cargo clippy -Zunstable-options".split_whitespace().map(ToString::to_string);
|
let args = "cargo clippy -Zunstable-options"
|
||||||
|
.split_whitespace()
|
||||||
|
.map(ToString::to_string);
|
||||||
let cmd = ClippyCmd::new(args);
|
let cmd = ClippyCmd::new(args);
|
||||||
assert_eq!("check", cmd.cargo_subcommand);
|
assert_eq!("check", cmd.cargo_subcommand);
|
||||||
assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env());
|
assert_eq!("RUSTC_WORKSPACE_WRAPPER", cmd.path_env());
|
||||||
|
Loading…
Reference in New Issue
Block a user