Skip to content

Commit cce1701

Browse files
committed
Rename EarlyErrorHandler as EarlyDiagCtxt.
1 parent 45f3476 commit cce1701

File tree

16 files changed

+77
-88
lines changed

16 files changed

+77
-88
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub(crate) fn compile_fn(
176176
match module.define_function(codegened_func.func_id, context) {
177177
Ok(()) => {}
178178
Err(ModuleError::Compilation(CodegenError::ImplLimitExceeded)) => {
179-
let handler = rustc_session::EarlyErrorHandler::new(
179+
let handler = rustc_session::EarlyDiagCtxt::new(
180180
rustc_session::config::ErrorOutputType::default(),
181181
);
182182
handler.early_error(format!(

compiler/rustc_codegen_cranelift/src/pretty_clif.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,8 @@ pub(crate) fn write_ir_file(
231231
let res = std::fs::File::create(clif_file_name).and_then(|mut file| write(&mut file));
232232
if let Err(err) = res {
233233
// Using early_warn as no Session is available here
234-
let handler = rustc_session::EarlyErrorHandler::new(
235-
rustc_session::config::ErrorOutputType::default(),
236-
);
234+
let handler =
235+
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
237236
handler.early_warn(format!("error writing ir file: {}", err));
238237
}
239238
}

compiler/rustc_driver_impl/src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt;
33
use std::fs;
44
use std::io;
55

6-
use rustc_session::EarlyErrorHandler;
6+
use rustc_session::EarlyDiagCtxt;
77

88
fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
99
if let Some(path) = arg.strip_prefix('@') {
@@ -23,7 +23,7 @@ fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
2323
/// **Note:** This function doesn't interpret argument 0 in any special way.
2424
/// If this function is intended to be used with command line arguments,
2525
/// `argv[0]` must be removed prior to calling it manually.
26-
pub fn arg_expand_all(handler: &EarlyErrorHandler, at_args: &[String]) -> Vec<String> {
26+
pub fn arg_expand_all(handler: &EarlyDiagCtxt, at_args: &[String]) -> Vec<String> {
2727
let mut args = Vec::new();
2828
for arg in at_args {
2929
match arg_expand(arg.clone()) {

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
3838
use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType, TrimmedDefPaths};
3939
use rustc_session::getopts::{self, Matches};
4040
use rustc_session::lint::{Lint, LintId};
41-
use rustc_session::{config, EarlyErrorHandler, Session};
41+
use rustc_session::{config, EarlyDiagCtxt, Session};
4242
use rustc_span::def_id::LOCAL_CRATE;
4343
use rustc_span::source_map::FileLoader;
4444
use rustc_span::symbol::sym;
@@ -291,7 +291,7 @@ fn run_compiler(
291291
>,
292292
using_internal_features: Arc<std::sync::atomic::AtomicBool>,
293293
) -> interface::Result<()> {
294-
let mut default_handler = EarlyErrorHandler::new(ErrorOutputType::default());
294+
let mut default_handler = EarlyDiagCtxt::new(ErrorOutputType::default());
295295

296296
// Throw away the first argument, the name of the binary.
297297
// In case of at_args being empty, as might be the case by
@@ -369,7 +369,7 @@ fn run_compiler(
369369
return sess.compile_status();
370370
}
371371

372-
let handler = EarlyErrorHandler::new(sess.opts.error_format);
372+
let handler = EarlyDiagCtxt::new(sess.opts.error_format);
373373

374374
if print_crate_info(&handler, codegen_backend, sess, has_input) == Compilation::Stop {
375375
return sess.compile_status();
@@ -495,7 +495,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<OutFileNa
495495

496496
// Extract input (string or file and optional path) from matches.
497497
fn make_input(
498-
handler: &EarlyErrorHandler,
498+
handler: &EarlyDiagCtxt,
499499
free_matches: &[String],
500500
) -> Result<Option<Input>, ErrorGuaranteed> {
501501
if free_matches.len() == 1 {
@@ -537,7 +537,7 @@ pub enum Compilation {
537537
Continue,
538538
}
539539

540-
fn handle_explain(handler: &EarlyErrorHandler, registry: Registry, code: &str, color: ColorConfig) {
540+
fn handle_explain(handler: &EarlyDiagCtxt, registry: Registry, code: &str, color: ColorConfig) {
541541
let upper_cased_code = code.to_ascii_uppercase();
542542
let normalised =
543543
if upper_cased_code.starts_with('E') { upper_cased_code } else { format!("E{code:0>4}") };
@@ -669,11 +669,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
669669
}
670670
}
671671

672-
fn list_metadata(
673-
handler: &EarlyErrorHandler,
674-
sess: &Session,
675-
metadata_loader: &dyn MetadataLoader,
676-
) {
672+
fn list_metadata(handler: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn MetadataLoader) {
677673
match sess.io.input {
678674
Input::File(ref ifile) => {
679675
let path = &(*ifile);
@@ -695,7 +691,7 @@ fn list_metadata(
695691
}
696692

697693
fn print_crate_info(
698-
handler: &EarlyErrorHandler,
694+
handler: &EarlyDiagCtxt,
699695
codegen_backend: &dyn CodegenBackend,
700696
sess: &Session,
701697
parse_attrs: bool,
@@ -873,7 +869,7 @@ pub macro version($handler: expr, $binary: literal, $matches: expr) {
873869

874870
#[doc(hidden)] // use the macro instead
875871
pub fn version_at_macro_invocation(
876-
handler: &EarlyErrorHandler,
872+
handler: &EarlyDiagCtxt,
877873
binary: &str,
878874
matches: &getopts::Matches,
879875
version: &str,
@@ -1072,7 +1068,7 @@ Available lint options:
10721068
/// Show help for flag categories shared between rustdoc and rustc.
10731069
///
10741070
/// Returns whether a help option was printed.
1075-
pub fn describe_flag_categories(handler: &EarlyErrorHandler, matches: &Matches) -> bool {
1071+
pub fn describe_flag_categories(handler: &EarlyDiagCtxt, matches: &Matches) -> bool {
10761072
// Handle the special case of -Wall.
10771073
let wall = matches.opt_strs("W");
10781074
if wall.iter().any(|x| *x == "all") {
@@ -1160,7 +1156,7 @@ fn print_flag_list<T>(
11601156
/// This does not need to be `pub` for rustc itself, but @chaosite needs it to
11611157
/// be public when using rustc as a library, see
11621158
/// <https://github.com/rust-lang/rust/commit/2b4c33817a5aaecabf4c6598d41e190080ec119e>
1163-
pub fn handle_options(handler: &EarlyErrorHandler, args: &[String]) -> Option<getopts::Matches> {
1159+
pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option<getopts::Matches> {
11641160
if args.is_empty() {
11651161
// user did not write `-v` nor `-Z unstable-options`, so do not
11661162
// include that extra information.
@@ -1336,7 +1332,7 @@ pub fn install_ice_hook(
13361332
if msg.starts_with("failed printing to stdout: ") && msg.ends_with("(os error 232)")
13371333
{
13381334
// the error code is already going to be reported when the panic unwinds up the stack
1339-
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
1335+
let handler = EarlyDiagCtxt::new(ErrorOutputType::default());
13401336
let _ = handler.early_error_no_abort(msg.clone());
13411337
return;
13421338
}
@@ -1476,14 +1472,14 @@ fn report_ice(
14761472

14771473
/// This allows tools to enable rust logging without having to magically match rustc's
14781474
/// tracing crate version.
1479-
pub fn init_rustc_env_logger(handler: &EarlyErrorHandler) {
1475+
pub fn init_rustc_env_logger(handler: &EarlyDiagCtxt) {
14801476
init_logger(handler, rustc_log::LoggerConfig::from_env("RUSTC_LOG"));
14811477
}
14821478

14831479
/// This allows tools to enable rust logging without having to magically match rustc's
14841480
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose
14851481
/// the values directly rather than having to set an environment variable.
1486-
pub fn init_logger(handler: &EarlyErrorHandler, cfg: rustc_log::LoggerConfig) {
1482+
pub fn init_logger(handler: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
14871483
if let Err(error) = rustc_log::init_logger(cfg) {
14881484
handler.early_error(error.to_string());
14891485
}
@@ -1493,7 +1489,7 @@ pub fn main() -> ! {
14931489
let start_time = Instant::now();
14941490
let start_rss = get_resident_set_size();
14951491

1496-
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
1492+
let handler = EarlyDiagCtxt::new(ErrorOutputType::default());
14971493

14981494
init_rustc_env_logger(&handler);
14991495
signal_handler::install();

compiler/rustc_interface/src/interface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_query_system::query::print_query_stack;
1818
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
1919
use rustc_session::filesearch::sysroot_candidates;
2020
use rustc_session::parse::ParseSess;
21-
use rustc_session::{lint, CompilerIO, EarlyErrorHandler, Session};
21+
use rustc_session::{lint, CompilerIO, EarlyDiagCtxt, Session};
2222
use rustc_span::source_map::FileLoader;
2323
use rustc_span::symbol::sym;
2424
use rustc_span::FileName;
@@ -317,7 +317,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
317317
rustc_data_structures::sync::set_dyn_thread_safe_mode(config.opts.unstable_opts.threads > 1);
318318

319319
// Check jobserver before run_in_thread_pool_with_globals, which call jobserver::acquire_thread
320-
let early_handler = EarlyErrorHandler::new(config.opts.error_format);
320+
let early_handler = EarlyDiagCtxt::new(config.opts.error_format);
321321
early_handler.initialize_checked_jobserver();
322322

323323
util::run_in_thread_pool_with_globals(
@@ -326,7 +326,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
326326
|| {
327327
crate::callbacks::setup_callbacks();
328328

329-
let early_handler = EarlyErrorHandler::new(config.opts.error_format);
329+
let early_handler = EarlyDiagCtxt::new(config.opts.error_format);
330330

331331
let codegen_backend = if let Some(make_codegen_backend) = config.make_codegen_backend {
332332
make_codegen_backend(&config.opts)

compiler/rustc_interface/src/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_session::config::{
1313
use rustc_session::lint::Level;
1414
use rustc_session::search_paths::SearchPath;
1515
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
16-
use rustc_session::{build_session, getopts, CompilerIO, EarlyErrorHandler, Session};
16+
use rustc_session::{build_session, getopts, CompilerIO, EarlyDiagCtxt, Session};
1717
use rustc_span::edition::{Edition, DEFAULT_EDITION};
1818
use rustc_span::symbol::sym;
1919
use rustc_span::{FileName, SourceFileHashAlgorithm};
@@ -25,7 +25,7 @@ use std::path::{Path, PathBuf};
2525
use std::sync::Arc;
2626

2727
fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
28-
let mut early_handler = EarlyErrorHandler::new(ErrorOutputType::default());
28+
let mut early_handler = EarlyDiagCtxt::new(ErrorOutputType::default());
2929
early_handler.initialize_checked_jobserver();
3030

3131
let registry = registry::Registry::new(&[]);
@@ -301,7 +301,7 @@ fn test_search_paths_tracking_hash_different_order() {
301301
let mut v3 = Options::default();
302302
let mut v4 = Options::default();
303303

304-
let handler = EarlyErrorHandler::new(JSON);
304+
let handler = EarlyDiagCtxt::new(JSON);
305305
const JSON: ErrorOutputType = ErrorOutputType::Json {
306306
pretty: false,
307307
json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
@@ -854,7 +854,7 @@ fn test_edition_parsing() {
854854
let options = Options::default();
855855
assert!(options.edition == DEFAULT_EDITION);
856856

857-
let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
857+
let mut handler = EarlyDiagCtxt::new(ErrorOutputType::default());
858858

859859
let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
860860
let sessopts = build_session_options(&mut handler, &matches);

compiler/rustc_interface/src/util.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_session::{filesearch, output, Session};
1414
use rustc_span::edit_distance::find_best_match_for_name;
1515
use rustc_span::edition::Edition;
1616
use rustc_span::symbol::{sym, Symbol};
17-
use session::EarlyErrorHandler;
17+
use session::EarlyDiagCtxt;
1818
use std::env;
1919
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
2020
use std::mem;
@@ -161,7 +161,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
161161
})
162162
}
163163

164-
fn load_backend_from_dylib(handler: &EarlyErrorHandler, path: &Path) -> MakeBackendFn {
164+
fn load_backend_from_dylib(handler: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn {
165165
let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| {
166166
let err = format!("couldn't load codegen backend {path:?}: {err}");
167167
handler.early_error(err);
@@ -185,7 +185,7 @@ fn load_backend_from_dylib(handler: &EarlyErrorHandler, path: &Path) -> MakeBack
185185
///
186186
/// A name of `None` indicates that the default backend should be used.
187187
pub fn get_codegen_backend(
188-
handler: &EarlyErrorHandler,
188+
handler: &EarlyDiagCtxt,
189189
maybe_sysroot: &Option<PathBuf>,
190190
backend_name: Option<&str>,
191191
) -> Box<dyn CodegenBackend> {
@@ -233,7 +233,7 @@ fn get_rustc_path_inner(bin_path: &str) -> Option<PathBuf> {
233233
}
234234

235235
fn get_codegen_sysroot(
236-
handler: &EarlyErrorHandler,
236+
handler: &EarlyDiagCtxt,
237237
maybe_sysroot: &Option<PathBuf>,
238238
backend_name: &str,
239239
) -> MakeBackendFn {

0 commit comments

Comments
 (0)