]> git.lizzy.rs Git - rust.git/blobdiff - src/librust/rust.rs
librust: Stop rust tool from crashing on macos.
[rust.git] / src / librust / rust.rs
index bc97ef0e8ca4d9541334773323127dfc25f1f05c..746b75292315aecc52766e843ad45371eccc98cc 100644 (file)
@@ -60,7 +60,13 @@ struct Command<'self> {
     usage_full: UsageSource<'self>,
 }
 
-static COMMANDS: &'static [Command<'static>] = &[
+static NUM_OF_COMMANDS: uint = 7;
+
+// FIXME(#7617): should just be &'static [Command<'static>]
+// but mac os doesn't seem to like that and tries to loop
+// past the end of COMMANDS in usage thus passing garbage
+// to str::repeat and eventually malloc and crashing.
+static COMMANDS: [Command<'static>, .. NUM_OF_COMMANDS] = [
     Command{
         cmd: "build",
         action: CallMain("rustc", rustc::main),
@@ -132,13 +138,13 @@ fn print_usage(command_string: ~str) -> ValidUsage {
         match find_cmd(command_string) {
             Some(command) => {
                 match command.action {
-                    CallMain(prog, _) => io::println(fmt!(
+                    CallMain(prog, _) => printfln!(
                         "The %s command is an alias for the %s program.",
-                        command.cmd, prog)),
+                        command.cmd, prog),
                     _       => ()
                 }
                 match command.usage_full {
-                    UsgStr(msg) => io::println(fmt!("%s\n", msg)),
+                    UsgStr(msg) => printfln!("%s\n", msg),
                     UsgCall(f)  => f(),
                 }
                 Valid(0)
@@ -211,8 +217,7 @@ fn usage() {
 
     for COMMANDS.iter().advance |command| {
         let padding = " ".repeat(INDENT - command.cmd.len());
-        io::println(fmt!("    %s%s%s",
-                         command.cmd, padding, command.usage_line));
+        printfln!("    %s%s%s", command.cmd, padding, command.usage_line);
     }
 
     io::print(