From 227dc44aee7f9dd8ac85fce15943dad5c43422ea Mon Sep 17 00:00:00 2001 From: Mikhail Babenko Date: Wed, 13 Nov 2019 04:27:43 +0300 Subject: [PATCH] display help on empty command line arguments --- src/driver.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index d2f81066ddea..9995c3fb1cec 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -268,14 +268,14 @@ pub fn main() { // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. // We're invoking the compiler programmatically, so we ignore this/ - let wrapper_mode = Path::new(&orig_args[1]).file_stem() == Some("rustc".as_ref()); + let wrapper_mode = orig_args.get(1).map(Path::new).and_then(Path::file_stem) == Some("rustc".as_ref()); if wrapper_mode { // we still want to be able to invoke it normally though orig_args.remove(1); } - if !wrapper_mode && std::env::args().any(|a| a == "--help" || a == "-h") { + if !wrapper_mode && (orig_args.iter().any(|a| a == "--help" || a == "-h") || orig_args.len() == 1) { display_help(); exit(0); }