Skip to content

Commit d14109e

Browse files
author
Thomas Jespersen
committed
Add "trace-macros" as a compiler flag
Fixes #22619
1 parent e6a8124 commit d14109e

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/librustc/session/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
606606
"Force overflow checks on or off"),
607607
force_dropflag_checks: Option<bool> = (None, parse_opt_bool,
608608
"Force drop flag checks on or off"),
609+
trace_macros: bool = (false, parse_bool,
610+
"For every macro invocation, print its name and arguments"),
609611
}
610612

611613
pub fn default_lib_output() -> CrateType {
@@ -667,7 +669,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
667669
Ok(t) => t,
668670
Err(e) => {
669671
sp.handler().fatal(&format!("Error loading target specification: {}", e));
670-
}
672+
}
671673
};
672674

673675
let (int_type, uint_type) = match &target.target_pointer_width[..] {

src/librustc_driver/driver.rs

+1
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
482482
crate_name: crate_name.to_string(),
483483
features: Some(&features),
484484
recursion_limit: sess.recursion_limit.get(),
485+
trace_mac: sess.opt.debugging_opts.trace_macros,
485486
};
486487
let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
487488
cfg,

src/libsyntax/ext/base.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ pub struct ExtCtxt<'a> {
554554
pub use_std: bool,
555555

556556
pub mod_path: Vec<ast::Ident> ,
557-
pub trace_mac: bool,
558557
pub exported_macros: Vec<ast::MacroDef>,
559558

560559
pub syntax_env: SyntaxEnv,
@@ -572,7 +571,6 @@ impl<'a> ExtCtxt<'a> {
572571
mod_path: Vec::new(),
573572
ecfg: ecfg,
574573
use_std: true,
575-
trace_mac: false,
576574
exported_macros: Vec::new(),
577575
syntax_env: env,
578576
recursion_count: 0,
@@ -732,10 +730,10 @@ impl<'a> ExtCtxt<'a> {
732730
self.parse_sess.span_diagnostic.handler().bug(msg);
733731
}
734732
pub fn trace_macros(&self) -> bool {
735-
self.trace_mac
733+
self.ecfg.trace_mac
736734
}
737735
pub fn set_trace_macros(&mut self, x: bool) {
738-
self.trace_mac = x
736+
self.ecfg.trace_mac = x
739737
}
740738
pub fn ident_of(&self, st: &str) -> ast::Ident {
741739
str_to_ident(st)

src/libsyntax/ext/expand.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,7 @@ pub struct ExpansionConfig<'feat> {
14061406
pub crate_name: String,
14071407
pub features: Option<&'feat Features>,
14081408
pub recursion_limit: usize,
1409+
pub trace_mac: bool,
14091410
}
14101411

14111412
macro_rules! feature_tests {
@@ -1427,6 +1428,7 @@ impl<'feat> ExpansionConfig<'feat> {
14271428
crate_name: crate_name,
14281429
features: None,
14291430
recursion_limit: 64,
1431+
trace_mac: false,
14301432
}
14311433
}
14321434

0 commit comments

Comments
 (0)