@@ -26,7 +26,7 @@ use std::collections::HashMap;
2626use std:: collections:: HashSet ;
2727use std:: env;
2828use std:: ffi:: OsString ;
29- use std:: fs:: { self , File , create_dir_all} ;
29+ use std:: fs:: { self , File , create_dir_all, OpenOptions } ;
3030use std:: fmt;
3131use std:: io:: prelude:: * ;
3232use std:: io:: { self , BufReader } ;
@@ -2268,6 +2268,36 @@ actual:\n\
22682268 errors += self . compare_output ( UI_STDERR , & normalized_stderr, & expected_stderr) ;
22692269
22702270
2271+ if self . config . rustfix_coverage {
2272+ // Find out which tests have `MachineApplicable` suggestions but are missing
2273+ // `run-rustfix` or `run-rustfix-only-machine-applicable` headers.
2274+ //
2275+ // This will return an empty `Vec` in case the executed test file has a
2276+ // `compile-flags: --error-format=xxxx` header with a value other than `json`.
2277+ let suggestions = get_suggestions_from_json (
2278+ & proc_res. stderr ,
2279+ & HashSet :: new ( ) ,
2280+ Filter :: MachineApplicableOnly
2281+ ) . unwrap_or_default ( ) ;
2282+ if suggestions. len ( ) > 0
2283+ && !self . props . run_rustfix
2284+ && !self . props . rustfix_only_machine_applicable {
2285+ let mut coverage_file_path = self . config . build_base . clone ( ) ;
2286+ coverage_file_path. push ( "rustfix_missing_coverage.txt" ) ;
2287+ debug ! ( "coverage_file_path: {}" , coverage_file_path. display( ) ) ;
2288+
2289+ let mut file = OpenOptions :: new ( )
2290+ . create ( true )
2291+ . append ( true )
2292+ . open ( coverage_file_path. as_path ( ) )
2293+ . expect ( "could not create or open file" ) ;
2294+
2295+ if let Err ( _) = writeln ! ( file, "{}" , self . testpaths. file. display( ) ) {
2296+ panic ! ( "couldn't write to {}" , coverage_file_path. display( ) ) ;
2297+ }
2298+ }
2299+ }
2300+
22712301 if self . props . run_rustfix {
22722302 // Apply suggestions from lints to the code itself
22732303 let unfixed_code = self
0 commit comments