99#![ feature( once_cell) ]
1010#![ feature( decl_macro) ]
1111#![ feature( panic_info_message) ]
12+ #![ feature( backtrace_frames) ]
1213#![ recursion_limit = "256" ]
1314#![ allow( rustc:: potential_query_instability) ]
1415#![ deny( rustc:: untranslatable_diagnostic) ]
@@ -1192,7 +1193,8 @@ impl From<std::io::Error> for IceError {
11921193 }
11931194}
11941195
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 ! [ ] ;
11961198 let capture = backtrace:: Backtrace :: force_capture ( ) ;
11971199 let now = chrono:: UTC :: now ( ) ;
11981200 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> {
12101212 } ,
12111213 config:: host_triple( ) ,
12121214 ) ?;
1215+ args. push ( ( "version" , util:: version_str!( ) . unwrap_or ( "unknown_version" ) ) ) ;
1216+ args. push ( ( "platform" , config:: host_triple ( ) ) ) ;
12131217
12141218 if let Some ( ( flags, excluded_cargo_defaults) ) = extra_compiler_flags ( ) {
12151219 writeln ! ( file, "compiler flags:" ) ?;
1216- for flag in flags {
1220+ for flag in & flags {
12171221 writeln ! ( file, " {flag}" ) ?;
12181222 }
12191223 if excluded_cargo_defaults {
12201224 writeln ! ( file, "some of the compiler flags provided by cargo are hidden" ) ?;
12211225 }
12221226 }
12231227 writeln ! ( file, "" ) ?;
1228+ let mut text = String :: new ( ) ;
1229+ text. push_str ( & format ! ( "{:?} {:?}" , info. message( ) , info. location( ) ) ) ;
12241230 match ( info. message ( ) , info. location ( ) ) {
12251231 ( Some ( message) , Some ( location) ) => {
12261232 writeln ! ( file, "panicked at {location}:\n {message}" ) ?;
@@ -1237,7 +1243,15 @@ fn write_ice_to_disk(info: &panic::PanicInfo<'_>) -> Result<String, IceError> {
12371243 }
12381244
12391245 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( ) ) ;
12411255
12421256 // Be careful relying on global state here: this code is called from
12431257 // 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> {
12661280 writeln ! ( file, "end of query stack" ) ?;
12671281 Ok ( ( ) )
12681282 } ) ?;
1269- Ok ( path)
1283+ Ok ( ( path, String :: new ( ) ) )
12701284}
12711285
12721286static 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 +
13131327///
13141328/// When `install_ice_hook` is called, this function will be called as the panic
13151329/// 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 ) > ) {
13171331 let fallback_bundle =
13181332 rustc_errors:: fallback_fluent_bundle ( rustc_errors:: DEFAULT_LOCALE_RESOURCES , false ) ;
13191333 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
13411355 handler. emit_diagnostic ( & mut d) ;
13421356 }
13431357
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 {
13451359 vec ! [
13461360 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 }>" )
13481362 . into( ) ,
13491363 ]
13501364 } else {
0 commit comments