Skip to content

Commit 55480f1

Browse files
authored
Rollup merge of rust-lang#89634 - hawkw:eliza/enable-err-warn, r=oli-obk
rustc_driver: Enable the `WARN` log level by default This commit changes the `tracing_subscriber` initialization in `rustc_driver` so that the `WARN` verbosity level is enabled by default when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env variable is set, the filter string in the environment variable is honored, instead. Fixes rust-lang#76824 Closes rust-lang#89623 cc `@eddyb,` `@oli-obk`
2 parents 6bd7a7f + 84fc5db commit 55480f1

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,19 +843,18 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
843843
let msg_bus = "clang: error: unable to execute command: Bus error: 10";
844844
if out.contains(msg_segv) || out.contains(msg_bus) {
845845
warn!(
846+
?cmd, %out,
846847
"looks like the linker segfaulted when we tried to call it, \
847-
automatically retrying again. cmd = {:?}, out = {}.",
848-
cmd, out,
848+
automatically retrying again",
849849
);
850850
continue;
851851
}
852852

853853
if is_illegal_instruction(&output.status) {
854854
warn!(
855+
?cmd, %out, status = %output.status,
855856
"looks like the linker hit an illegal instruction when we \
856-
tried to call it, automatically retrying again. cmd = {:?}, ]\
857-
out = {}, status = {}.",
858-
cmd, out, output.status,
857+
tried to call it, automatically retrying again.",
859858
);
860859
continue;
861860
}

compiler/rustc_driver/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,12 +1253,16 @@ pub fn init_rustc_env_logger() {
12531253
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
12541254
/// other than `RUSTC_LOG`.
12551255
pub fn init_env_logger(env: &str) {
1256-
// Don't register a dispatcher if there's no filter to print anything
1257-
match std::env::var(env) {
1258-
Err(_) => return,
1259-
Ok(s) if s.is_empty() => return,
1260-
Ok(_) => {}
1261-
}
1256+
use tracing_subscriber::{
1257+
filter::{self, EnvFilter, LevelFilter},
1258+
layer::SubscriberExt,
1259+
};
1260+
1261+
let filter = match std::env::var(env) {
1262+
Ok(env) => EnvFilter::from_env(env),
1263+
_ => EnvFilter::default().add_directive(filter::Directive::from(LevelFilter::WARN)),
1264+
};
1265+
12621266
let color_logs = match std::env::var(String::from(env) + "_COLOR") {
12631267
Ok(value) => match value.as_ref() {
12641268
"always" => true,
@@ -1278,7 +1282,7 @@ pub fn init_env_logger(env: &str) {
12781282
"non-Unicode log color value: expected one of always, never, or auto",
12791283
),
12801284
};
1281-
let filter = tracing_subscriber::EnvFilter::from_env(env);
1285+
12821286
let layer = tracing_tree::HierarchicalLayer::default()
12831287
.with_writer(io::stderr)
12841288
.with_indent_lines(true)
@@ -1288,7 +1292,6 @@ pub fn init_env_logger(env: &str) {
12881292
#[cfg(parallel_compiler)]
12891293
let layer = layer.with_thread_ids(true).with_thread_names(true);
12901294

1291-
use tracing_subscriber::layer::SubscriberExt;
12921295
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);
12931296
tracing::subscriber::set_global_default(subscriber).unwrap();
12941297
}

compiler/rustc_errors/src/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,7 @@ pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
23082308
let found = match sm.span_to_snippet(sp) {
23092309
Ok(snippet) => snippet,
23102310
Err(e) => {
2311-
warn!("Invalid span {:?}. Err={:?}", sp, e);
2311+
warn!(error = ?e, "Invalid span {:?}", sp);
23122312
return false;
23132313
}
23142314
};

compiler/rustc_mir_dataflow/src/rustc_peek.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'tcx> RustcPeekAt<'tcx> for MaybeMutBorrowedLocals<'_, 'tcx> {
289289
flow_state: &BitSet<Local>,
290290
call: PeekCall,
291291
) {
292-
warn!("peek_at: place={:?}", place);
292+
info!(?place, "peek_at");
293293
let local = if let Some(l) = place.as_local() {
294294
l
295295
} else {
@@ -311,7 +311,7 @@ impl<'tcx> RustcPeekAt<'tcx> for MaybeLiveLocals {
311311
flow_state: &BitSet<Local>,
312312
call: PeekCall,
313313
) {
314-
warn!("peek_at: place={:?}", place);
314+
info!(?place, "peek_at");
315315
let local = if let Some(l) = place.as_local() {
316316
l
317317
} else {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WARN rustc_mir_build::thir::pattern::const_to_pat MIR const-checker found novel structural match violation. See #73448.

0 commit comments

Comments
 (0)