Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow showing backtraces from proc-macro panics #75050

Closed
Aaron1011 opened this issue Aug 2, 2020 · 0 comments · Fixed by #75082
Closed

Allow showing backtraces from proc-macro panics #75050

Aaron1011 opened this issue Aug 2, 2020 · 0 comments · Fixed by #75082
Labels
A-proc-macros Area: Procedural macros C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Aaron1011
Copy link
Member

Currently, rustc always hides the panic backtrace when a proc-macro panics:

// Hide the default panic output within `proc_macro` expansions.
// NB. the server can't do this because it may use a different libstd.
static HIDE_PANICS_DURING_EXPANSION: Once = Once::new();
HIDE_PANICS_DURING_EXPANSION.call_once(|| {
let prev = panic::take_hook();
panic::set_hook(Box::new(move |info| {
let hide = BridgeState::with(|state| match state {
BridgeState::NotConnected => false,
BridgeState::Connected(_) | BridgeState::InUse => true,
});
if !hide {
prev(info)
}
}));
});

It would be useful to able to set an environment variable or command-line argument to override this behavior.

@Aaron1011 Aaron1011 added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-proc-macros Area: Procedural macros labels Aug 2, 2020
@JohnTitor JohnTitor added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 6, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 31, 2020
…e, r=petrochenkov

Add `-Z proc-macro-backtrace` to allow showing proc-macro panics

Fixes rust-lang#75050

Previously, we would unconditionally suppress the panic hook during
proc-macro execution. This commit adds a new flag
`-Z proc-macro-backtrace`, which allows running the panic hook for
easier debugging.
@bors bors closed this as completed in d920866 Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants