diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2019-07-14 21:17:37 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2019-09-17 21:23:33 +0100 |
| commit | 3c2fd1a72d2e8cc80b354b4d2dd7931a7afe1b02 (patch) | |
| tree | 7dfa2a7fc81ea002b8c6fef446a1d8989fdb3c11 /src/libsyntax_pos | |
| parent | b4ef99f4a61aa14f860c37eecbd04791005effc2 (diff) | |
Print syntax contexts and marks when printing hygiene information
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/hygiene.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index f0e7344c1b9..8142d44b3f6 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -343,6 +343,38 @@ pub fn update_dollar_crate_names(mut get_name: impl FnMut(SyntaxContext) -> Symb })) } +pub fn debug_hygiene_data(verbose: bool) -> String { + HygieneData::with(|data| { + if verbose { + format!("{:#?}", data) + } else { + let mut s = String::from(""); + s.push_str("Expansions:"); + data.expn_data.iter().enumerate().for_each(|(id, expn_info)| { + let expn_info = expn_info.as_ref().expect("no expansion data for an expansion ID"); + s.push_str(&format!( + "\n{}: parent: {:?}, call_site_ctxt: {:?}, kind: {:?}", + id, + expn_info.parent, + expn_info.call_site.ctxt(), + expn_info.kind, + )); + }); + s.push_str("\n\nSyntaxContexts:"); + data.syntax_context_data.iter().enumerate().for_each(|(id, ctxt)| { + s.push_str(&format!( + "\n#{}: parent: {:?}, outer_mark: ({:?}, {:?})", + id, + ctxt.parent, + ctxt.outer_expn, + ctxt.outer_transparency, + )); + }); + s + } + }) +} + impl SyntaxContext { #[inline] pub const fn root() -> Self { |
