Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47f359b

Browse files
committed
Remove std::panic::PanicInfo::internal_constructor+set_payload.
We can just set the payload immediately in the constructor,and the constructor does not need to be public.
1 parent701d6a2 commit47f359b

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

‎std/src/panic.rs‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,14 @@ pub struct PanicInfo<'a> {
4444
}
4545

4646
impl<'a>PanicInfo<'a>{
47-
#[unstable(feature ="panic_internals", issue ="none")]
48-
#[doc(hidden)]
4947
#[inline]
50-
pubfninternal_constructor(
48+
pub(crate)fnnew(
5149
location:&'aLocation<'a>,
50+
payload:&'a(dynAny +Send),
5251
can_unwind:bool,
5352
force_no_backtrace:bool,
5453
) ->Self{
55-
structNoPayload;
56-
PanicInfo{payload:&NoPayload, location, can_unwind, force_no_backtrace}
57-
}
58-
59-
#[unstable(feature ="panic_internals", issue ="none")]
60-
#[doc(hidden)]
61-
#[inline]
62-
pubfnset_payload(&mutself,info:&'a(dynAny +Send)){
63-
self.payload = info;
54+
PanicInfo{ payload, location, can_unwind, force_no_backtrace}
6455
}
6556

6657
/// Returns the payload associated with the panic.

‎std/src/panicking.rs‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,7 @@ fn rust_panic_with_hook(
775775
crate::sys::abort_internal();
776776
}
777777

778-
letmut info =PanicInfo::internal_constructor(location, can_unwind, force_no_backtrace);
779-
let hook =HOOK.read().unwrap_or_else(PoisonError::into_inner);
780-
match*hook{
778+
match*HOOK.read().unwrap_or_else(PoisonError::into_inner){
781779
// Some platforms (like wasm) know that printing to stderr won't ever actually
782780
// print anything, and if that's the case we can skip the default
783781
// hook. Since string formatting happens lazily when calling `payload`
@@ -786,15 +784,12 @@ fn rust_panic_with_hook(
786784
// formatting.)
787785
Hook::Defaultifpanic_output().is_none() =>{}
788786
Hook::Default =>{
789-
info.set_payload(payload.get());
790-
default_hook(&info);
787+
default_hook(&PanicInfo::new(location, payload.get(), can_unwind, force_no_backtrace));
791788
}
792789
Hook::Custom(ref hook) =>{
793-
info.set_payload(payload.get());
794-
hook(&info);
790+
hook(&PanicInfo::new(location, payload.get(), can_unwind, force_no_backtrace));
795791
}
796-
};
797-
drop(hook);
792+
}
798793

799794
// Indicate that we have finished executing the panic hook. After this point
800795
// it is fine if there is a panic while executing destructors, as long as it

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp