@@ -51,7 +51,8 @@ use rustc_metadata::creader::MetadataLoader;
51
51
use rustc_metadata:: locator;
52
52
use rustc_parse:: { new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal} ;
53
53
use rustc_session:: config:: {
54
- nightly_options, ErrorOutputType , Input , OutFileName , OutputType , CG_OPTIONS , Z_OPTIONS ,
54
+ nightly_options, ErrorOutputType , Input , OutFileName , OutputType , UnstableOptions , CG_OPTIONS ,
55
+ Z_OPTIONS ,
55
56
} ;
56
57
use rustc_session:: getopts:: { self , Matches } ;
57
58
use rustc_session:: lint:: { Lint , LintId } ;
@@ -301,6 +302,8 @@ fn run_compiler(
301
302
let Some ( matches) = handle_options( & default_early_dcx, & args) else { return Ok ( ( ) ) } ;
302
303
303
304
let sopts = config:: build_session_options( & mut default_early_dcx, & matches) ;
305
+ // fully initialize ice path static once unstable options are available as context
306
+ let _ = ice_path_with_config( Some ( & sopts. unstable_opts) ) ;
304
307
305
308
if let Some ( ref code) = matches. opt_str( "explain" ) {
306
309
handle_explain( & default_early_dcx, diagnostics_registry( ) , code, sopts. color) ;
@@ -1307,15 +1310,14 @@ pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
1307
1310
static ICE_PATH : OnceLock <Option <PathBuf >> = OnceLock :: new( ) ;
1308
1311
1309
1312
fn ice_path( ) -> & ' static Option <PathBuf > {
1313
+ ice_path_with_config( None )
1314
+ }
1315
+
1316
+ fn ice_path_with_config( config: Option <& UnstableOptions >) -> & ' static Option <PathBuf > {
1310
1317
ICE_PATH . get_or_init( || {
1311
1318
if !rustc_feature:: UnstableFeatures :: from_environment( None ) . is_nightly_build( ) {
1312
1319
return None ;
1313
1320
}
1314
- if let Some ( s) = std:: env:: var_os( "RUST_BACKTRACE" )
1315
- && s == "0"
1316
- {
1317
- return None ;
1318
- }
1319
1321
let mut path = match std:: env:: var_os( "RUSTC_ICE" ) {
1320
1322
Some ( s) => {
1321
1323
if s == "0" {
@@ -1324,7 +1326,10 @@ fn ice_path() -> &'static Option<PathBuf> {
1324
1326
}
1325
1327
PathBuf :: from( s)
1326
1328
}
1327
- None => std:: env:: current_dir( ) . unwrap_or_default( ) ,
1329
+ None => config
1330
+ . and_then( |unstable_opts| unstable_opts. error_metrics. to_owned( ) )
1331
+ . or_else( || std:: env:: current_dir( ) . ok( ) )
1332
+ . unwrap_or_default( ) ,
1328
1333
} ;
1329
1334
let now: OffsetDateTime = SystemTime :: now( ) . into( ) ;
1330
1335
let file_now = now
0 commit comments