From d58e372853a9e07a50f409c1e6f0fe8fe2f7c3ff Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Dec 2023 10:57:26 +1100 Subject: Rename many `EarlyDiagCtxt` arguments. --- compiler/rustc_driver_impl/src/args.rs | 4 ++-- compiler/rustc_driver_impl/src/lib.rs | 44 +++++++++++++++++----------------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'compiler/rustc_driver_impl/src') diff --git a/compiler/rustc_driver_impl/src/args.rs b/compiler/rustc_driver_impl/src/args.rs index d93ac0efffd..dc546da7342 100644 --- a/compiler/rustc_driver_impl/src/args.rs +++ b/compiler/rustc_driver_impl/src/args.rs @@ -23,12 +23,12 @@ fn arg_expand(arg: String) -> Result, Error> { /// **Note:** This function doesn't interpret argument 0 in any special way. /// If this function is intended to be used with command line arguments, /// `argv[0]` must be removed prior to calling it manually. -pub fn arg_expand_all(handler: &EarlyDiagCtxt, at_args: &[String]) -> Vec { +pub fn arg_expand_all(early_dcx: &EarlyDiagCtxt, at_args: &[String]) -> Vec { let mut args = Vec::new(); for arg in at_args { match arg_expand(arg.clone()) { Ok(arg) => args.extend(arg), - Err(err) => handler.early_error(format!("Failed to load argument file: {err}")), + Err(err) => early_dcx.early_error(format!("Failed to load argument file: {err}")), } } args diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 662d6d51179..18d9610f62e 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -495,7 +495,7 @@ fn make_output(matches: &getopts::Matches) -> (Option, Option Result, ErrorGuaranteed> { if free_matches.len() == 1 { @@ -505,7 +505,7 @@ fn make_input( if io::stdin().read_to_string(&mut src).is_err() { // Immediately stop compilation if there was an issue reading // the input (for example if the input stream is not UTF-8). - let reported = handler.early_error_no_abort( + let reported = early_dcx.early_error_no_abort( "couldn't read from stdin, as it did not contain valid UTF-8", ); return Err(reported); @@ -537,7 +537,7 @@ pub enum Compilation { Continue, } -fn handle_explain(handler: &EarlyDiagCtxt, registry: Registry, code: &str, color: ColorConfig) { +fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, color: ColorConfig) { let upper_cased_code = code.to_ascii_uppercase(); let normalised = if upper_cased_code.starts_with('E') { upper_cased_code } else { format!("E{code:0>4}") }; @@ -567,7 +567,7 @@ fn handle_explain(handler: &EarlyDiagCtxt, registry: Registry, code: &str, color } } Err(InvalidErrorCode) => { - handler.early_error(format!("{code} is not a valid error code")); + early_dcx.early_error(format!("{code} is not a valid error code")); } } } @@ -669,7 +669,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) { } } -fn list_metadata(handler: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn MetadataLoader) { +fn list_metadata(early_dcx: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn MetadataLoader) { match sess.io.input { Input::File(ref ifile) => { let path = &(*ifile); @@ -685,13 +685,13 @@ fn list_metadata(handler: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn safe_println!("{}", String::from_utf8(v).unwrap()); } Input::Str { .. } => { - handler.early_error("cannot list metadata for stdin"); + early_dcx.early_error("cannot list metadata for stdin"); } } } fn print_crate_info( - handler: &EarlyDiagCtxt, + early_dcx: &EarlyDiagCtxt, codegen_backend: &dyn CodegenBackend, sess: &Session, parse_attrs: bool, @@ -838,7 +838,7 @@ fn print_crate_info( .expect("unknown Apple target OS"); println_info!("deployment_target={}", format!("{major}.{minor}")) } else { - handler + early_dcx .early_error("only Apple targets currently support deployment version info") } } @@ -869,7 +869,7 @@ pub macro version($handler: expr, $binary: literal, $matches: expr) { #[doc(hidden)] // use the macro instead pub fn version_at_macro_invocation( - handler: &EarlyDiagCtxt, + early_dcx: &EarlyDiagCtxt, binary: &str, matches: &getopts::Matches, version: &str, @@ -890,7 +890,7 @@ pub fn version_at_macro_invocation( let debug_flags = matches.opt_strs("Z"); let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); - get_codegen_backend(handler, &None, backend_name).print_version(); + get_codegen_backend(early_dcx, &None, backend_name).print_version(); } } @@ -1068,7 +1068,7 @@ Available lint options: /// Show help for flag categories shared between rustdoc and rustc. /// /// Returns whether a help option was printed. -pub fn describe_flag_categories(handler: &EarlyDiagCtxt, matches: &Matches) -> bool { +pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) -> bool { // Handle the special case of -Wall. let wall = matches.opt_strs("W"); if wall.iter().any(|x| *x == "all") { @@ -1090,12 +1090,12 @@ pub fn describe_flag_categories(handler: &EarlyDiagCtxt, matches: &Matches) -> b } if cg_flags.iter().any(|x| *x == "no-stack-check") { - handler.early_warn("the --no-stack-check flag is deprecated and does nothing"); + early_dcx.early_warn("the --no-stack-check flag is deprecated and does nothing"); } if cg_flags.iter().any(|x| *x == "passes=list") { let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); - get_codegen_backend(handler, &None, backend_name).print_passes(); + get_codegen_backend(early_dcx, &None, backend_name).print_passes(); return true; } @@ -1156,7 +1156,7 @@ fn print_flag_list( /// This does not need to be `pub` for rustc itself, but @chaosite needs it to /// be public when using rustc as a library, see /// -pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option { +pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option { if args.is_empty() { // user did not write `-v` nor `-Z unstable-options`, so do not // include that extra information. @@ -1182,7 +1182,7 @@ pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option None, }; - handler.early_error(msg.unwrap_or_else(|| e.to_string())); + early_dcx.early_error(msg.unwrap_or_else(|| e.to_string())); }); // For all options we just parsed, we check a few aspects: @@ -1196,7 +1196,7 @@ pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option Option