about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2014-12-27 19:43:14 +0900
committerSeo Sanghyeon <sanxiyn@gmail.com>2014-12-27 19:43:14 +0900
commitd4da75892219ee8fed5fc8801a37ffe82520083d (patch)
treef199e349c9efb1f6db56083b1e41924aa88efbeb
parent9554794d22840b5077aa4605fa49a587d3e018b6 (diff)
downloadrust-d4da75892219ee8fed5fc8801a37ffe82520083d.tar.gz
rust-d4da75892219ee8fed5fc8801a37ffe82520083d.zip
Use -Z unstable-options for span debugger
-rw-r--r--src/librustc/session/config.rs6
-rw-r--r--src/librustc/session/mod.rs3
-rw-r--r--src/librustc_driver/driver.rs4
-rw-r--r--src/librustc_driver/lib.rs6
4 files changed, 11 insertions, 8 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 6629f6620d4..61676407991 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -105,6 +105,7 @@ pub struct Options {
     pub prints: Vec<PrintRequest>,
     pub cg: CodegenOptions,
     pub color: ColorConfig,
+    pub show_span: Option<String>,
     pub externs: HashMap<String, Vec<String>>,
     pub crate_name: Option<String>,
     /// An optional name to use as the crate for std during std injection,
@@ -211,6 +212,7 @@ pub fn basic_options() -> Options {
         prints: Vec::new(),
         cg: basic_codegen_options(),
         color: Auto,
+        show_span: None,
         externs: HashMap::new(),
         crate_name: None,
         alt_std_name: None,
@@ -259,7 +261,6 @@ debugging_opts! {
         BORROWCK_STATS,
         NO_LANDING_PADS,
         DEBUG_LLVM,
-        SHOW_SPAN,
         COUNT_TYPE_SIZES,
         META_STATS,
         GC,
@@ -298,7 +299,6 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
      ("no-landing-pads", "omit landing pads for unwinding",
       NO_LANDING_PADS),
      ("debug-llvm", "enable debug output from LLVM", DEBUG_LLVM),
-     ("show-span", "show spans for compiler debugging", SHOW_SPAN),
      ("count-type-sizes", "count the sizes of aggregate types",
       COUNT_TYPE_SIZES),
      ("meta-stats", "gather metadata statistics", META_STATS),
@@ -820,6 +820,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
                       `flowgraph=<nodeid>` (graphviz formatted flowgraph for node), or
                       `everybody_loops` (all function bodies replaced with `loop {}`).",
                      "TYPE"),
+        opt::opt_u("", "show-span", "Show spans for compiler debugging", "expr|pat|ty"),
         opt::flagopt("", "dep-info",
                  "Output dependency info to <filename> after compiling, \
                   in a format suitable for use by Makefiles", "FILENAME"),
@@ -1122,6 +1123,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         prints: prints,
         cg: cg,
         color: color,
+        show_span: None,
         externs: externs,
         crate_name: crate_name,
         alt_std_name: None,
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index c120ac53b78..9a6275401ad 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -199,9 +199,6 @@ impl Session {
     pub fn no_landing_pads(&self) -> bool {
         self.debugging_opt(config::NO_LANDING_PADS)
     }
-    pub fn show_span(&self) -> bool {
-        self.debugging_opt(config::SHOW_SPAN)
-    }
     pub fn unstable_options(&self) -> bool {
         self.debugging_opt(config::UNSTABLE_OPTIONS)
     }
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 20bb9c2f4fd..69e439c1bbe 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -138,7 +138,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
         krate.encode(&mut json).unwrap();
     }
 
-    if sess.show_span() {
+    if sess.opts.show_span.is_some() {
         syntax::show_span::run(sess.diagnostic(), &krate);
     }
 
@@ -542,7 +542,7 @@ pub fn stop_after_phase_1(sess: &Session) -> bool {
         debug!("invoked with --parse-only, returning early from compile_input");
         return true;
     }
-    if sess.show_span() {
+    if sess.opts.show_span.is_some() {
         return true;
     }
     return sess.opts.debugging_opts & config::AST_JSON_NOEXPAND != 0;
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index 5cd87a1e4c0..98d2b5eb67d 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -132,7 +132,7 @@ fn run_compiler(args: &[String]) {
         _ => early_error("multiple input filenames provided")
     };
 
-    let sess = build_session(sopts, input_file_path, descriptions);
+    let mut sess = build_session(sopts, input_file_path, descriptions);
     let cfg = config::build_configuration(&sess);
     if print_crate_info(&sess, Some(&input), &odir, &ofile) {
         return
@@ -160,6 +160,10 @@ fn run_compiler(args: &[String]) {
         None => {/* continue */ }
     }
 
+    if sess.unstable_options() {
+        sess.opts.show_span = matches.opt_str("show-span");
+    }
+
     let r = matches.opt_strs("Z");
     if r.contains(&("ls".to_string())) {
         match input {