Skip to content

Conversation

@MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented Jan 5, 2026

We know from experience - and the payload() docs - that the returned payload can be a &'static str or String, but we only downcast the former meaning that any owned (typically because of being Debug-formatted) error messages are not included in the panic log. Add the cast to include them.

Note that Rust 1.91 (slightly more than 2 months old at the time of writing) added this cast to the PanicHookInfo type directly: https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html#method.payload_as_str

We know from experience - [and the `payload()` docs] - that the
returned payload can be a `&'static str` or `String`, but we only
downcast the former meaning that any owned (typically because of being
`Debug`-formatted) error messages are not included in the panic log.
Add the cast to include them.

Note that Rust 1.91, slightly more than 2
months old at the time of writing added this cast to the `PanicHookInfo`
type directly:
https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html#method.payload_as_str

[and the `payload()` docs]: https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html#method.payload
Set the `rust-version` in `Cargo.toml` for a multitude of reasons
(crates.io shows it to users, and `cargo` can use it in its MSRV-aware
resolver), including the `+nightly -Zminimal-versions generate-lockfile`
step to generate a compatible `version = 3` `Cargo.lock` for MSRV 1.74
to consume, rather than `version = 4` which it doesn't understand yet.
Before that, the `log!` macro is not found inside `error!` expansion.
Because the `README` is _intentionally_ included as the root
module/library documentation, its code sample is susceptible to `cargo
tests` doctests.
@MarijnS95 MarijnS95 force-pushed the panic-include-string branch from 4d2f99e to e3d42a9 Compare January 5, 2026 12:50
@MarijnS95 MarijnS95 force-pushed the panic-include-string branch from 79d1dac to 1fab6e9 Compare January 5, 2026 12:54
@MarijnS95 MarijnS95 merged commit cda646c into Traverse-Research:main Jan 5, 2026
2 checks passed
@MarijnS95 MarijnS95 deleted the panic-include-string branch January 5, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants