Skip to content

Commit 0574d66

Browse files
committed
Auto merge of #4810 - Areredify:4716-fix, r=flip1995
clippy-driver display help on empty command line arguments changelog: fixes #4716, now displaying help if clippy-driver is run with no arguments.
2 parents 320b94d + 227dc44 commit 0574d66

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/driver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ pub fn main() {
268268

269269
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
270270
// We're invoking the compiler programmatically, so we ignore this/
271-
let wrapper_mode = Path::new(&orig_args[1]).file_stem() == Some("rustc".as_ref());
271+
let wrapper_mode = orig_args.get(1).map(Path::new).and_then(Path::file_stem) == Some("rustc".as_ref());
272272

273273
if wrapper_mode {
274274
// we still want to be able to invoke it normally though
275275
orig_args.remove(1);
276276
}
277277

278-
if !wrapper_mode && std::env::args().any(|a| a == "--help" || a == "-h") {
278+
if !wrapper_mode && (orig_args.iter().any(|a| a == "--help" || a == "-h") || orig_args.len() == 1) {
279279
display_help();
280280
exit(0);
281281
}

0 commit comments

Comments
 (0)