Skip to content

Commit 729aa49

Browse files
authored
Rollup merge of #130381 - workingjubilee:sometimes-code-really-is-self-descriptive, r=Noratrieb
library: Compute Rust exception class from its string repr Noticed this awkwardness while scanning through the code. I think we can do better than that.
2 parents 9ed667f + fef7373 commit 729aa49

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

  • library/panic_unwind/src

‎library/panic_unwind/src/gcc.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct Exception {
6161
pubunsafefnpanic(data:Box<dynAny + Send>) -> u32{
6262
let exception = Box::new(Exception{
6363
_uwe: uw::_Unwind_Exception{
64-
exception_class:rust_exception_class(),
64+
exception_class:RUST_EXCEPTION_CLASS,
6565
exception_cleanup:Some(exception_cleanup),
6666
private:[core::ptr::null(); uw::unwinder_private_data_size],
6767
},
@@ -84,7 +84,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
8484

8585
pubunsafefncleanup(ptr:*mutu8) -> Box<dynAny + Send>{
8686
let exception = ptr as*mut uw::_Unwind_Exception;
87-
if(*exception).exception_class != rust_exception_class(){
87+
if(*exception).exception_class != RUST_EXCEPTION_CLASS{
8888
uw::_Unwind_DeleteException(exception);
8989
super::__rust_foreign_exception();
9090
}
@@ -107,7 +107,4 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
107107

108108
// Rust's exception class identifier. This is used by personality routines to
109109
// determine whether the exception was thrown by their own runtime.
110-
fnrust_exception_class() -> uw::_Unwind_Exception_Class{
111-
// M O Z \0 R U S T -- vendor, language
112-
0x4d4f5a_00_52555354
113-
}
110+
constRUST_EXCEPTION_CLASS: uw::_Unwind_Exception_Class = u64::from_be_bytes(*b"MOZ\0RUST");

0 commit comments

Comments
 (0)