1use once_cell::sync::Lazy;
2use std::panic;
3
4const BUG_REPORT_URL: &str = "https://github.com/ethereum/fe/issues/new";
5type PanicCallback = dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static;
6static DEFAULT_PANIC_HOOK: Lazy<Box<PanicCallback>> = Lazy::new(|| {
7 let hook = panic::take_hook();
8 panic::set_hook(Box::new(report_ice));
9 hook
10});
11
12pub fn install_panic_hook() {
13 Lazy::force(&DEFAULT_PANIC_HOOK);
14}
15fn report_ice(info: &panic::PanicInfo) {
16 (*DEFAULT_PANIC_HOOK)(info);
17
18 eprintln!();
19 eprintln!("You've hit an internal compiler error. This is a bug in the Fe compiler.");
20 eprintln!("Fe is still under heavy development, and isn't yet ready for production use.");
21 eprintln!();
22 eprintln!("If you would, please report this bug at the following URL:");
23 eprintln!(" {BUG_REPORT_URL}");
24}