@@ -42,7 +42,7 @@ pub struct Compiler {
4242}
4343
4444/// Converts strings provided as `--cfg [cfgspec]` into a `Cfg`.
45- pub ( crate ) fn parse_cfg ( handler : & EarlyErrorHandler , cfgs : Vec < String > ) -> Cfg {
45+ pub ( crate ) fn parse_cfg ( handler : & Handler , cfgs : Vec < String > ) -> Cfg {
4646 cfgs. into_iter ( )
4747 . map ( |s| {
4848 let sess = ParseSess :: with_silent_emitter ( Some ( format ! (
@@ -52,10 +52,14 @@ pub(crate) fn parse_cfg(handler: &EarlyErrorHandler, cfgs: Vec<String>) -> Cfg {
5252
5353 macro_rules! error {
5454 ( $reason: expr) => {
55- handler. early_error( format!(
56- concat!( "invalid `--cfg` argument: `{}` (" , $reason, ")" ) ,
57- s
58- ) ) ;
55+ #[ allow( rustc:: untranslatable_diagnostic) ]
56+ #[ allow( rustc:: diagnostic_outside_of_impl) ]
57+ handler
58+ . struct_fatal( format!(
59+ concat!( "invalid `--cfg` argument: `{}` (" , $reason, ")" ) ,
60+ s
61+ ) )
62+ . emit( ) ;
5963 } ;
6064 }
6165
@@ -97,7 +101,7 @@ pub(crate) fn parse_cfg(handler: &EarlyErrorHandler, cfgs: Vec<String>) -> Cfg {
97101}
98102
99103/// Converts strings provided as `--check-cfg [specs]` into a `CheckCfg`.
100- pub ( crate ) fn parse_check_cfg ( handler : & EarlyErrorHandler , specs : Vec < String > ) -> CheckCfg {
104+ pub ( crate ) fn parse_check_cfg ( handler : & Handler , specs : Vec < String > ) -> CheckCfg {
101105 // If any --check-cfg is passed then exhaustive_values and exhaustive_names
102106 // are enabled by default.
103107 let exhaustive_names = !specs. is_empty ( ) ;
@@ -113,10 +117,14 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
113117
114118 macro_rules! error {
115119 ( $reason: expr) => {
116- handler. early_error( format!(
117- concat!( "invalid `--check-cfg` argument: `{}` (" , $reason, ")" ) ,
118- s
119- ) )
120+ #[ allow( rustc:: untranslatable_diagnostic) ]
121+ #[ allow( rustc:: diagnostic_outside_of_impl) ]
122+ handler
123+ . struct_fatal( format!(
124+ concat!( "invalid `--check-cfg` argument: `{}` (" , $reason, ")" ) ,
125+ s
126+ ) )
127+ . emit( )
120128 } ;
121129 }
122130
@@ -388,13 +396,13 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
388396 || {
389397 crate :: callbacks:: setup_callbacks ( ) ;
390398
391- let handler = EarlyErrorHandler :: new ( config. opts . error_format ) ;
399+ let early_handler = EarlyErrorHandler :: new ( config. opts . error_format ) ;
392400
393401 let codegen_backend = if let Some ( make_codegen_backend) = config. make_codegen_backend {
394402 make_codegen_backend ( & config. opts )
395403 } else {
396404 util:: get_codegen_backend (
397- & handler ,
405+ & early_handler ,
398406 & config. opts . maybe_sysroot ,
399407 config. opts . unstable_opts . codegen_backend . as_deref ( ) ,
400408 )
@@ -411,7 +419,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
411419 ) {
412420 Ok ( bundle) => bundle,
413421 Err ( e) => {
414- handler . early_error ( format ! ( "failed to load fluent bundle: {e}" ) ) ;
422+ early_handler . early_error ( format ! ( "failed to load fluent bundle: {e}" ) ) ;
415423 }
416424 } ;
417425
@@ -422,7 +430,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
422430 let target_override = codegen_backend. target_override ( & config. opts ) ;
423431
424432 let mut sess = rustc_session:: build_session (
425- & handler ,
433+ early_handler ,
426434 config. opts ,
427435 CompilerIO {
428436 input : config. input ,
@@ -444,12 +452,12 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
444452
445453 codegen_backend. init ( & sess) ;
446454
447- let cfg = parse_cfg ( & handler , config. crate_cfg ) ;
455+ let cfg = parse_cfg ( & sess . diagnostic ( ) , config. crate_cfg ) ;
448456 let mut cfg = config:: build_configuration ( & sess, cfg) ;
449457 util:: add_configuration ( & mut cfg, & mut sess, & * codegen_backend) ;
450458 sess. parse_sess . config = cfg;
451459
452- let mut check_cfg = parse_check_cfg ( & handler , config. crate_check_cfg ) ;
460+ let mut check_cfg = parse_check_cfg ( & sess . diagnostic ( ) , config. crate_check_cfg ) ;
453461 check_cfg. fill_well_known ( & sess. target ) ;
454462 sess. parse_sess . check_config = check_cfg;
455463
0 commit comments