Skip to content

Commit

Permalink
Auto merge of #119063 - nnethercote:dcx, r=compiler-errors
Browse files Browse the repository at this point in the history
Consistent `Handler` naming

This PR implements the renaming described in rust-lang/compiler-team#699.

r? `@compiler-errors`
  • Loading branch information
bors committed Dec 18, 2023
2 parents 4503a3d + 569fcec commit 649c266
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/bin/miri.rs
Expand Up @@ -35,7 +35,7 @@ use rustc_middle::{
};
use rustc_session::config::{CrateType, ErrorOutputType, OptLevel};
use rustc_session::search_paths::PathKind;
use rustc_session::{CtfeBacktrace, EarlyErrorHandler};
use rustc_session::{CtfeBacktrace, EarlyDiagCtxt};

use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields};

Expand Down Expand Up @@ -69,8 +69,8 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
}

let handler = EarlyErrorHandler::new(tcx.sess.opts.error_format);
init_late_loggers(&handler, tcx);
let early_dcx = EarlyDiagCtxt::new(tcx.sess.opts.error_format);
init_late_loggers(&early_dcx, tcx);
if !tcx.crate_types().contains(&CrateType::Executable) {
tcx.sess.fatal("miri only makes sense on bin crates");
}
Expand Down Expand Up @@ -215,7 +215,7 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
cfg
}

fn init_early_loggers(handler: &EarlyErrorHandler) {
fn init_early_loggers(early_dcx: &EarlyDiagCtxt) {
// Note that our `extern crate log` is *not* the same as rustc's; as a result, we have to
// initialize them both, and we always initialize `miri`'s first.
let env = env_logger::Env::new().filter("MIRI_LOG").write_style("MIRI_LOG_STYLE");
Expand All @@ -224,15 +224,15 @@ fn init_early_loggers(handler: &EarlyErrorHandler) {
// If it is not set, we avoid initializing now so that we can initialize later with our custom
// settings, and *not* log anything for what happens before `miri` gets started.
if env::var_os("RUSTC_LOG").is_some() {
rustc_driver::init_logger(handler, rustc_logger_config());
rustc_driver::init_logger(early_dcx, rustc_logger_config());
}
}

fn init_late_loggers(handler: &EarlyErrorHandler, tcx: TyCtxt<'_>) {
fn init_late_loggers(early_dcx: &EarlyDiagCtxt, tcx: TyCtxt<'_>) {
// If `RUSTC_LOG` is not set, then `init_early_loggers` did not call
// `rustc_driver::init_logger`, so we have to do this now.
if env::var_os("RUSTC_LOG").is_none() {
rustc_driver::init_logger(handler, rustc_logger_config());
rustc_driver::init_logger(early_dcx, rustc_logger_config());
}

// If `MIRI_BACKTRACE` is set and `RUSTC_CTFE_BACKTRACE` is not, set `RUSTC_CTFE_BACKTRACE`.
Expand Down Expand Up @@ -300,7 +300,7 @@ fn parse_comma_list<T: FromStr>(input: &str) -> Result<Vec<T>, T::Err> {
}

fn main() {
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());

// Snapshot a copy of the environment before `rustc` starts messing with it.
// (`install_ice_hook` might change `RUST_BACKTRACE`.)
Expand All @@ -311,7 +311,7 @@ fn main() {
// Earliest rustc setup.
let using_internal_features =
rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ());
rustc_driver::init_rustc_env_logger(&handler);
rustc_driver::init_rustc_env_logger(&early_dcx);

let target_crate = if crate_kind == "target" {
true
Expand All @@ -335,7 +335,7 @@ fn main() {
rustc_driver::install_ice_hook("https://github.com/rust-lang/miri/issues/new", |_| ());

// Init loggers the Miri way.
init_early_loggers(&handler);
init_early_loggers(&early_dcx);

// Parse our arguments and split them across `rustc` and `miri`.
let mut miri_config = miri::MiriConfig::default();
Expand Down
6 changes: 3 additions & 3 deletions src/diagnostics.rs
Expand Up @@ -384,7 +384,7 @@ pub fn report_error<'tcx, 'mir>(

// Include a note like `std` does when we omit frames from a backtrace
if was_pruned {
ecx.tcx.sess.diagnostic().note(
ecx.tcx.sess.dcx().note(
"some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace",
);
}
Expand Down Expand Up @@ -431,7 +431,7 @@ pub fn report_leaks<'mir, 'tcx>(
);
}
if any_pruned {
ecx.tcx.sess.diagnostic().note(
ecx.tcx.sess.dcx().note(
"some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace",
);
}
Expand All @@ -456,7 +456,7 @@ pub fn report_msg<'tcx>(
let mut err = match diag_level {
DiagLevel::Error => sess.struct_span_err(span, title).forget_guarantee(),
DiagLevel::Warning => sess.struct_span_warn(span, title),
DiagLevel::Note => sess.diagnostic().struct_span_note(span, title),
DiagLevel::Note => sess.dcx().struct_span_note(span, title),
};

// Show main message.
Expand Down

0 comments on commit 649c266

Please sign in to comment.