]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #29296 - zazdxscf:compiletest_noargs_show_help, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 26 Oct 2015 00:19:51 +0000 (00:19 +0000)
committerbors <bors@rust-lang.org>
Mon, 26 Oct 2015 00:19:51 +0000 (00:19 +0000)
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.

src/compiletest/compiletest.rs

index 3b9eec12ba3e9109734b165935812a3cf6e91d21..dfd99a9beae96cc5ac80615ea61c181f0dd79057 100644 (file)
@@ -90,7 +90,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
           optflag("h", "help", "show this message"));
 
     let (argv0, args_) = args.split_first().unwrap();
-    if args[1] == "-h" || args[1] == "--help" {
+    if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
         let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
         println!("{}", getopts::usage(&message, &groups));
         println!("");