Skip to content

Commit cb94081

Browse files
committed
Add a way to get mismatch backtrace using cfg
1 parent 3eb1857 commit cb94081

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
- name: RUSTFLAGS='-Z allow-features=' cargo test
7777
run: cargo test
7878
env:
79-
RUSTFLAGS: -Z allow-features= ${{env.RUSTFLAGS}}
79+
RUSTFLAGS: -Z allow-features= --cfg procmacro2_backtrace ${{env.RUSTFLAGS}}
8080

8181
minimal:
8282
name: Minimal versions

src/wrapper.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ impl LexError {
4040

4141
#[cold]
4242
fn mismatch(line: u32) -> ! {
43-
panic!("compiler/fallback mismatch #{}", line)
43+
#[cfg(procmacro2_backtrace)]
44+
{
45+
let backtrace = std::backtrace::Backtrace::force_capture();
46+
panic!("compiler/fallback mismatch #{}\n\n{}", line, backtrace)
47+
}
48+
#[cfg(not(procmacro2_backtrace))]
49+
{
50+
panic!("compiler/fallback mismatch #{}", line)
51+
}
4452
}
4553

4654
impl DeferredTokenStream {

0 commit comments

Comments
 (0)