]> git.lizzy.rs Git - rust.git/blobdiff - src/main.rs
Merge pull request #3085 from mikerite/revert-98dbce
[rust.git] / src / main.rs
index 5bdbaf1bc80e3818814bc5301665129bd44f33e2..cf26549774c22c269f6973265454cb739f947fc3 100644 (file)
@@ -1,7 +1,10 @@
 // error-pattern:yummy
 #![feature(box_syntax)]
 #![feature(rustc_private)]
-#![allow(unknown_lints, missing_docs_in_private_items)]
+#![feature(tool_lints)]
+#![allow(unknown_lints, clippy::missing_docs_in_private_items)]
+
+use rustc_tools_util::*;
 
 const CARGO_CLIPPY_HELP: &str = r#"Checks a package to catch common mistakes and improve your Rust code.
 
     #[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))]
 "#;
 
-#[allow(print_stdout)]
+#[allow(clippy::print_stdout)]
 fn show_help() {
     println!("{}", CARGO_CLIPPY_HELP);
 }
 
-#[allow(print_stdout)]
+#[allow(clippy::print_stdout)]
 fn show_version() {
-    println!("{}", env!("CARGO_PKG_VERSION"));
+    let version_info = rustc_tools_util::get_version_info!();
+    println!("{}", version_info);
 }
 
 pub fn main() {
@@ -44,6 +48,7 @@ pub fn main() {
         show_help();
         return;
     }
+
     if std::env::args().any(|a| a == "--version" || a == "-V") {
         show_version();
         return;
@@ -77,10 +82,29 @@ fn process<I>(mut old_args: I) -> Result<(), i32>
     if cfg!(windows) {
         path.set_extension("exe");
     }
+
+    let target_dir = std::env::var_os("CLIPPY_DOGFOOD")
+        .map(|_| {
+            std::env::var_os("CARGO_MANIFEST_DIR").map_or_else(
+                || {
+                    let mut fallback = std::ffi::OsString::new();
+                    fallback.push("clippy_dogfood");
+                    fallback
+                },
+                |d| {
+                    std::path::PathBuf::from(d)
+                        .join("target")
+                        .join("dogfood")
+                        .into_os_string()
+                },
+            )
+        }).map(|p| ("CARGO_TARGET_DIR", p));
+
     let exit_status = std::process::Command::new("cargo")
         .args(&args)
         .env("RUSTC_WRAPPER", path)
         .env("CLIPPY_ARGS", clippy_args)
+        .envs(target_dir)
         .spawn()
         .expect("could not run cargo")
         .wait()