-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Add support for SpanTrace capture in ICE reports #103993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,20 +45,32 @@ | |
use std::env::{self, VarError}; | ||
use std::fmt::{self, Display}; | ||
use std::io::{self, IsTerminal}; | ||
use std::str::FromStr; | ||
use tracing_core::{Event, Subscriber}; | ||
use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter}; | ||
use tracing_subscriber::fmt::{ | ||
format::{self, FormatEvent, FormatFields}, | ||
FmtContext, | ||
}; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::Layer; | ||
|
||
pub fn init_env_logger(env: &str) -> Result<(), Error> { | ||
let filter = match env::var(env) { | ||
/// In contrast to `init_rustc_env_logger` this allows you to choose an env var | ||
/// other than `RUSTC_LOG`. | ||
pub fn init_env_logger(env: &str, ice_env: &str) -> Result<(), Error> { | ||
let log_filter = match env::var(env) { | ||
Ok(env) => EnvFilter::new(env), | ||
_ => EnvFilter::default().add_directive(Directive::from(LevelFilter::WARN)), | ||
}; | ||
|
||
let error_filter = match env::var(ice_env) { | ||
|
||
Ok(env) => tracing::Level::from_str(&env).unwrap(), | ||
_ => tracing::Level::WARN, | ||
}; | ||
let error_filter = tracing_subscriber::filter::filter_fn(move |metadata| { | ||
metadata.is_span() && metadata.level() <= &error_filter | ||
}); | ||
|
||
let color_logs = match env::var(String::from(env) + "_COLOR") { | ||
Ok(value) => match value.as_ref() { | ||
"always" => true, | ||
|
@@ -75,7 +87,7 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> { | |
Some(v) => &v != "0", | ||
}; | ||
|
||
let layer = tracing_tree::HierarchicalLayer::default() | ||
let log_layer = tracing_tree::HierarchicalLayer::default() | ||
.with_writer(io::stderr) | ||
.with_indent_lines(true) | ||
.with_ansi(color_logs) | ||
|
@@ -84,9 +96,12 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> { | |
.with_verbose_entry(verbose_entry_exit) | ||
.with_indent_amount(2); | ||
#[cfg(parallel_compiler)] | ||
let layer = layer.with_thread_ids(true).with_thread_names(true); | ||
let log_layer = log_layer.with_thread_ids(true).with_thread_names(true); | ||
let error_layer = tracing_error::ErrorLayer::default(); | ||
let subscriber = tracing_subscriber::Registry::default() | ||
.with(error_layer.with_filter(error_filter)) | ||
.with(log_layer.with_filter(log_filter)); | ||
|
||
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer); | ||
match env::var(format!("{env}_BACKTRACE")) { | ||
Ok(str) => { | ||
let fmt_layer = tracing_subscriber::fmt::layer() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -677,6 +677,7 @@ impl Session { | |
|| self.opts.unstable_opts.unpretty.is_some() | ||
|| self.opts.output_types.contains_key(&OutputType::Mir) | ||
|| std::env::var_os("RUSTC_LOG").is_some() | ||
|| std::env::var_os("RUSTC_ICE_LOG").is_some() | ||
|
||
{ | ||
return; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// edition:2021 | ||
// known-bug: unknown | ||
// unset-rustc-env:RUST_BACKTRACE | ||
// rustc-env:RUSTC_ICE_LOG=trace | ||
|
||
// compile-flags:-Z trait-solver=chalk | ||
// error-pattern:internal compiler error | ||
// failure-status:101 | ||
|
Uh oh!
There was an error while loading. Please reload this page.