Skip to content

Commit 4f7a260

Browse files
author
Michael Wright
committed
driver: Improve check for rustc arg
The rustc arg might not be exactly "rustc". It may be any path to a rustc executable (especially if the RUSTC environment variable is set when executing cargo). Rather check that it is a path with 'rustc' file stem.
1 parent ed38d9c commit 4f7a260

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use rustc_driver::{self, driver::CompileController, Compilation};
88
use rustc_plugin;
9+
use std::path::Path;
910
use std::process::{exit, Command};
1011

1112
#[allow(clippy::print_stdout)]
@@ -47,7 +48,7 @@ pub fn main() {
4748
if orig_args.len() <= 1 {
4849
std::process::exit(1);
4950
}
50-
if orig_args[1] == "rustc" {
51+
if Path::new(&orig_args[1]).file_stem() == Some("rustc".as_ref()) {
5152
// we still want to be able to invoke it normally though
5253
orig_args.remove(1);
5354
}

0 commit comments

Comments
 (0)