Skip to content

Commit a733556

Browse files
committed
clippy-driver: pass all args after "--rustc" to rustc
1 parent 3d0f0e3 commit a733556

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/driver.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ pub fn main() {
299299
rustc_driver::catch_fatal_errors(move || {
300300
let mut orig_args: Vec<String> = env::args().collect();
301301

302+
// make "clippy-driver --rustc" work like a subcommand that passes further args to "rustc"
303+
// for example `clippy-driver --rustc --version` will print the rustc version that clippy-driver
304+
// uses
305+
if let Some(pos) = orig_args.iter().position(|arg| arg == "--rustc") {
306+
orig_args.remove(pos);
307+
orig_args[0] = "rustc".to_string();
308+
return rustc_driver::run_compiler(&orig_args, &mut DefaultCallbacks, None, None);
309+
}
310+
302311
if orig_args.iter().any(|a| a == "--version" || a == "-V") {
303312
let version_info = rustc_tools_util::get_version_info!();
304313
println!("{}", version_info);

0 commit comments

Comments
 (0)