Skip to content

Commit

Permalink
Invert MOZ\0RUST endianness
Browse files Browse the repository at this point in the history
This was changed in upstream Rust recently [1], so change to follow
suit. The error message is slightly different between
exception from another Rust runtime and a complete foreign exception.
(The message for latter is a confusing "Rust exception must be
rethrown").

Link: rust-lang/rust#130897 [1]
  • Loading branch information
nbdd0121 committed Oct 8, 2024
1 parent e651ead commit 24c1b38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn begin_panic<E: Exception>(exception: E) -> UnwindReasonCode {

let ex = E::wrap(exception);
unsafe {
(*ex).exception_class = u64::from_be_bytes(E::CLASS);
(*ex).exception_class = u64::from_ne_bytes(E::CLASS);
(*ex).exception_cleanup = Some(exception_cleanup::<E>);
_Unwind_RaiseException(ex)
}
Expand Down Expand Up @@ -60,7 +60,7 @@ pub fn catch_unwind<E: Exception, R, F: FnOnce() -> R>(f: F) -> Result<R, Option
unsafe {
let data = &mut *(data as *mut ManuallyDrop<Option<E>>);
let exception = exception as *mut UnwindException;
if (*exception).exception_class != u64::from_be_bytes(E::CLASS) {
if (*exception).exception_class != u64::from_ne_bytes(E::CLASS) {
_Unwind_DeleteException(exception);
*data = ManuallyDrop::new(None);
return;
Expand Down

0 comments on commit 24c1b38

Please sign in to comment.