@@ -495,7 +495,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<OutFileNa
495
495
496
496
// Extract input (string or file and optional path) from matches.
497
497
fn make_input(
498
- handler : & EarlyDiagCtxt ,
498
+ early_dcx : & EarlyDiagCtxt ,
499
499
free_matches: & [ String ] ,
500
500
) -> Result <Option <Input >, ErrorGuaranteed > {
501
501
if free_matches. len( ) == 1 {
@@ -505,7 +505,7 @@ fn make_input(
505
505
if io:: stdin( ) . read_to_string( & mut src) . is_err( ) {
506
506
// Immediately stop compilation if there was an issue reading
507
507
// 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(
509
509
"couldn't read from stdin, as it did not contain valid UTF-8" ,
510
510
) ;
511
511
return Err ( reported) ;
@@ -537,7 +537,7 @@ pub enum Compilation {
537
537
Continue ,
538
538
}
539
539
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 ) {
541
541
let upper_cased_code = code. to_ascii_uppercase( ) ;
542
542
let normalised =
543
543
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
567
567
}
568
568
}
569
569
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" ) ) ;
571
571
}
572
572
}
573
573
}
@@ -669,7 +669,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
669
669
}
670
670
}
671
671
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 ) {
673
673
match sess. io. input {
674
674
Input :: File ( ref ifile) => {
675
675
let path = & ( * ifile) ;
@@ -685,13 +685,13 @@ fn list_metadata(handler: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn
685
685
safe_println!( "{}" , String :: from_utf8( v) . unwrap( ) ) ;
686
686
}
687
687
Input :: Str { .. } => {
688
- handler . early_error( "cannot list metadata for stdin" ) ;
688
+ early_dcx . early_error( "cannot list metadata for stdin" ) ;
689
689
}
690
690
}
691
691
}
692
692
693
693
fn print_crate_info(
694
- handler : & EarlyDiagCtxt ,
694
+ early_dcx : & EarlyDiagCtxt ,
695
695
codegen_backend: & dyn CodegenBackend ,
696
696
sess: & Session ,
697
697
parse_attrs: bool ,
@@ -838,7 +838,7 @@ fn print_crate_info(
838
838
. expect( "unknown Apple target OS" ) ;
839
839
println_info!( "deployment_target={}" , format!( "{major}.{minor}" ) )
840
840
} else {
841
- handler
841
+ early_dcx
842
842
. early_error( "only Apple targets currently support deployment version info" )
843
843
}
844
844
}
@@ -869,7 +869,7 @@ pub macro version($handler: expr, $binary: literal, $matches: expr) {
869
869
870
870
#[ doc( hidden) ] // use the macro instead
871
871
pub fn version_at_macro_invocation(
872
- handler : & EarlyDiagCtxt ,
872
+ early_dcx : & EarlyDiagCtxt ,
873
873
binary: & str ,
874
874
matches: & getopts:: Matches ,
875
875
version: & str ,
@@ -890,7 +890,7 @@ pub fn version_at_macro_invocation(
890
890
891
891
let debug_flags = matches. opt_strs( "Z" ) ;
892
892
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( ) ;
894
894
}
895
895
}
896
896
@@ -1068,7 +1068,7 @@ Available lint options:
1068
1068
/// Show help for flag categories shared between rustdoc and rustc.
1069
1069
///
1070
1070
/// 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 {
1072
1072
// Handle the special case of -Wall.
1073
1073
let wall = matches. opt_strs( "W" ) ;
1074
1074
if wall. iter( ) . any( |x| * x == "all" ) {
@@ -1090,12 +1090,12 @@ pub fn describe_flag_categories(handler: &EarlyDiagCtxt, matches: &Matches) -> b
1090
1090
}
1091
1091
1092
1092
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" ) ;
1094
1094
}
1095
1095
1096
1096
if cg_flags. iter( ) . any( |x| * x == "passes=list" ) {
1097
1097
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( ) ;
1099
1099
return true ;
1100
1100
}
1101
1101
@@ -1156,7 +1156,7 @@ fn print_flag_list<T>(
1156
1156
/// This does not need to be `pub` for rustc itself, but @chaosite needs it to
1157
1157
/// be public when using rustc as a library, see
1158
1158
/// <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 > {
1160
1160
if args. is_empty( ) {
1161
1161
// user did not write `-v` nor `-Z unstable-options`, so do not
1162
1162
// include that extra information.
@@ -1182,7 +1182,7 @@ pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option<getopt
1182
1182
. map( |( flag, _) | format!( "{e}. Did you mean `-{flag} {opt}`?" ) ) ,
1183
1183
_ => None ,
1184
1184
} ;
1185
- handler . early_error( msg. unwrap_or_else( || e. to_string( ) ) ) ;
1185
+ early_dcx . early_error( msg. unwrap_or_else( || e. to_string( ) ) ) ;
1186
1186
} ) ;
1187
1187
1188
1188
// 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
1196
1196
// we're good to go.
1197
1197
// * Otherwise, if we're an unstable option then we generate an error
1198
1198
// (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( ) ) ;
1200
1200
1201
1201
if matches. opt_present( "h" ) || matches. opt_present( "help" ) {
1202
1202
// 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
1206
1206
return None ;
1207
1207
}
1208
1208
1209
- if describe_flag_categories( handler , & matches) {
1209
+ if describe_flag_categories( early_dcx , & matches) {
1210
1210
return None ;
1211
1211
}
1212
1212
1213
1213
if matches. opt_present( "version" ) {
1214
- version!( handler , "rustc" , & matches) ;
1214
+ version!( early_dcx , "rustc" , & matches) ;
1215
1215
return None ;
1216
1216
}
1217
1217
@@ -1472,16 +1472,16 @@ fn report_ice(
1472
1472
1473
1473
/// This allows tools to enable rust logging without having to magically match rustc's
1474
1474
/// 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" ) ) ;
1477
1477
}
1478
1478
1479
1479
/// This allows tools to enable rust logging without having to magically match rustc's
1480
1480
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose
1481
1481
/// 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 ) {
1483
1483
if let Err ( error) = rustc_log:: init_logger( cfg) {
1484
- handler . early_error( error. to_string( ) ) ;
1484
+ early_dcx . early_error( error. to_string( ) ) ;
1485
1485
}
1486
1486
}
1487
1487
0 commit comments