Skip to content

Commit 351efd5

Browse files
author
Emanuel Czirai
committed
compiletest: show usage/help when passed no args
instead of this panic: ``` thread '<main>' panicked at 'index out of bounds: the len is 1 but the index is 1', src/libcollections/vec.rs:1110 ``` It still panics, just like `-h` does, so it should be okay in this regard.
1 parent 04e497c commit 351efd5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compiletest/compiletest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
9292
optflag("h", "help", "show this message"));
9393

9494
let (argv0, args_) = args.split_first().unwrap();
95-
if args[1] == "-h" || args[1] == "--help" {
95+
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
9696
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
9797
println!("{}", getopts::usage(&message, &groups));
9898
println!("");

0 commit comments

Comments
 (0)