From 31ecd2a124ff9c466c9661862aa0a0ad2d48d1a1 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 10 Oct 2020 01:11:01 -0400 Subject: [PATCH] Allow using clippy with either beta or nightly Not 100% sure this will _always_ work, but it works currently. --- src/bootstrap/builder.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a2759b205d75f..532949e47a17a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -866,20 +866,22 @@ impl<'a> Builder<'a> { cargo.arg("-Zunstable-options"); // Explicitly does *not* set `--cfg=bootstrap`, since we're using a nightly clippy. let host_version = Command::new("rustc").arg("--version").output().map_err(|_| ()); - if let Err(_) = host_version.and_then(|output| { + let output = host_version.and_then(|output| { if output.status.success() - && t!(std::str::from_utf8(&output.stdout)).contains("nightly") { Ok(output) } else { Err(()) } - }) { + }).unwrap_or_else(|_| { eprintln!( - "error: `x.py clippy` requires a nightly host `rustc` toolchain with the `clippy` component" + "error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component" ); - eprintln!("help: try `rustup default nightly`"); + eprintln!("help: try `rustup component add clippy`"); std::process::exit(1); + }); + if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") { + rustflags.arg("--cfg=bootstrap"); } } else { rustflags.arg("--cfg=bootstrap");