@@ -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.
497497fn make_input(
498- handler : & EarlyDiagCtxt ,
498+ early_dcx : & EarlyDiagCtxt ,
499499 free_matches: & [ String ] ,
500500) -> Result <Option <Input >, ErrorGuaranteed > {
501501 if free_matches. len( ) == 1 {
@@ -505,7 +505,7 @@ fn make_input(
505505 if io:: stdin( ) . read_to_string( & mut src) . is_err( ) {
506506 // Immediately stop compilation if there was an issue reading
507507 // the input (for example if the input stream is not UTF-8).
508- let reported = handler . early_error_no_abort(
508+ let reported = early_dcx . early_error_no_abort(
509509 "couldn't read from stdin, as it did not contain valid UTF-8" ,
510510 ) ;
511511 return Err ( reported) ;
@@ -537,7 +537,7 @@ pub enum Compilation {
537537 Continue ,
538538}
539539
540- fn handle_explain( handler : & EarlyDiagCtxt , registry: Registry , code: & str , color: ColorConfig ) {
540+ fn handle_explain( early_dcx : & 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}" ) } ;
@@ -567,7 +567,7 @@ fn handle_explain(handler: &EarlyDiagCtxt, registry: Registry, code: &str, color
567567 }
568568 }
569569 Err ( InvalidErrorCode ) => {
570- handler . early_error( format!( "{code} is not a valid error code" ) ) ;
570+ early_dcx . early_error( format!( "{code} is not a valid error code" ) ) ;
571571 }
572572 }
573573}
@@ -669,7 +669,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
669669 }
670670}
671671
672- fn list_metadata( handler : & EarlyDiagCtxt , sess: & Session , metadata_loader: & dyn MetadataLoader ) {
672+ fn list_metadata( early_dcx : & EarlyDiagCtxt , sess: & Session , metadata_loader: & dyn MetadataLoader ) {
673673 match sess. io. input {
674674 Input :: File ( ref ifile) => {
675675 let path = & ( * ifile) ;
@@ -685,13 +685,13 @@ fn list_metadata(handler: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn
685685 safe_println!( "{}" , String :: from_utf8( v) . unwrap( ) ) ;
686686 }
687687 Input :: Str { .. } => {
688- handler . early_error( "cannot list metadata for stdin" ) ;
688+ early_dcx . early_error( "cannot list metadata for stdin" ) ;
689689 }
690690 }
691691}
692692
693693fn print_crate_info(
694- handler : & EarlyDiagCtxt ,
694+ early_dcx : & EarlyDiagCtxt ,
695695 codegen_backend: & dyn CodegenBackend ,
696696 sess: & Session ,
697697 parse_attrs: bool ,
@@ -838,7 +838,7 @@ fn print_crate_info(
838838 . expect( "unknown Apple target OS" ) ;
839839 println_info!( "deployment_target={}" , format!( "{major}.{minor}" ) )
840840 } else {
841- handler
841+ early_dcx
842842 . early_error( "only Apple targets currently support deployment version info" )
843843 }
844844 }
@@ -869,7 +869,7 @@ pub macro version($handler: expr, $binary: literal, $matches: expr) {
869869
870870#[ doc( hidden) ] // use the macro instead
871871pub fn version_at_macro_invocation(
872- handler : & EarlyDiagCtxt ,
872+ early_dcx : & EarlyDiagCtxt ,
873873 binary: & str ,
874874 matches: & getopts:: Matches ,
875875 version: & str ,
@@ -890,7 +890,7 @@ pub fn version_at_macro_invocation(
890890
891891 let debug_flags = matches. opt_strs( "Z" ) ;
892892 let backend_name = debug_flags. iter( ) . find_map( |x| x. strip_prefix( "codegen-backend=" ) ) ;
893- get_codegen_backend( handler , & None , backend_name) . print_version( ) ;
893+ get_codegen_backend( early_dcx , & None , backend_name) . print_version( ) ;
894894 }
895895}
896896
@@ -1068,7 +1068,7 @@ Available lint options:
10681068/// Show help for flag categories shared between rustdoc and rustc.
10691069///
10701070/// Returns whether a help option was printed.
1071- pub fn describe_flag_categories( handler : & EarlyDiagCtxt , matches: & Matches ) -> bool {
1071+ pub fn describe_flag_categories( early_dcx : & EarlyDiagCtxt , matches: & Matches ) -> bool {
10721072 // Handle the special case of -Wall.
10731073 let wall = matches. opt_strs( "W" ) ;
10741074 if wall. iter( ) . any( |x| * x == "all" ) {
@@ -1090,12 +1090,12 @@ pub fn describe_flag_categories(handler: &EarlyDiagCtxt, matches: &Matches) -> b
10901090 }
10911091
10921092 if cg_flags. iter( ) . any( |x| * x == "no-stack-check" ) {
1093- handler . early_warn( "the --no-stack-check flag is deprecated and does nothing" ) ;
1093+ early_dcx . early_warn( "the --no-stack-check flag is deprecated and does nothing" ) ;
10941094 }
10951095
10961096 if cg_flags. iter( ) . any( |x| * x == "passes=list" ) {
10971097 let backend_name = debug_flags. iter( ) . find_map( |x| x. strip_prefix( "codegen-backend=" ) ) ;
1098- get_codegen_backend( handler , & None , backend_name) . print_passes( ) ;
1098+ get_codegen_backend( early_dcx , & None , backend_name) . print_passes( ) ;
10991099 return true ;
11001100 }
11011101
@@ -1156,7 +1156,7 @@ fn print_flag_list<T>(
11561156/// This does not need to be `pub` for rustc itself, but @chaosite needs it to
11571157/// be public when using rustc as a library, see
11581158/// <https://github.com/rust-lang/rust/commit/2b4c33817a5aaecabf4c6598d41e190080ec119e>
1159- pub fn handle_options( handler : & EarlyDiagCtxt , args: & [ String ] ) -> Option <getopts:: Matches > {
1159+ pub fn handle_options( early_dcx : & EarlyDiagCtxt , args: & [ String ] ) -> Option <getopts:: Matches > {
11601160 if args. is_empty( ) {
11611161 // user did not write `-v` nor `-Z unstable-options`, so do not
11621162 // include that extra information.
@@ -1182,7 +1182,7 @@ pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option<getopt
11821182 . map( |( flag, _) | format!( "{e}. Did you mean `-{flag} {opt}`?" ) ) ,
11831183 _ => None ,
11841184 } ;
1185- handler . early_error( msg. unwrap_or_else( || e. to_string( ) ) ) ;
1185+ early_dcx . early_error( msg. unwrap_or_else( || e. to_string( ) ) ) ;
11861186 } ) ;
11871187
11881188 // For all options we just parsed, we check a few aspects:
@@ -1196,7 +1196,7 @@ pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option<getopt
11961196 // we're good to go.
11971197 // * Otherwise, if we're an unstable option then we generate an error
11981198 // (unstable option being used on stable)
1199- nightly_options:: check_nightly_options( handler , & matches, & config:: rustc_optgroups( ) ) ;
1199+ nightly_options:: check_nightly_options( early_dcx , & matches, & config:: rustc_optgroups( ) ) ;
12001200
12011201 if matches. opt_present( "h" ) || matches. opt_present( "help" ) {
12021202 // Only show unstable options in --help if we accept unstable options.
@@ -1206,12 +1206,12 @@ pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option<getopt
12061206 return None ;
12071207 }
12081208
1209- if describe_flag_categories( handler , & matches) {
1209+ if describe_flag_categories( early_dcx , & matches) {
12101210 return None ;
12111211 }
12121212
12131213 if matches. opt_present( "version" ) {
1214- version!( handler , "rustc" , & matches) ;
1214+ version!( early_dcx , "rustc" , & matches) ;
12151215 return None ;
12161216 }
12171217
@@ -1472,16 +1472,16 @@ fn report_ice(
14721472
14731473/// This allows tools to enable rust logging without having to magically match rustc's
14741474/// tracing crate version.
1475- pub fn init_rustc_env_logger( handler : & EarlyDiagCtxt ) {
1476- init_logger( handler , rustc_log:: LoggerConfig :: from_env( "RUSTC_LOG" ) ) ;
1475+ pub fn init_rustc_env_logger( early_dcx : & EarlyDiagCtxt ) {
1476+ init_logger( early_dcx , rustc_log:: LoggerConfig :: from_env( "RUSTC_LOG" ) ) ;
14771477}
14781478
14791479/// This allows tools to enable rust logging without having to magically match rustc's
14801480/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose
14811481/// the values directly rather than having to set an environment variable.
1482- pub fn init_logger( handler : & EarlyDiagCtxt , cfg: rustc_log:: LoggerConfig ) {
1482+ pub fn init_logger( early_dcx : & EarlyDiagCtxt , cfg: rustc_log:: LoggerConfig ) {
14831483 if let Err ( error) = rustc_log:: init_logger( cfg) {
1484- handler . early_error( error. to_string( ) ) ;
1484+ early_dcx . early_error( error. to_string( ) ) ;
14851485 }
14861486}
14871487
0 commit comments