1- #![ feature( array_windows) ]
21#![ feature( decl_macro) ]
3- #![ feature( if_let_guard) ]
42
53#![ feature( rustc_private) ]
4+ extern crate rustc_data_structures;
65extern crate rustc_driver;
7- extern crate rustc_hash;
86extern crate rustc_interface;
97extern crate rustc_session;
108extern crate rustc_span;
@@ -21,7 +19,7 @@ use mutest_driver::passes::external_mutant::RustcInvocation;
2119use mutest_driver_cli:: { UnstableFlag , UnstableOption } ;
2220use mutest_emit:: analysis:: hir:: Safety ;
2321use mutest_emit:: codegen:: mutation:: { OperatorRef , UnsafeTargeting } ;
24- use rustc_hash :: FxHashSet ;
22+ use rustc_data_structures :: fx :: FxHashSet ;
2523use rustc_interface:: Config as CompilerConfig ;
2624use rustc_session:: EarlyDiagCtxt ;
2725use rustc_session:: config:: { CrateType , ErrorOutputType , Input } ;
@@ -38,8 +36,8 @@ struct RustcCallbacks {
3836impl rustc_driver:: Callbacks for RustcCallbacks {
3937 fn config ( & mut self , config : & mut CompilerConfig ) {
4038 let args = self . mutest_args . take ( ) ;
41- config. psess_created = Some ( Box :: new ( move |parse_sess | {
42- mutest_driver:: passes:: track_invocation_fingerprint ( parse_sess , args. as_deref ( ) ) ;
39+ config. track_state = Some ( Box :: new ( move |sess | {
40+ mutest_driver:: passes:: track_invocation_fingerprint ( sess , args. as_deref ( ) ) ;
4341 } ) ) ;
4442 }
4543}
@@ -146,7 +144,7 @@ const UNSTABLE_OPTIONS: &[UnstableOption] = mutest_driver_cli::extend_const_slic
146144
147145const BUG_REPORT_URL : & str = "https://github.com/zalanlevai/mutest-rs/issues/new" ;
148146
149- pub fn main ( ) {
147+ pub fn main ( ) -> process :: ExitCode {
150148 let early_dcx = EarlyDiagCtxt :: new ( ErrorOutputType :: default ( ) ) ;
151149 let mut args = rustc_driver:: args:: raw_args ( & early_dcx) ;
152150
@@ -168,9 +166,9 @@ pub fn main() {
168166 args. remove ( marker_arg_position) ;
169167 args[ 0 ] = "rustc" . to_owned ( ) ;
170168
171- process :: exit ( rustc_driver:: catch_with_exit_code ( || {
169+ return rustc_driver:: catch_with_exit_code ( || {
172170 rustc_driver:: run_compiler ( & args, & mut DefaultCallbacks )
173- } ) ) ;
171+ } ) ;
174172 }
175173
176174 // Parser for non-rustc, mutest-specific arguments provided through MUTEST_ARGS / MUTEST_ENCODED_ARGS.
@@ -191,15 +189,15 @@ pub fn main() {
191189 // NOTE: The exit calls are actually unreachable, but it is good to have them just in case.
192190 if args. iter ( ) . any ( |arg| arg == "-V" || arg == "--version" ) {
193191 let _ = mutest_command. get_matches_from ( [ "--version" ] ) ;
194- process:: exit ( 0 ) ;
192+ return process:: ExitCode :: SUCCESS ;
195193 }
196194 if args. iter ( ) . any ( |arg| arg == "-h" ) {
197195 let _ = mutest_command. get_matches_from ( [ "-h" ] ) ;
198- process:: exit ( 0 ) ;
196+ return process:: ExitCode :: SUCCESS ;
199197 }
200198 if args. iter ( ) . any ( |arg| arg == "--help" ) {
201199 let _ = mutest_command. get_matches_from ( [ "--help" ] ) ;
202- process:: exit ( 0 ) ;
200+ return process:: ExitCode :: SUCCESS ;
203201 }
204202 }
205203
@@ -229,24 +227,24 @@ pub fn main() {
229227
230228 // Fall back to a rustc invocation if mutest is not "enabled" for the given crate based on invocation.
231229 if info_query || ( cargo_invocation && !primary_package) || proc_macro_target || ( bin_target && !test_target) {
232- process :: exit ( rustc_driver:: catch_with_exit_code ( || {
230+ return rustc_driver:: catch_with_exit_code ( || {
233231 rustc_driver:: run_compiler ( & args, & mut RustcCallbacks { mutest_args : mutest_args_str } )
234- } ) ) ;
232+ } ) ;
235233 }
236234
237235 let mutest_arg_matches = mutest_command. get_matches_from ( mutest_args. unwrap_or_default ( ) ) ;
238236
239237 let unstable_flags = mutest_arg_matches. get_many :: < String > ( "Z" ) . into_iter ( ) . flatten ( ) . map ( String :: as_str) . collect :: < Vec < _ > > ( ) ;
240238 if unstable_flags. contains ( & "help" ) {
241239 mutest_driver_cli:: print_unstable_flags_help ( UNSTABLE_FLAGS ) ;
242- process:: exit ( 0 ) ;
240+ return process:: ExitCode :: SUCCESS ;
243241 }
244242 mutest_driver_cli:: check_unstable_flags ( & unstable_flags, UNSTABLE_FLAGS ) ;
245243 if !unstable_flags. contains ( & "unstable-options" ) {
246244 mutest_driver_cli:: check_unstable_options ( & mutest_arg_matches, UNSTABLE_OPTIONS ) ;
247245 }
248246
249- process :: exit ( rustc_driver:: catch_with_exit_code ( || {
247+ rustc_driver:: catch_with_exit_code ( || {
250248 let ( Some ( compiler_config) , crate_types) = mutest_driver:: passes:: parse_compiler_args ( & args) else {
251249 early_dcx. early_fatal ( "no compiler configuration was generated" ) ;
252250 } ;
@@ -684,5 +682,5 @@ pub fn main() {
684682 } ;
685683
686684 mutest_driver:: run ( config) . unwrap ( ) ;
687- } ) ) ;
685+ } )
688686}
0 commit comments