about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThomas Jespersen <laumann.thomas@gmail.com>2015-04-14 15:36:38 +0200
committerThomas Jespersen <laumann.thomas@gmail.com>2015-04-14 15:36:38 +0200
commitd14109ec7e90f42a7cb966415b96094b146d3706 (patch)
tree649be4562b01b23607c486eabe99879fa6da3549
parente6a812402828f0f11b0de7a7e0c08c1d85a437f1 (diff)
downloadrust-d14109ec7e90f42a7cb966415b96094b146d3706.tar.gz
rust-d14109ec7e90f42a7cb966415b96094b146d3706.zip
Add "trace-macros" as a compiler flag
Fixes #22619
-rw-r--r--src/librustc/session/config.rs4
-rw-r--r--src/librustc_driver/driver.rs1
-rw-r--r--src/libsyntax/ext/base.rs6
-rw-r--r--src/libsyntax/ext/expand.rs2
4 files changed, 8 insertions, 5 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index a7d608d2c87..47049969f0c 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -606,6 +606,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
           "Force overflow checks on or off"),
     force_dropflag_checks: Option<bool> = (None, parse_opt_bool,
           "Force drop flag checks on or off"),
+    trace_macros: bool = (false, parse_bool,
+          "For every macro invocation, print its name and arguments"),
 }
 
 pub fn default_lib_output() -> CrateType {
@@ -667,7 +669,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
         Ok(t) => t,
         Err(e) => {
             sp.handler().fatal(&format!("Error loading target specification: {}", e));
-    }
+        }
     };
 
     let (int_type, uint_type) = match &target.target_pointer_width[..] {
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index e310798b20a..f7815a58d06 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -482,6 +482,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
                 crate_name: crate_name.to_string(),
                 features: Some(&features),
                 recursion_limit: sess.recursion_limit.get(),
+                trace_mac: sess.opt.debugging_opts.trace_macros,
             };
             let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
                                               cfg,
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 9994fad3e31..9c2837d71ff 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -554,7 +554,6 @@ pub struct ExtCtxt<'a> {
     pub use_std: bool,
 
     pub mod_path: Vec<ast::Ident> ,
-    pub trace_mac: bool,
     pub exported_macros: Vec<ast::MacroDef>,
 
     pub syntax_env: SyntaxEnv,
@@ -572,7 +571,6 @@ impl<'a> ExtCtxt<'a> {
             mod_path: Vec::new(),
             ecfg: ecfg,
             use_std: true,
-            trace_mac: false,
             exported_macros: Vec::new(),
             syntax_env: env,
             recursion_count: 0,
@@ -732,10 +730,10 @@ impl<'a> ExtCtxt<'a> {
         self.parse_sess.span_diagnostic.handler().bug(msg);
     }
     pub fn trace_macros(&self) -> bool {
-        self.trace_mac
+        self.ecfg.trace_mac
     }
     pub fn set_trace_macros(&mut self, x: bool) {
-        self.trace_mac = x
+        self.ecfg.trace_mac = x
     }
     pub fn ident_of(&self, st: &str) -> ast::Ident {
         str_to_ident(st)
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index b65798b8a49..c8ff08eeb94 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -1406,6 +1406,7 @@ pub struct ExpansionConfig<'feat> {
     pub crate_name: String,
     pub features: Option<&'feat Features>,
     pub recursion_limit: usize,
+    pub trace_mac: bool,
 }
 
 macro_rules! feature_tests {
@@ -1427,6 +1428,7 @@ impl<'feat> ExpansionConfig<'feat> {
             crate_name: crate_name,
             features: None,
             recursion_limit: 64,
+            trace_mac: false,
         }
     }