@@ -16,11 +16,10 @@ use regex::{Captures, Regex};
1616use  tracing:: * ; 
1717
1818use  crate :: common:: { 
19-     Assembly ,  Codegen ,  CodegenUnits ,  CompareMode ,  Config ,  CoverageMap ,  CoverageRun ,  Crashes , 
20-     DebugInfo ,  Debugger ,  FailMode ,  Incremental ,  MirOpt ,  PassMode ,  Pretty ,  RunMake ,  Rustdoc , 
21-     RustdocJs ,  RustdocJson ,  TestPaths ,  UI_EXTENSIONS ,  UI_FIXED ,  UI_RUN_STDERR ,  UI_RUN_STDOUT , 
22-     UI_STDERR ,  UI_STDOUT ,  UI_SVG ,  UI_WINDOWS_SVG ,  Ui ,  expected_output_path,  incremental_dir, 
23-     output_base_dir,  output_base_name,  output_testname_unique, 
19+     CompareMode ,  Config ,  Debugger ,  FailMode ,  PassMode ,  TestMode ,  TestPaths ,  UI_EXTENSIONS , 
20+     UI_FIXED ,  UI_RUN_STDERR ,  UI_RUN_STDOUT ,  UI_STDERR ,  UI_STDOUT ,  UI_SVG ,  UI_WINDOWS_SVG , 
21+     expected_output_path,  incremental_dir,  output_base_dir,  output_base_name, 
22+     output_testname_unique, 
2423} ; 
2524use  crate :: compute_diff:: { DiffLine ,  make_diff,  write_diff,  write_filtered_diff} ; 
2625use  crate :: directives:: TestProps ; 
@@ -154,7 +153,7 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
154153        cx. init_incremental_test ( ) ; 
155154    } 
156155
157-     if  config. mode  == Incremental  { 
156+     if  config. mode  == TestMode :: Incremental  { 
158157        // Incremental tests are special because they cannot be run in 
159158        // parallel. 
160159        assert ! ( !props. revisions. is_empty( ) ,  "Incremental tests require revisions." ) ; 
@@ -203,7 +202,7 @@ pub fn compute_stamp_hash(config: &Config) -> String {
203202        None  => { } 
204203    } 
205204
206-     if  let   Ui  =  config. mode  { 
205+     if  config. mode  ==  TestMode :: Ui  { 
207206        config. force_pass_mode . hash ( & mut  hash) ; 
208207    } 
209208
@@ -251,25 +250,28 @@ impl<'test> TestCx<'test> {
251250    /// Code executed for each revision in turn (or, if there are no 
252251/// revisions, exactly once, with revision == None). 
253252fn  run_revision ( & self )  { 
254-         if  self . props . should_ice  && self . config . mode  != Incremental  && self . config . mode  != Crashes  { 
253+         if  self . props . should_ice 
254+             && self . config . mode  != TestMode :: Incremental 
255+             && self . config . mode  != TestMode :: Crashes 
256+         { 
255257            self . fatal ( "cannot use should-ice in a test that is not cfail" ) ; 
256258        } 
257259        match  self . config . mode  { 
258-             Pretty  => self . run_pretty_test ( ) , 
259-             DebugInfo  => self . run_debuginfo_test ( ) , 
260-             Codegen  => self . run_codegen_test ( ) , 
261-             Rustdoc  => self . run_rustdoc_test ( ) , 
262-             RustdocJson  => self . run_rustdoc_json_test ( ) , 
263-             CodegenUnits  => self . run_codegen_units_test ( ) , 
264-             Incremental  => self . run_incremental_test ( ) , 
265-             RunMake  => self . run_rmake_test ( ) , 
266-             Ui  => self . run_ui_test ( ) , 
267-             MirOpt  => self . run_mir_opt_test ( ) , 
268-             Assembly  => self . run_assembly_test ( ) , 
269-             RustdocJs  => self . run_rustdoc_js_test ( ) , 
270-             CoverageMap  => self . run_coverage_map_test ( ) ,  // see self::coverage 
271-             CoverageRun  => self . run_coverage_run_test ( ) ,  // see self::coverage 
272-             Crashes  => self . run_crash_test ( ) , 
260+             TestMode :: Pretty  => self . run_pretty_test ( ) , 
261+             TestMode :: DebugInfo  => self . run_debuginfo_test ( ) , 
262+             TestMode :: Codegen  => self . run_codegen_test ( ) , 
263+             TestMode :: Rustdoc  => self . run_rustdoc_test ( ) , 
264+             TestMode :: RustdocJson  => self . run_rustdoc_json_test ( ) , 
265+             TestMode :: CodegenUnits  => self . run_codegen_units_test ( ) , 
266+             TestMode :: Incremental  => self . run_incremental_test ( ) , 
267+             TestMode :: RunMake  => self . run_rmake_test ( ) , 
268+             TestMode :: Ui  => self . run_ui_test ( ) , 
269+             TestMode :: MirOpt  => self . run_mir_opt_test ( ) , 
270+             TestMode :: Assembly  => self . run_assembly_test ( ) , 
271+             TestMode :: RustdocJs  => self . run_rustdoc_js_test ( ) , 
272+             TestMode :: CoverageMap  => self . run_coverage_map_test ( ) ,  // see self::coverage 
273+             TestMode :: CoverageRun  => self . run_coverage_run_test ( ) ,  // see self::coverage 
274+             TestMode :: Crashes  => self . run_crash_test ( ) , 
273275        } 
274276    } 
275277
@@ -279,9 +281,13 @@ impl<'test> TestCx<'test> {
279281
280282    fn  should_run ( & self ,  pm :  Option < PassMode > )  -> WillExecute  { 
281283        let  test_should_run = match  self . config . mode  { 
282-             Ui  if  pm == Some ( PassMode :: Run )  || self . props . fail_mode  == Some ( FailMode :: Run )  => true , 
283-             MirOpt  if  pm == Some ( PassMode :: Run )  => true , 
284-             Ui  | MirOpt  => false , 
284+             TestMode :: Ui 
285+                 if  pm == Some ( PassMode :: Run )  || self . props . fail_mode  == Some ( FailMode :: Run )  =>
286+             { 
287+                 true 
288+             } 
289+             TestMode :: MirOpt  if  pm == Some ( PassMode :: Run )  => true , 
290+             TestMode :: Ui  | TestMode :: MirOpt  => false , 
285291            mode => panic ! ( "unimplemented for mode {:?}" ,  mode) , 
286292        } ; 
287293        if  test_should_run {  self . run_if_enabled ( )  }  else  {  WillExecute :: No  } 
@@ -293,17 +299,17 @@ impl<'test> TestCx<'test> {
293299
294300    fn  should_run_successfully ( & self ,  pm :  Option < PassMode > )  -> bool  { 
295301        match  self . config . mode  { 
296-             Ui  | MirOpt  => pm == Some ( PassMode :: Run ) , 
302+             TestMode :: Ui  | TestMode :: MirOpt  => pm == Some ( PassMode :: Run ) , 
297303            mode => panic ! ( "unimplemented for mode {:?}" ,  mode) , 
298304        } 
299305    } 
300306
301307    fn  should_compile_successfully ( & self ,  pm :  Option < PassMode > )  -> bool  { 
302308        match  self . config . mode  { 
303-             RustdocJs  => true , 
304-             Ui  => pm. is_some ( )  || self . props . fail_mode  > Some ( FailMode :: Build ) , 
305-             Crashes  => false , 
306-             Incremental  => { 
309+             TestMode :: RustdocJs  => true , 
310+             TestMode :: Ui  => pm. is_some ( )  || self . props . fail_mode  > Some ( FailMode :: Build ) , 
311+             TestMode :: Crashes  => false , 
312+             TestMode :: Incremental  => { 
307313                let  revision =
308314                    self . revision . expect ( "incremental tests require a list of revisions" ) ; 
309315                if  revision. starts_with ( "cpass" ) 
@@ -892,7 +898,9 @@ impl<'test> TestCx<'test> {
892898
893899    fn  should_emit_metadata ( & self ,  pm :  Option < PassMode > )  -> Emit  { 
894900        match  ( pm,  self . props . fail_mode ,  self . config . mode )  { 
895-             ( Some ( PassMode :: Check ) ,  ..)  | ( _,  Some ( FailMode :: Check ) ,  Ui )  => Emit :: Metadata , 
901+             ( Some ( PassMode :: Check ) ,  ..)  | ( _,  Some ( FailMode :: Check ) ,  TestMode :: Ui )  => { 
902+                 Emit :: Metadata 
903+             } 
896904            _ => Emit :: None , 
897905        } 
898906    } 
@@ -926,7 +934,7 @@ impl<'test> TestCx<'test> {
926934        } ; 
927935
928936        let  allow_unused = match  self . config . mode  { 
929-             Ui  => { 
937+             TestMode :: Ui  => { 
930938                // UI tests tend to have tons of unused code as 
931939                // it's just testing various pieces of the compile, but we don't 
932940                // want to actually assert warnings about all this code. Instead 
@@ -1021,7 +1029,7 @@ impl<'test> TestCx<'test> {
10211029            . args ( & self . props . compile_flags ) 
10221030            . args ( & self . props . doc_flags ) ; 
10231031
1024-         if  self . config . mode  == RustdocJson  { 
1032+         if  self . config . mode  == TestMode :: RustdocJson  { 
10251033            rustdoc. arg ( "--output-format" ) . arg ( "json" ) . arg ( "-Zunstable-options" ) ; 
10261034        } 
10271035
@@ -1372,7 +1380,7 @@ impl<'test> TestCx<'test> {
13721380            || self . is_vxworks_pure_static ( ) 
13731381            || self . config . target . contains ( "bpf" ) 
13741382            || !self . config . target_cfg ( ) . dynamic_linking 
1375-             || matches ! ( self . config. mode,  CoverageMap  | CoverageRun ) 
1383+             || matches ! ( self . config. mode,  TestMode :: CoverageMap  | TestMode :: CoverageRun ) 
13761384        { 
13771385            // We primarily compile all auxiliary libraries as dynamic libraries 
13781386            // to avoid code size bloat and large binaries as much as possible 
@@ -1562,14 +1570,14 @@ impl<'test> TestCx<'test> {
15621570                rustc. args ( & [ "-Z" ,  "incremental-verify-ich" ] ) ; 
15631571            } 
15641572
1565-             if  self . config . mode  == CodegenUnits  { 
1573+             if  self . config . mode  == TestMode :: CodegenUnits  { 
15661574                rustc. args ( & [ "-Z" ,  "human_readable_cgu_names" ] ) ; 
15671575            } 
15681576        } 
15691577
15701578        if  self . config . optimize_tests  && !is_rustdoc { 
15711579            match  self . config . mode  { 
1572-                 Ui  => { 
1580+                 TestMode :: Ui  => { 
15731581                    // If optimize-tests is true we still only want to optimize tests that actually get 
15741582                    // executed and that don't specify their own optimization levels. 
15751583                    // Note: aux libs don't have a pass-mode, so they won't get optimized 
@@ -1585,8 +1593,8 @@ impl<'test> TestCx<'test> {
15851593                        rustc. arg ( "-O" ) ; 
15861594                    } 
15871595                } 
1588-                 DebugInfo  => {  /* debuginfo tests must be unoptimized */  } 
1589-                 CoverageMap  | CoverageRun  => { 
1596+                 TestMode :: DebugInfo  => {  /* debuginfo tests must be unoptimized */  } 
1597+                 TestMode :: CoverageMap  | TestMode :: CoverageRun  => { 
15901598                    // Coverage mappings and coverage reports are affected by 
15911599                    // optimization level, so they ignore the optimize-tests 
15921600                    // setting and set an optimization level in their mode's 
@@ -1607,7 +1615,7 @@ impl<'test> TestCx<'test> {
16071615        } ; 
16081616
16091617        match  self . config . mode  { 
1610-             Incremental  => { 
1618+             TestMode :: Incremental  => { 
16111619                // If we are extracting and matching errors in the new 
16121620                // fashion, then you want JSON mode. Old-skool error 
16131621                // patterns still match the raw compiler output. 
@@ -1620,7 +1628,7 @@ impl<'test> TestCx<'test> {
16201628                rustc. arg ( "-Zui-testing" ) ; 
16211629                rustc. arg ( "-Zdeduplicate-diagnostics=no" ) ; 
16221630            } 
1623-             Ui  => { 
1631+             TestMode :: Ui  => { 
16241632                if  !self . props . compile_flags . iter ( ) . any ( |s| s. starts_with ( "--error-format" ) )  { 
16251633                    rustc. args ( & [ "--error-format" ,  "json" ] ) ; 
16261634                    rustc. args ( & [ "--json" ,  "future-incompat" ] ) ; 
@@ -1633,7 +1641,7 @@ impl<'test> TestCx<'test> {
16331641                // FIXME: use this for other modes too, for perf? 
16341642                rustc. arg ( "-Cstrip=debuginfo" ) ; 
16351643            } 
1636-             MirOpt  => { 
1644+             TestMode :: MirOpt  => { 
16371645                // We check passes under test to minimize the mir-opt test dump 
16381646                // if files_for_miropt_test parses the passes, we dump only those passes 
16391647                // otherwise we conservatively pass -Zdump-mir=all 
@@ -1663,7 +1671,7 @@ impl<'test> TestCx<'test> {
16631671
16641672                set_mir_dump_dir ( & mut  rustc) ; 
16651673            } 
1666-             CoverageMap  => { 
1674+             TestMode :: CoverageMap  => { 
16671675                rustc. arg ( "-Cinstrument-coverage" ) ; 
16681676                // These tests only compile to LLVM IR, so they don't need the 
16691677                // profiler runtime to be present. 
@@ -1673,23 +1681,28 @@ impl<'test> TestCx<'test> {
16731681                // by `compile-flags`. 
16741682                rustc. arg ( "-Copt-level=2" ) ; 
16751683            } 
1676-             CoverageRun  => { 
1684+             TestMode :: CoverageRun  => { 
16771685                rustc. arg ( "-Cinstrument-coverage" ) ; 
16781686                // Coverage reports are sometimes sensitive to optimizations, 
16791687                // and the current snapshots assume `opt-level=2` unless 
16801688                // overridden by `compile-flags`. 
16811689                rustc. arg ( "-Copt-level=2" ) ; 
16821690            } 
1683-             Assembly  | Codegen  => { 
1691+             TestMode :: Assembly  | TestMode :: Codegen  => { 
16841692                rustc. arg ( "-Cdebug-assertions=no" ) ; 
16851693            } 
1686-             Crashes  => { 
1694+             TestMode :: Crashes  => { 
16871695                set_mir_dump_dir ( & mut  rustc) ; 
16881696            } 
1689-             CodegenUnits  => { 
1697+             TestMode :: CodegenUnits  => { 
16901698                rustc. arg ( "-Zprint-mono-items" ) ; 
16911699            } 
1692-             Pretty  | DebugInfo  | Rustdoc  | RustdocJson  | RunMake  | RustdocJs  => { 
1700+             TestMode :: Pretty 
1701+             | TestMode :: DebugInfo 
1702+             | TestMode :: Rustdoc 
1703+             | TestMode :: RustdocJson 
1704+             | TestMode :: RunMake 
1705+             | TestMode :: RustdocJs  => { 
16931706                // do not use JSON output 
16941707            } 
16951708        } 
@@ -1962,7 +1975,7 @@ impl<'test> TestCx<'test> {
19621975    /// The revision, ignored for incremental compilation since it wants all revisions in 
19631976/// the same directory. 
19641977fn  safe_revision ( & self )  -> Option < & str >  { 
1965-         if  self . config . mode  == Incremental  {  None  }  else  {  self . revision  } 
1978+         if  self . config . mode  == TestMode :: Incremental  {  None  }  else  {  self . revision  } 
19661979    } 
19671980
19681981    /// Gets the absolute path to the directory where all output for the given 
0 commit comments