diff --git a/src/driver.rs b/src/driver.rs index 097b796e785b..9988105bbf34 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -292,6 +292,21 @@ fn toolchain_path(home: Option, toolchain: Option) -> Option) { + // make "clippy-driver rustc --version" print rustc --version output + if orig_args.len() > 2 && orig_args[1..2] == ["rustc".to_string(), "--version".to_string()] { + let rustc_version = Command::new("rustc") + .arg("--version") + .arg("--verbose") + .output() + .ok() + .and_then(|out| String::from_utf8(out.stdout).ok()) + .unwrap(); + print!("{}", rustc_version); + exit(0); + } +} + pub fn main() { rustc_driver::init_rustc_env_logger(); lazy_static::initialize(&ICE_HOOK); @@ -299,6 +314,8 @@ pub fn main() { rustc_driver::catch_fatal_errors(move || { let mut orig_args: Vec = env::args().collect(); + print_rustc_version(&orig_args); + if orig_args.iter().any(|a| a == "--version" || a == "-V") { let version_info = rustc_tools_util::get_version_info!(); println!("{}", version_info);