Repository navigation
Keep &str panic messages in cxx's kj exceptions - #8763
Merged
Merged
Conversation
When a Rust function exposed through cxx panics, panic_result turns the
payload into a kj::Exception, but it only read String payloads. A
`panic!("literal")` with no format arguments carries a &'static str, so
C++ got "panic in <fn>" and lost the message.
In this patch panic_result reads both payload types. The new
r_panic_literal test fails without the fix.
There was a problem hiding this comment.
✅ Approved — A small, correct fix that keeps &'static str panic messages in the kj exception, covered by a test that fails without it. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
panic_result now reads both String and &'static str payloads. The borrow taken by message ends before err is moved in the CanceledException branch, and the CanceledException handling is unchanged. The new r_panic_literal test checks the exact message, so it would fail on the old code.
📝 Documentation: ✅ LGTM
The new comments are accurate and describe the code as it is now.
Reviewed commit: 0653a279
guybedford
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Rust function exposed through cxx panics,
panic_resultturns the payload into akj::Exception, but it only readStringpayloads. Apanic!("literal")with no format arguments carries a&'static str, so C++ gotpanic in <fn>and lost the message.In this patch
panic_resultreads both payload types. The newr_panic_literaltest in//src/rust/cxx/tests:testfails without the fix.