xtask: replace "lint" command by a simply cargo alias

This strips the run_clippy implementation out of xtask and replaces it by
a simple "cargo lint" alias which runs clippy with the corresponding flags.

Unfortunately  I could not name the alias "clippy" because that would lead to infinite recursion.
This commit is contained in:
Matthias Krüger 2021-03-14 13:34:28 +01:00
parent a8a7fa8347
commit 5008e56821
3 changed files with 1 additions and 22 deletions

View file

@ -3,6 +3,7 @@ xtask = "run --package xtask --bin xtask --"
install-ra = "run --package xtask --bin xtask -- install" # for backwards compat install-ra = "run --package xtask --bin xtask -- install" # for backwards compat
tq = "test -- -q" tq = "test -- -q"
qt = "tq" qt = "tq"
lint = "clippy --all-targets -- -Aclippy::collapsible_if -Aclippy::needless_pass_by_value -Aclippy::nonminimal_bool -Aclippy::redundant_pattern_matching --cap-lints warn"
[target.x86_64-pc-windows-msvc] [target.x86_64-pc-windows-msvc]
linker = "rust-lld" linker = "rust-lld"

View file

@ -27,7 +27,6 @@ xflags::xflags! {
optional --jemalloc optional --jemalloc
} }
cmd lint {}
cmd fuzz-tests {} cmd fuzz-tests {}
cmd pre-cache {} cmd pre-cache {}
@ -63,7 +62,6 @@ pub struct Xtask {
pub enum XtaskCmd { pub enum XtaskCmd {
Help(Help), Help(Help),
Install(Install), Install(Install),
Lint(Lint),
FuzzTests(FuzzTests), FuzzTests(FuzzTests),
PreCache(PreCache), PreCache(PreCache),
Release(Release), Release(Release),

View file

@ -40,7 +40,6 @@ fn main() -> Result<()> {
return Ok(()); return Ok(());
} }
flags::XtaskCmd::Install(cmd) => cmd.run(), flags::XtaskCmd::Install(cmd) => cmd.run(),
flags::XtaskCmd::Lint(_) => run_clippy(),
flags::XtaskCmd::FuzzTests(_) => run_fuzzer(), flags::XtaskCmd::FuzzTests(_) => run_fuzzer(),
flags::XtaskCmd::PreCache(cmd) => cmd.run(), flags::XtaskCmd::PreCache(cmd) => cmd.run(),
flags::XtaskCmd::Release(cmd) => cmd.run(), flags::XtaskCmd::Release(cmd) => cmd.run(),
@ -95,25 +94,6 @@ fn ensure_rustfmt() -> Result<()> {
Ok(()) Ok(())
} }
fn run_clippy() -> Result<()> {
if cmd!("cargo clippy --version").read().is_err() {
bail!(
"Failed run cargo clippy. \
Please run `rustup component add clippy` to install it.",
)
}
let allowed_lints = "
-A clippy::collapsible_if
-A clippy::needless_pass_by_value
-A clippy::nonminimal_bool
-A clippy::redundant_pattern_matching
"
.split_ascii_whitespace();
cmd!("cargo clippy --all-features --all-targets -- {allowed_lints...}").run()?;
Ok(())
}
fn run_fuzzer() -> Result<()> { fn run_fuzzer() -> Result<()> {
let _d = pushd("./crates/syntax")?; let _d = pushd("./crates/syntax")?;
let _e = pushenv("RUSTUP_TOOLCHAIN", "nightly"); let _e = pushenv("RUSTUP_TOOLCHAIN", "nightly");