1
Fork 0

Rollup merge of #125355 - michaelwoerister:rust_log_force_capture, r=nnethercote

Use Backtrace::force_capture instead of Backtrace::capture in rustc_log

After https://github.com/rust-lang/rust/pull/125063, the compiler and custom drivers won't automatically set the RUST_BACKTRACE environment variable anymore, so we have to call `Backtrace::force_capture` instead of `Backtrace::capture` to unconditionally capture a backtrace.

rustc_log handles enabling backtraces via env vars itself, so we don't want RUST_BACKTRACE to make a difference.
This commit is contained in:
León Orell Valerian Liehr 2024-05-22 23:41:12 +02:00 committed by GitHub
commit c7d4c54cc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -159,7 +159,9 @@ where
if !target.contains(&self.backtrace_target) {
return Ok(());
}
let backtrace = std::backtrace::Backtrace::capture();
// Use Backtrace::force_capture because we don't want to depend on the
// RUST_BACKTRACE environment variable being set.
let backtrace = std::backtrace::Backtrace::force_capture();
writeln!(writer, "stack backtrace: \n{backtrace:?}")
}
}