mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1909558 - Handle the deprecation of std::panic::PanicInfo. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D217533
This commit is contained in:
parent
a2ec89eb6e
commit
27f6dc381c
@ -22,8 +22,15 @@ fn main() {
|
||||
let max_alloc_error_panic_version = Version::parse("1.83.0-alpha").unwrap();
|
||||
|
||||
if ver >= Version::parse("1.80.0-alpha").unwrap() {
|
||||
println!("cargo::rustc-check-cfg=cfg(has_panic_hook_info)");
|
||||
println!("cargo::rustc-check-cfg=cfg(oom_with, values(\"hook\", \"alloc_error_panic\"))");
|
||||
}
|
||||
// As of 1.81, std::panic::PanicInfo is deprecated and replaced by
|
||||
// std::panic::PanicHookInfo. Using the former becomes a warning in
|
||||
// 1.82, but we can use the new type as of 1.81.
|
||||
if ver >= Version::parse("1.81.0-beta").unwrap() {
|
||||
println!("cargo:rustc-cfg=has_panic_hook_info");
|
||||
}
|
||||
if ver < max_oom_hook_version {
|
||||
println!("cargo:rustc-cfg=oom_with=\"hook\"");
|
||||
} else if ver < max_alloc_error_panic_version {
|
||||
|
@ -13,6 +13,10 @@ use std::os::raw::c_char;
|
||||
use std::os::raw::c_int;
|
||||
use std::os::raw::c_void;
|
||||
use std::panic;
|
||||
#[cfg(has_panic_hook_info)]
|
||||
use std::panic::PanicHookInfo;
|
||||
#[cfg(not(has_panic_hook_info))]
|
||||
use std::panic::PanicInfo as PanicHookInfo;
|
||||
|
||||
#[link(name = "wrappers")]
|
||||
extern "C" {
|
||||
@ -68,7 +72,7 @@ impl<const CAP: usize> Deref for ArrayCString<CAP> {
|
||||
}
|
||||
}
|
||||
|
||||
fn panic_hook(info: &panic::PanicInfo) {
|
||||
fn panic_hook(info: &PanicHookInfo) {
|
||||
// Try to handle &str/String payloads, which should handle 99% of cases.
|
||||
let payload = info.payload();
|
||||
let message = if let Some(layout) = oom_hook::oom_layout(payload) {
|
||||
|
Loading…
Reference in New Issue
Block a user