@@ -1161,12 +1161,18 @@ pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorReported>
1161
1161
lazy_static ! {
1162
1162
static ref DEFAULT_HOOK : Box <dyn Fn ( & panic:: PanicInfo <' _>) + Sync + Send + ' static > = {
1163
1163
let hook = panic:: take_hook( ) ;
1164
- panic:: set_hook( Box :: new( report_ice) ) ;
1164
+ panic:: set_hook( Box :: new( |info| report_ice( info , BUG_REPORT_URL ) ) ) ;
1165
1165
hook
1166
1166
} ;
1167
1167
}
1168
1168
1169
- pub fn report_ice ( info : & panic:: PanicInfo < ' _ > ) {
1169
+ /// Prints the ICE message, including backtrace and query stack.
1170
+ ///
1171
+ /// The message will point the user at `bug_report_url` to report the ICE.
1172
+ ///
1173
+ /// When `install_ice_hook` is called, this function will be called as the panic
1174
+ /// hook.
1175
+ pub fn report_ice ( info : & panic:: PanicInfo < ' _ > , bug_report_url : & str ) {
1170
1176
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
1171
1177
( * DEFAULT_HOOK ) ( info) ;
1172
1178
@@ -1192,7 +1198,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>) {
1192
1198
1193
1199
let mut xs: Vec < Cow < ' static , str > > = vec ! [
1194
1200
"the compiler unexpectedly panicked. this is a bug." . into( ) ,
1195
- format!( "we would appreciate a bug report: {}" , BUG_REPORT_URL ) . into( ) ,
1201
+ format!( "we would appreciate a bug report: {}" , bug_report_url ) . into( ) ,
1196
1202
format!( "rustc {} running on {}" ,
1197
1203
option_env!( "CFG_VERSION" ) . unwrap_or( "unknown_version" ) ,
1198
1204
config:: host_triple( ) ) . into( ) ,
@@ -1231,6 +1237,9 @@ pub fn report_ice(info: &panic::PanicInfo<'_>) {
1231
1237
}
1232
1238
}
1233
1239
1240
+ /// Installs a panic hook that will print the ICE message on unexpected panics.
1241
+ ///
1242
+ /// A custom rustc driver can skip calling this to set up a custom ICE hook.
1234
1243
pub fn install_ice_hook ( ) {
1235
1244
lazy_static:: initialize ( & DEFAULT_HOOK ) ;
1236
1245
}
0 commit comments