]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/flags.rs
Various minor/cosmetic improvements to code
[rust.git] / src / bootstrap / flags.rs
index 2084b8bdb65ffb859bb74195c6ec764ad4069afc..c49da8fc734892042d4f70c03e2e8a39600461bb 100644 (file)
@@ -93,8 +93,7 @@ fn default() -> Subcommand {
 impl Flags {
     pub fn parse(args: &[String]) -> Flags {
         let mut extra_help = String::new();
-        let mut subcommand_help = format!(
-            "\
+        let mut subcommand_help = String::from("\
 Usage: x.py <subcommand> [options] [<paths>...]
 
 Subcommands:
@@ -122,11 +121,11 @@ pub fn parse(args: &[String]) -> Flags {
         opts.optopt("", "on-fail", "command to run on failure", "CMD");
         opts.optflag("", "dry-run", "dry run; don't build anything");
         opts.optopt("", "stage",
-            "stage to build (indicates compiler to use/test, e.g. stage 0 uses the \
+            "stage to build (indicates compiler to use/test, e.g., stage 0 uses the \
              bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)",
             "N");
         opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling \
-            (pass multiple times to keep e.g. both stages 0 and 1)", "N");
+            (pass multiple times to keep e.g., both stages 0 and 1)", "N");
         opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
         opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
         opts.optflag("h", "help", "print this help message");
@@ -365,8 +364,8 @@ pub fn parse(args: &[String]) -> Flags {
         }
 
         let cmd = match subcommand.as_str() {
-            "build" => Subcommand::Build { paths: paths },
-            "check" => Subcommand::Check { paths: paths },
+            "build" => Subcommand::Build { paths },
+            "check" => Subcommand::Check { paths },
             "test" => Subcommand::Test {
                 paths,
                 bless: matches.opt_present("bless"),
@@ -386,9 +385,9 @@ pub fn parse(args: &[String]) -> Flags {
                 paths,
                 test_args: matches.opt_strs("test-args"),
             },
-            "doc" => Subcommand::Doc { paths: paths },
+            "doc" => Subcommand::Doc { paths },
             "clean" => {
-                if paths.len() > 0 {
+                if !paths.is_empty() {
                     println!("\nclean does not take a path argument\n");
                     usage(1, &opts, &subcommand_help, &extra_help);
                 }
@@ -413,11 +412,11 @@ pub fn parse(args: &[String]) -> Flags {
             keep_stage: matches.opt_strs("keep-stage")
                 .into_iter().map(|j| j.parse().unwrap())
                 .collect(),
-            host: split(matches.opt_strs("host"))
+            host: split(&matches.opt_strs("host"))
                 .into_iter()
                 .map(|x| INTERNER.intern_string(x))
                 .collect::<Vec<_>>(),
-            target: split(matches.opt_strs("target"))
+            target: split(&matches.opt_strs("target"))
                 .into_iter()
                 .map(|x| INTERNER.intern_string(x))
                 .collect::<Vec<_>>(),
@@ -425,7 +424,7 @@ pub fn parse(args: &[String]) -> Flags {
             jobs: matches.opt_str("jobs").map(|j| j.parse().unwrap()),
             cmd,
             incremental: matches.opt_present("incremental"),
-            exclude: split(matches.opt_strs("exclude"))
+            exclude: split(&matches.opt_strs("exclude"))
                 .into_iter()
                 .map(|p| p.into())
                 .collect::<Vec<_>>(),
@@ -488,7 +487,7 @@ pub fn compare_mode(&self) -> Option<&str> {
     }
 }
 
-fn split(s: Vec<String>) -> Vec<String> {
+fn split(s: &[String]) -> Vec<String> {
     s.iter()
         .flat_map(|s| s.split(','))
         .map(|s| s.to_string())