Skip to content

Commit

Permalink
Add a way to get mismatch backtrace using cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 3, 2024
1 parent 3eb1857 commit cb94081
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: RUSTFLAGS='-Z allow-features=' cargo test
run: cargo test
env:
RUSTFLAGS: -Z allow-features= ${{env.RUSTFLAGS}}
RUSTFLAGS: -Z allow-features= --cfg procmacro2_backtrace ${{env.RUSTFLAGS}}

minimal:
name: Minimal versions
Expand Down
10 changes: 9 additions & 1 deletion src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ impl LexError {

#[cold]
fn mismatch(line: u32) -> ! {
panic!("compiler/fallback mismatch #{}", line)
#[cfg(procmacro2_backtrace)]
{
let backtrace = std::backtrace::Backtrace::force_capture();
panic!("compiler/fallback mismatch #{}\n\n{}", line, backtrace)
}
#[cfg(not(procmacro2_backtrace))]
{
panic!("compiler/fallback mismatch #{}", line)
}
}

impl DeferredTokenStream {
Expand Down

0 comments on commit cb94081

Please sign in to comment.