@@ -19,10 +19,10 @@ extern crate tracing;
1919
2020use rustc_ast as ast;
2121use rustc_codegen_ssa:: { traits:: CodegenBackend , CodegenErrors , CodegenResults } ;
22+ use rustc_const_eval:: CTRL_C_RECEIVED ;
2223use rustc_data_structures:: profiling:: {
2324 get_resident_set_size, print_time_passes_entry, TimePassesFormat ,
2425} ;
25- use rustc_data_structures:: CTRL_C_RECEIVED ;
2626use rustc_errors:: emitter:: stderr_destination;
2727use rustc_errors:: registry:: Registry ;
2828use rustc_errors:: {
@@ -1506,17 +1506,9 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
15061506 }
15071507}
15081508
1509- pub fn main( ) -> ! {
1510- let start_time = Instant :: now( ) ;
1511- let start_rss = get_resident_set_size( ) ;
1512-
1513- let early_dcx = EarlyDiagCtxt :: new( ErrorOutputType :: default ( ) ) ;
1514-
1515- init_rustc_env_logger( & early_dcx) ;
1516- signal_handler:: install( ) ;
1517- let mut callbacks = TimePassesCallbacks :: default ( ) ;
1518- let using_internal_features = install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
1519-
1509+ /// Install our usual `ctrlc` handler, which sets [`rustc_const_eval::CTRL_C_RECEIVED`].
1510+ /// Makign this handler optional lets tools can install a different handler, if they wish.
1511+ pub fn install_ctrlc_handler( ) {
15201512 ctrlc:: set_handler( move || {
15211513 // Indicate that we have been signaled to stop. If we were already signaled, exit
15221514 // immediately. In our interpreter loop we try to consult this value often, but if for
@@ -1528,6 +1520,19 @@ pub fn main() -> ! {
15281520 }
15291521 } )
15301522 . expect( "Unable to install ctrlc handler" ) ;
1523+ }
1524+
1525+ pub fn main( ) -> ! {
1526+ let start_time = Instant :: now( ) ;
1527+ let start_rss = get_resident_set_size( ) ;
1528+
1529+ let early_dcx = EarlyDiagCtxt :: new( ErrorOutputType :: default ( ) ) ;
1530+
1531+ init_rustc_env_logger( & early_dcx) ;
1532+ signal_handler:: install( ) ;
1533+ let mut callbacks = TimePassesCallbacks :: default ( ) ;
1534+ let using_internal_features = install_ice_hook( DEFAULT_BUG_REPORT_URL , |_| ( ) ) ;
1535+ install_ctrlc_handler( ) ;
15311536
15321537 let exit_code = catch_with_exit_code( || {
15331538 RunCompiler :: new( & args:: raw_args( & early_dcx) ?, & mut callbacks)
0 commit comments