@@ -42,7 +42,7 @@ pub struct Compiler {
42
42
}
43
43
44
44
/// 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 {
46
46
cfgs. into_iter ( )
47
47
. map ( |s| {
48
48
let sess = ParseSess :: with_silent_emitter ( Some ( format ! (
@@ -52,10 +52,14 @@ pub(crate) fn parse_cfg(handler: &EarlyErrorHandler, cfgs: Vec<String>) -> Cfg {
52
52
53
53
macro_rules! error {
54
54
( $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( ) ;
59
63
} ;
60
64
}
61
65
@@ -97,7 +101,10 @@ pub(crate) fn parse_cfg(handler: &EarlyErrorHandler, cfgs: Vec<String>) -> Cfg {
97
101
}
98
102
99
103
/// Converts strings provided as `--check-cfg [specs]` into a `CheckCfg`.
100
- pub ( crate ) fn parse_check_cfg ( handler : & EarlyErrorHandler , specs : Vec < String > ) -> CheckCfg {
104
+ // njn: temp
105
+ #[ allow( rustc:: untranslatable_diagnostic) ]
106
+ #[ allow( rustc:: diagnostic_outside_of_impl) ]
107
+ pub ( crate ) fn parse_check_cfg ( handler : & Handler , specs : Vec < String > ) -> CheckCfg {
101
108
// If any --check-cfg is passed then exhaustive_values and exhaustive_names
102
109
// are enabled by default.
103
110
let exhaustive_names = !specs. is_empty ( ) ;
@@ -113,10 +120,14 @@ pub(crate) fn parse_check_cfg(handler: &EarlyErrorHandler, specs: Vec<String>) -
113
120
114
121
macro_rules! error {
115
122
( $reason: expr) => {
116
- handler. early_error( format!(
117
- concat!( "invalid `--check-cfg` argument: `{}` (" , $reason, ")" ) ,
118
- s
119
- ) )
123
+ #[ allow( rustc:: untranslatable_diagnostic) ]
124
+ #[ allow( rustc:: diagnostic_outside_of_impl) ]
125
+ handler
126
+ . struct_fatal( format!(
127
+ concat!( "invalid `--check-cfg` argument: `{}` (" , $reason, ")" ) ,
128
+ s
129
+ ) )
130
+ . emit( )
120
131
} ;
121
132
}
122
133
@@ -388,13 +399,13 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
388
399
|| {
389
400
crate :: callbacks:: setup_callbacks ( ) ;
390
401
391
- let handler = EarlyErrorHandler :: new ( config. opts . error_format ) ;
402
+ let early_handler = EarlyErrorHandler :: new ( config. opts . error_format ) ;
392
403
393
404
let codegen_backend = if let Some ( make_codegen_backend) = config. make_codegen_backend {
394
405
make_codegen_backend ( & config. opts )
395
406
} else {
396
407
util:: get_codegen_backend (
397
- & handler ,
408
+ & early_handler ,
398
409
& config. opts . maybe_sysroot ,
399
410
config. opts . unstable_opts . codegen_backend . as_deref ( ) ,
400
411
)
@@ -411,7 +422,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
411
422
) {
412
423
Ok ( bundle) => bundle,
413
424
Err ( e) => {
414
- handler . early_error ( format ! ( "failed to load fluent bundle: {e}" ) ) ;
425
+ early_handler . early_error ( format ! ( "failed to load fluent bundle: {e}" ) ) ;
415
426
}
416
427
} ;
417
428
@@ -422,7 +433,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
422
433
let target_override = codegen_backend. target_override ( & config. opts ) ;
423
434
424
435
let mut sess = rustc_session:: build_session (
425
- & handler ,
436
+ early_handler ,
426
437
config. opts ,
427
438
CompilerIO {
428
439
input : config. input ,
@@ -444,12 +455,12 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
444
455
445
456
codegen_backend. init ( & sess) ;
446
457
447
- let cfg = parse_cfg ( & handler , config. crate_cfg ) ;
458
+ let cfg = parse_cfg ( & sess . diagnostic ( ) , config. crate_cfg ) ;
448
459
let mut cfg = config:: build_configuration ( & sess, cfg) ;
449
460
util:: add_configuration ( & mut cfg, & mut sess, & * codegen_backend) ;
450
461
sess. parse_sess . config = cfg;
451
462
452
- let mut check_cfg = parse_check_cfg ( & handler , config. crate_check_cfg ) ;
463
+ let mut check_cfg = parse_check_cfg ( & sess . diagnostic ( ) , config. crate_check_cfg ) ;
453
464
check_cfg. fill_well_known ( & sess. target ) ;
454
465
sess. parse_sess . check_config = check_cfg;
455
466
0 commit comments