]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #19964: pnkfelix/everybody-loops-pprint
authorAlex Crichton <alex@alexcrichton.com>
Mon, 22 Dec 2014 20:53:23 +0000 (12:53 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 22 Dec 2014 20:53:23 +0000 (12:53 -0800)
Conflicts:
src/librustc/session/config.rs
src/librustc_driver/lib.rs
src/librustc_driver/pretty.rs

1  2 
src/librustc/session/config.rs
src/librustc_driver/lib.rs
src/librustc_driver/pretty.rs

index e25c0be2ee5d0d6d98c19b2466eaf01f23c992ab,e3bd2648588d6d0b3a28520ceeb25156ae83eb59..86f0655a3ad664cf963ef4cc55e63c4a6b9f8b0d
@@@ -662,26 -741,26 +741,27 @@@ pub fn rustc_short_optgroups() -> Vec<R
                               library NAME. The optional KIND can be one of,
                               static, dylib, or framework. If omitted, dylib is
                               assumed.", "NAME[:KIND]"),
-         optmulti("", "crate-type", "Comma separated list of types of crates
+         opt::multi("", "crate-type", "Comma separated list of types of crates
                                      for the compiler to emit",
 -                 "[bin|lib|rlib|dylib|staticlib|dep-info]"),
 +                 "[bin|lib|rlib|dylib|staticlib]"),
-         optopt("", "crate-name", "Specify the name of the crate being built",
+         opt::opt("", "crate-name", "Specify the name of the crate being built",
                 "NAME"),
-         optmulti("", "emit", "Comma separated list of types of output for \
+         opt::multi("", "emit", "Comma separated list of types of output for \
                                the compiler to emit",
-         optmulti("", "print", "Comma separated list of compiler information to \
 +                 "[asm|llvm-bc|llvm-ir|obj|link|dep-info]"),
+                  "[asm|llvm-bc|llvm-ir|obj|link]"),
+         opt::multi("", "print", "Comma separated list of compiler information to \
                                 print on stdout",
                   "[crate-name|output-file-names|sysroot]"),
-         optflag("g",  "",  "Equivalent to -C debuginfo=2"),
-         optflag("O", "", "Equivalent to -C opt-level=2"),
-         optopt("o", "", "Write output to <filename>", "FILENAME"),
-         optopt("",  "out-dir", "Write output to compiler-chosen filename \
 -        opt::flag("g",  "",  "Equivalent to --debuginfo=2"),
 -        opt::flag("O", "", "Equivalent to --opt-level=2"),
++        opt::flag("g",  "",  "Equivalent to -C debuginfo=2"),
++        opt::flag("O", "", "Equivalent to -C opt-level=2"),
+         opt::opt("o", "", "Write output to <filename>", "FILENAME"),
+         opt::opt("",  "out-dir", "Write output to compiler-chosen filename \
                                  in <dir>", "DIR"),
-         optopt("", "explain", "Provide a detailed explanation of an error \
+         opt::opt("", "explain", "Provide a detailed explanation of an error \
                                 message", "OPT"),
-         optflag("", "test", "Build a test harness"),
-         optopt("", "target", "Target triple cpu-manufacturer-kernel[-os] \
+         opt::flag("", "test", "Build a test harness"),
+         opt::opt("", "target", "Target triple cpu-manufacturer-kernel[-os] \
                                to compile for (see chapter 3.4 of \
                                http://www.sourceware.org/autobook/
                                for details)",
index 1fb90d7860e42029603a07a6b97fb58c25dd2775,64f4d8bdc783f563b77686bf4524dcf9d10ac763..e2791aff14e49bcef25018d580f4a222263c7ee4
@@@ -370,10 -384,30 +387,30 @@@ pub fn handle_options(mut args: Vec<Str
      }
  
      let matches =
 -        match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) {
 +        match getopts::getopts(args[], config::optgroups()[]) {
              Ok(m) => m,
-             Err(f) => {
-                 early_error(f.to_string()[]);
+             Err(f_stable_attempt) => {
+                 // redo option parsing, including unstable options this time,
+                 // in anticipation that the mishandled option was one of the
+                 // unstable ones.
+                 let all_groups : Vec<getopts::OptGroup>
+                     = config::rustc_optgroups().into_iter().map(|x|x.opt_group).collect();
+                 match getopts::getopts(args.as_slice(), all_groups.as_slice()) {
+                     Ok(m_unstable) => {
+                         let r = m_unstable.opt_strs("Z");
+                         let include_unstable_options = r.iter().any(|x| *x == "unstable-options");
+                         if include_unstable_options {
+                             m_unstable
+                         } else {
+                             early_error(f_stable_attempt.to_string().as_slice());
+                         }
+                     }
+                     Err(_) => {
+                         // ignore the error from the unstable attempt; just
+                         // pass the error we got from the first try.
+                         early_error(f_stable_attempt.to_string().as_slice());
+                     }
+                 }
              }
          };
  
index 4b10ca92e705e7d532d6d319a5a39abc73b73b9f,3b6ad75243e229d6f105b566e6ed4f75ed7dac0c..9334c648a1f70b97a65d8d3d55ca8f69ef3cddc2
@@@ -59,22 -65,30 +65,30 @@@ pub fn parse_pretty(sess: &Session
      let mut split = name.splitn(1, '=');
      let first = split.next().unwrap();
      let opt_second = split.next();
-     let first = match first {
-         "normal"       => PpmSource(PpmNormal),
-         "expanded"     => PpmSource(PpmExpanded),
-         "typed"        => PpmSource(PpmTyped),
-         "expanded,identified" => PpmSource(PpmExpandedIdentified),
-         "expanded,hygiene" => PpmSource(PpmExpandedHygiene),
-         "identified"   => PpmSource(PpmIdentified),
-         "flowgraph"    => PpmFlowGraph,
+     let first = match (first, extended) {
+         ("normal", _)       => PpmSource(PpmNormal),
+         ("everybody_loops", true) => PpmSource(PpmEveryBodyLoops),
+         ("expanded", _)     => PpmSource(PpmExpanded),
+         ("typed", _)        => PpmSource(PpmTyped),
+         ("expanded,identified", _) => PpmSource(PpmExpandedIdentified),
+         ("expanded,hygiene", _) => PpmSource(PpmExpandedHygiene),
+         ("identified", _)   => PpmSource(PpmIdentified),
+         ("flowgraph", true)    => PpmFlowGraph,
          _ => {
-             sess.fatal(format!(
-                 "argument to `pretty` must be one of `normal`, \
-                  `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
-                  or `expanded,identified`; got {}", name)[]);
+             if extended {
+                 sess.fatal(format!(
+                     "argument to `xpretty` must be one of `normal`, \
+                      `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
+                      `expanded,identified`, or `everybody_loops`; got {}", name).as_slice());
+             } else {
+                 sess.fatal(format!(
+                     "argument to `pretty` must be one of `normal`, \
+                      `expanded`, `typed`, `identified`, \
+                      or `expanded,identified`; got {}", name).as_slice());
+             }
          }
      };
 -    let opt_second = opt_second.and_then::<UserIdentifiedItem, _>(from_str);
 +    let opt_second = opt_second.and_then(|s| s.parse::<UserIdentifiedItem>());
      (first, opt_second)
  }