9
9
#![ feature( once_cell) ]
10
10
#![ feature( decl_macro) ]
11
11
#![ feature( panic_info_message) ]
12
+ #![ feature( backtrace_frames) ]
12
13
#![ recursion_limit = "256" ]
13
14
#![ allow( rustc:: potential_query_instability) ]
14
15
#![ deny( rustc:: untranslatable_diagnostic) ]
@@ -1192,7 +1193,8 @@ impl From<std::io::Error> for IceError {
1192
1193
}
1193
1194
}
1194
1195
1195
- fn write_ice_to_disk ( info : & panic:: PanicInfo < ' _ > ) -> Result < String , IceError > {
1196
+ fn write_ice_to_disk ( info : & panic:: PanicInfo < ' _ > ) -> Result < ( String , String ) , IceError > {
1197
+ let mut args = vec ! [ ] ;
1196
1198
let capture = backtrace:: Backtrace :: force_capture ( ) ;
1197
1199
let now = chrono:: UTC :: now ( ) ;
1198
1200
let file_now = now. format ( "%Y-%m-%d_%H:%M:%S" ) ;
@@ -1210,17 +1212,21 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<String, IceError> {
1210
1212
} ,
1211
1213
config:: host_triple( ) ,
1212
1214
) ?;
1215
+ args. push ( ( "version" , util:: version_str!( ) . unwrap_or ( "unknown_version" ) ) ) ;
1216
+ args. push ( ( "platform" , config:: host_triple ( ) ) ) ;
1213
1217
1214
1218
if let Some ( ( flags, excluded_cargo_defaults) ) = extra_compiler_flags ( ) {
1215
1219
writeln ! ( file, "compiler flags:" ) ?;
1216
- for flag in flags {
1220
+ for flag in & flags {
1217
1221
writeln ! ( file, " {flag}" ) ?;
1218
1222
}
1219
1223
if excluded_cargo_defaults {
1220
1224
writeln ! ( file, "some of the compiler flags provided by cargo are hidden" ) ?;
1221
1225
}
1222
1226
}
1223
1227
writeln ! ( file, "" ) ?;
1228
+ let mut text = String :: new ( ) ;
1229
+ text. push_str ( & format ! ( "{:?} {:?}" , info. message( ) , info. location( ) ) ) ;
1224
1230
match ( info. message ( ) , info. location ( ) ) {
1225
1231
( Some ( message) , Some ( location) ) => {
1226
1232
writeln ! ( file, "panicked at {location}:\n {message}" ) ?;
@@ -1237,7 +1243,15 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<String, IceError> {
1237
1243
}
1238
1244
1239
1245
writeln ! ( file, "" ) ?;
1240
- writeln ! ( file, "{}" , capture) ?;
1246
+ let capture = capture. frames ( ) . iter ( ) . map ( |frame| {
1247
+ format ! ( "{:?}" , frame)
1248
+ } ) . collect :: < String > ( ) ;
1249
+ writeln ! ( file, "{capture}" ) ?;
1250
+ text. push_str ( & format ! ( "{capture}" ) ) ;
1251
+ args. push ( ( "backtrace" , & text) ) ;
1252
+
1253
+ println ! ( "{}" , text) ;
1254
+ println ! ( "{}" , urlqstring:: QueryParams :: from( args) . stringify( ) ) ;
1241
1255
1242
1256
// Be careful relying on global state here: this code is called from
1243
1257
// a panic hook, which means that the global `Handler` may be in a weird
@@ -1266,7 +1280,7 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<String, IceError> {
1266
1280
writeln ! ( file, "end of query stack" ) ?;
1267
1281
Ok ( ( ) )
1268
1282
} ) ?;
1269
- Ok ( path)
1283
+ Ok ( ( path, String :: new ( ) ) )
1270
1284
}
1271
1285
1272
1286
static DEFAULT_HOOK : LazyLock < Box < dyn Fn ( & panic:: PanicInfo < ' _ > ) + Sync + Send + ' static > > =
@@ -1313,7 +1327,7 @@ static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
1313
1327
///
1314
1328
/// When `install_ice_hook` is called, this function will be called as the panic
1315
1329
/// hook.
1316
- pub fn report_ice ( info : & panic:: PanicInfo < ' _ > , bug_report_url : & str , reported_ice : Option < String > ) {
1330
+ pub fn report_ice ( info : & panic:: PanicInfo < ' _ > , bug_report_url : & str , reported_ice : Option < ( String , String ) > ) {
1317
1331
let fallback_bundle =
1318
1332
rustc_errors:: fallback_fluent_bundle ( rustc_errors:: DEFAULT_LOCALE_RESOURCES , false ) ;
1319
1333
let emitter = Box :: new ( rustc_errors:: emitter:: EmitterWriter :: stderr (
@@ -1341,10 +1355,10 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str, reported_ic
1341
1355
handler. emit_diagnostic ( & mut d) ;
1342
1356
}
1343
1357
1344
- let xs: Vec < Cow < ' static , str > > = if let Some ( path) = & reported_ice {
1358
+ let xs: Vec < Cow < ' static , str > > = if let Some ( ( path, url ) ) = & reported_ice {
1345
1359
vec ! [
1346
1360
format!( "all necessary context about this bug was written to `{path}`" ) . into( ) ,
1347
- format!( "we would appreciate a bug report with this context at <{bug_report_url }>" )
1361
+ format!( "we would appreciate a bug report with this context at <{url }>" )
1348
1362
. into( ) ,
1349
1363
]
1350
1364
} else {
0 commit comments