@@ -19,10 +19,10 @@ extern crate tracing;
19
19
20
20
use rustc_ast as ast;
21
21
use rustc_codegen_ssa:: { traits:: CodegenBackend , CodegenErrors , CodegenResults } ;
22
+ use rustc_const_eval:: CTRL_C_RECEIVED ;
22
23
use rustc_data_structures:: profiling:: {
23
24
get_resident_set_size, print_time_passes_entry, TimePassesFormat ,
24
25
} ;
25
- use rustc_data_structures:: CTRL_C_RECEIVED ;
26
26
use rustc_errors:: emitter:: stderr_destination;
27
27
use rustc_errors:: registry:: Registry ;
28
28
use rustc_errors:: {
@@ -1506,17 +1506,9 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
1506
1506
}
1507
1507
}
1508
1508
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( ) {
1520
1512
ctrlc:: set_handler( move || {
1521
1513
// Indicate that we have been signaled to stop. If we were already signaled, exit
1522
1514
// immediately. In our interpreter loop we try to consult this value often, but if for
@@ -1528,6 +1520,19 @@ pub fn main() -> ! {
1528
1520
}
1529
1521
} )
1530
1522
. 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( ) ;
1531
1536
1532
1537
let exit_code = catch_with_exit_code( || {
1533
1538
RunCompiler :: new( & args:: raw_args( & early_dcx) ?, & mut callbacks)
0 commit comments