Skip to content

Commit a5f518a

Browse files
committed
wip
1 parent 6b88403 commit a5f518a

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

Cargo.lock

+7
Original file line numberDiff line numberDiff line change
@@ -3976,6 +3976,7 @@ dependencies = [
39763976
"rustc_target",
39773977
"serde_json",
39783978
"tracing",
3979+
"urlqstring",
39793980
"winapi",
39803981
]
39813982

@@ -6090,6 +6091,12 @@ dependencies = [
60906091
"serde",
60916092
]
60926093

6094+
[[package]]
6095+
name = "urlqstring"
6096+
version = "0.3.5"
6097+
source = "registry+https://github.com/rust-lang/crates.io-index"
6098+
checksum = "25ef3473a06a065718d8ec7cd7acc6a35fc20f836dee7661ad3b64ea3cc2e0cc"
6099+
60936100
[[package]]
60946101
name = "utf-8"
60956102
version = "0.7.5"

compiler/rustc_driver/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ crate-type = ["dylib"]
1010
backtrace = "0.3.66"
1111
serde_json = "1.0.59"
1212
chrono = "0.2"
13+
urlqstring = "*"
1314
tracing = { version = "0.1.35" }
1415
rustc_log = { path = "../rustc_log" }
1516
rustc_middle = { path = "../rustc_middle" }

compiler/rustc_driver/src/lib.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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

12721286
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 +
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

Comments
 (0)