]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #14234 : alexcrichton/rust/rollup, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 15 May 2014 22:56:54 +0000 (15:56 -0700)
committerbors <bors@rust-lang.org>
Thu, 15 May 2014 22:56:54 +0000 (15:56 -0700)
Let's try this again!

1  2 
src/librustc/driver/config.rs
src/librustc/driver/mod.rs

index e929c64e58ad44d5496cd0d12573b5538cd8fe8e,cd9e50157f2e2d3c4f46643c4426d95807e3e886..da573a014d000e827324350a5cb507bb0dc9fc3c
@@@ -27,7 -27,6 +27,7 @@@ use syntax::ast
  use syntax::ast::{IntTy, UintTy};
  use syntax::attr;
  use syntax::attr::AttrMetaMethods;
 +use syntax::diagnostic::{ColorConfig, Auto, Always, Never};
  use syntax::parse;
  use syntax::parse::token::InternedString;
  
@@@ -93,7 -92,6 +93,7 @@@ pub struct Options 
      /// Crate id-related things to maybe print. It's (crate_id, crate_name, crate_file_name).
      pub print_metas: (bool, bool, bool),
      pub cg: CodegenOptions,
 +    pub color: ColorConfig,
  }
  
  /// Some reasonable defaults
@@@ -117,7 -115,6 +117,7 @@@ pub fn basic_options() -> Options 
          write_dependency_info: (false, None),
          print_metas: (false, false, false),
          cg: basic_codegen_options(),
 +        color: Auto,
      }
  }
  
@@@ -519,12 -516,13 +519,13 @@@ pub fn optgroups() -> Vec<getopts::OptG
          optopt( "",  "out-dir", "Write output to compiler-chosen filename in <dir>", "DIR"),
          optflag("", "parse-only", "Parse only; do not compile, assemble, or link"),
          optflagopt("", "pretty",
-                  "Pretty-print the input instead of compiling;
-                   valid types are: normal (un-annotated source),
-                   expanded (crates expanded),
-                   typed (crates expanded, with type annotations),
-                   or identified (fully parenthesized,
-                   AST nodes and blocks with IDs)", "TYPE"),
+                    "Pretty-print the input instead of compiling;
+                    valid types are: `normal` (un-annotated source),
+                    `expanded` (crates expanded),
+                    `typed` (crates expanded, with type annotations),
+                    `expanded,identified` (fully parenthesized, AST nodes with IDs), or
+                    `flowgraph=<nodeid>` (graphviz formatted flowgraph for node)",
+                  "TYPE"),
          optflagopt("", "dep-info",
                   "Output dependency info to <filename> after compiling, \
                    in a format suitable for use by Makefiles", "FILENAME"),
          optmulti("F", "forbid", "Set lint forbidden", "OPT"),
          optmulti("C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
          optmulti("Z", "", "Set internal debugging options", "FLAG"),
 -        optflag( "v", "version", "Print version info and exit")
 +        optflag("v", "version", "Print version info and exit"),
 +        optopt("", "color", "Configure coloring of output:
 +            auto   = colorize, if output goes to a tty (default);
 +            always = always colorize output;
 +            never  = never colorize output", "auto|always|never")
      )
  }
  
@@@ -714,18 -708,6 +715,18 @@@ pub fn build_session_options(matches: &
                         matches.opt_present("crate-file-name"));
      let cg = build_codegen_options(matches);
  
 +    let color = match matches.opt_str("color").as_ref().map(|s| s.as_slice()) {
 +        Some("auto")   => Auto,
 +        Some("always") => Always,
 +        Some("never")  => Never,
 +
 +        None => Auto,
 +
 +        Some(arg) => early_error(format!(
 +            "argument for --color must be auto, always or never (instead was `{}`)",
 +            arg))
 +    };
 +
      Options {
          crate_types: crate_types,
          gc: gc,
          write_dependency_info: write_dependency_info,
          print_metas: print_metas,
          cg: cg,
 +        color: color
      }
  }
  
index b355d474bd572a9438b5766a34f08d8e21b68214,5a1e27a52560d701369dbd56da04070d957e82bf..f32a8ec7cd735ca035fe8fbccc060d794b5c2164
@@@ -285,20 -285,32 +285,32 @@@ pub enum PpMode 
      PpmExpanded,
      PpmTyped,
      PpmIdentified,
-     PpmExpandedIdentified
+     PpmExpandedIdentified,
+     PpmFlowGraph(ast::NodeId),
  }
  
  pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
-     match name {
-         "normal" => PpmNormal,
-         "expanded" => PpmExpanded,
-         "typed" => PpmTyped,
-         "expanded,identified" => PpmExpandedIdentified,
-         "identified" => PpmIdentified,
+     let mut split = name.splitn('=', 1);
+     let first = split.next().unwrap();
+     let opt_second = split.next();
+     match (opt_second, first) {
+         (None, "normal")       => PpmNormal,
+         (None, "expanded")     => PpmExpanded,
+         (None, "typed")        => PpmTyped,
+         (None, "expanded,identified") => PpmExpandedIdentified,
+         (None, "identified")   => PpmIdentified,
+         (Some(s), "flowgraph") => {
+              match from_str(s) {
+                  Some(id) => PpmFlowGraph(id),
+                  None => sess.fatal(format!("`pretty flowgraph=<nodeid>` needs \
+                                              an integer <nodeid>; got {}", s))
+              }
+         }
          _ => {
-             sess.fatal("argument to `pretty` must be one of `normal`, \
-                         `expanded`, `typed`, `identified`, \
-                         or `expanded,identified`");
+             sess.fatal(format!(
+                 "argument to `pretty` must be one of `normal`, \
+                  `expanded`, `flowgraph=<nodeid>`, `typed`, `identified`, \
+                  or `expanded,identified`; got {}", name));
          }
      }
  }
@@@ -323,7 -335,7 +335,7 @@@ fn parse_crate_attrs(sess: &Session, in
  }
  
  pub fn early_error(msg: &str) -> ! {
 -    let mut emitter = diagnostic::EmitterWriter::stderr();
 +    let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto);
      emitter.emit(None, msg, diagnostic::Fatal);
      fail!(diagnostic::FatalError);
  }
@@@ -368,7 -380,7 +380,7 @@@ fn monitor(f: proc():Send) 
          Err(value) => {
              // Task failed without emitting a fatal diagnostic
              if !value.is::<diagnostic::FatalError>() {
 -                let mut emitter = diagnostic::EmitterWriter::stderr();
 +                let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto);
  
                  // a .span_bug or .bug call has already printed what
                  // it wants to print.