@@ -32,7 +32,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
3232use  std:: str; 
3333
3434use  glob:: glob; 
35- use  lazy_static :: lazy_static ; 
35+ use  once_cell :: sync :: Lazy ; 
3636use  tracing:: * ; 
3737
3838use  crate :: extract_gdb_version; 
@@ -52,9 +52,8 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
5252    use  winapi:: um:: errhandlingapi:: SetErrorMode ; 
5353    use  winapi:: um:: winbase:: SEM_NOGPFAULTERRORBOX ; 
5454
55-     lazy_static !  { 
56-         static  ref LOCK :  Mutex <( ) > = Mutex :: new( ( ) ) ; 
57-     } 
55+     static  LOCK :  Mutex < ( ) >  = Mutex :: new ( ( ) ) ; 
56+ 
5857    // Error mode is a global variable, so lock it so only one thread will change it 
5958    let  _lock = LOCK . lock ( ) . unwrap ( ) ; 
6059
@@ -2848,11 +2847,10 @@ impl<'test> TestCx<'test> {
28482847        // the form <crate-name1>.<crate-disambiguator1>-in-<crate-name2>.<crate-disambiguator2>, 
28492848        // remove all crate-disambiguators. 
28502849        fn  remove_crate_disambiguator_from_cgu ( cgu :  & str )  -> String  { 
2851-             lazy_static !  { 
2852-                 static  ref RE :  Regex  =
2853-                     Regex :: new( r"^[^\.]+(?P<d1>\.[[:alnum:]]+)(-in-[^\.]+(?P<d2>\.[[:alnum:]]+))?" ) 
2854-                         . unwrap( ) ; 
2855-             } 
2850+             static  RE :  Lazy < Regex >  = Lazy :: new ( || { 
2851+                 Regex :: new ( r"^[^\.]+(?P<d1>\.[[:alnum:]]+)(-in-[^\.]+(?P<d2>\.[[:alnum:]]+))?" ) 
2852+                     . unwrap ( ) 
2853+             } ) ; 
28562854
28572855            let  captures =
28582856                RE . captures ( cgu) . unwrap_or_else ( || panic ! ( "invalid cgu name encountered: {}" ,  cgu) ) ; 
@@ -3170,12 +3168,12 @@ impl<'test> TestCx<'test> {
31703168                // 'uploaded "$TEST_BUILD_DIR/<test_executable>, waiting for result"' 
31713169                // is printed to stdout by the client and then captured in the ProcRes, 
31723170                // so it needs to be removed when comparing the run-pass test execution output 
3173-                 lazy_static !  { 
3174-                     static  ref  REMOTE_TEST_RE :   Regex  =  Regex :: new( 
3171+                 static   REMOTE_TEST_RE :   Lazy < Regex >  =  Lazy :: new ( ||  { 
3172+                     Regex :: new ( 
31753173                        "^uploaded \" \\ $TEST_BUILD_DIR(/[[:alnum:]_\\ -.]+)+\" , waiting for result\n " 
31763174                    ) 
3177-                     . unwrap( ) ; 
3178-                 } 
3175+                     . unwrap ( ) 
3176+                 } ) ; 
31793177                REMOTE_TEST_RE 
31803178                    . replace ( 
31813179                        & self . normalize_output ( & proc_res. stdout ,  & self . props . normalize_stdout ) , 
@@ -3620,10 +3618,8 @@ impl<'test> TestCx<'test> {
36203618        // with placeholders as we do not want tests needing updated when compiler source code 
36213619        // changes. 
36223620        // eg. $SRC_DIR/libcore/mem.rs:323:14 becomes $SRC_DIR/libcore/mem.rs:LL:COL 
3623-         lazy_static !  { 
3624-             static  ref SRC_DIR_RE :  Regex  =
3625-                 Regex :: new( "SRC_DIR(.+):\\ d+:\\ d+(: \\ d+:\\ d+)?" ) . unwrap( ) ; 
3626-         } 
3621+         static  SRC_DIR_RE :  Lazy < Regex >  =
3622+             Lazy :: new ( || Regex :: new ( "SRC_DIR(.+):\\ d+:\\ d+(: \\ d+:\\ d+)?" ) . unwrap ( ) ) ; 
36273623
36283624        normalized = SRC_DIR_RE . replace_all ( & normalized,  "SRC_DIR$1:LL:COL" ) . into_owned ( ) ; 
36293625
@@ -3634,19 +3630,17 @@ impl<'test> TestCx<'test> {
36343630        // since they duplicate actual errors and make the output hard to read. 
36353631        // This mirrors the regex in src/tools/tidy/src/style.rs, please update 
36363632        // both if either are changed. 
3637-         lazy_static !  { 
3638-             static  ref ANNOTATION_RE :  Regex  = Regex :: new( "\\ s*//(\\ [.*\\ ])?~.*" ) . unwrap( ) ; 
3639-         } 
3633+         static  ANNOTATION_RE :  Lazy < Regex >  =
3634+             Lazy :: new ( || Regex :: new ( "\\ s*//(\\ [.*\\ ])?~.*" ) . unwrap ( ) ) ; 
36403635
36413636        normalized = ANNOTATION_RE . replace_all ( & normalized,  "" ) . into_owned ( ) ; 
36423637
36433638        // This code normalizes various hashes in v0 symbol mangling that is 
36443639        // emitted in the ui and mir-opt tests. 
3645-         lazy_static !  { 
3646-             static  ref V0_CRATE_HASH_PREFIX_RE :  Regex  =
3647-                 Regex :: new( r"_R.*?Cs[0-9a-zA-Z]+_" ) . unwrap( ) ; 
3648-             static  ref V0_CRATE_HASH_RE :  Regex  = Regex :: new( r"Cs[0-9a-zA-Z]+_" ) . unwrap( ) ; 
3649-         } 
3640+         static  V0_CRATE_HASH_PREFIX_RE :  Lazy < Regex >  =
3641+             Lazy :: new ( || Regex :: new ( r"_R.*?Cs[0-9a-zA-Z]+_" ) . unwrap ( ) ) ; 
3642+         static  V0_CRATE_HASH_RE :  Lazy < Regex >  =
3643+             Lazy :: new ( || Regex :: new ( r"Cs[0-9a-zA-Z]+_" ) . unwrap ( ) ) ; 
36503644
36513645        const  V0_CRATE_HASH_PLACEHOLDER :  & str  = r"CsCRATE_HASH_" ; 
36523646        if  V0_CRATE_HASH_PREFIX_RE . is_match ( & normalized)  { 
@@ -3655,10 +3649,9 @@ impl<'test> TestCx<'test> {
36553649                V0_CRATE_HASH_RE . replace_all ( & normalized,  V0_CRATE_HASH_PLACEHOLDER ) . into_owned ( ) ; 
36563650        } 
36573651
3658-         lazy_static !  { 
3659-             static  ref V0_BACK_REF_PREFIX_RE :  Regex  = Regex :: new( r"\(_R.*?B[0-9a-zA-Z]_" ) . unwrap( ) ; 
3660-             static  ref V0_BACK_REF_RE :  Regex  = Regex :: new( r"B[0-9a-zA-Z]_" ) . unwrap( ) ; 
3661-         } 
3652+         static  V0_BACK_REF_PREFIX_RE :  Lazy < Regex >  =
3653+             Lazy :: new ( || Regex :: new ( r"\(_R.*?B[0-9a-zA-Z]_" ) . unwrap ( ) ) ; 
3654+         static  V0_BACK_REF_RE :  Lazy < Regex >  = Lazy :: new ( || Regex :: new ( r"B[0-9a-zA-Z]_" ) . unwrap ( ) ) ; 
36623655
36633656        const  V0_BACK_REF_PLACEHOLDER :  & str  = r"B<REF>_" ; 
36643657        if  V0_BACK_REF_PREFIX_RE . is_match ( & normalized)  { 
@@ -3681,21 +3674,23 @@ impl<'test> TestCx<'test> {
36813674/// Replaces backslashes in paths with forward slashes, and replaces CRLF line endings 
36823675/// with LF. 
36833676fn  normalize_platform_differences ( output :  & str )  -> String  { 
3684-         lazy_static !  { 
3685-             /// Used to find Windows paths. 
3686- /// 
3687- /// It's not possible to detect paths in the error messages generally, but this is a 
3688- /// decent enough heuristic. 
3689- static  ref PATH_BACKSLASH_RE :  Regex  = Regex :: new( r#"(?x) 
3677+         /// Used to find Windows paths. 
3678+ /// 
3679+ /// It's not possible to detect paths in the error messages generally, but this is a 
3680+ /// decent enough heuristic. 
3681+ static  PATH_BACKSLASH_RE :  Lazy < Regex >  = Lazy :: new ( || { 
3682+             Regex :: new ( 
3683+                 r#"(?x) 
36903684                (?: 
36913685                  # Match paths that don't include spaces. 
36923686                  (?:\\[\pL\pN\.\-_']+)+\.\pL+ 
36933687                | 
36943688                  # If the path starts with a well-known root, then allow spaces. 
36953689                  \$(?:DIR|SRC_DIR|TEST_BUILD_DIR|BUILD_DIR|LIB_DIR)(?:\\[\pL\pN\.\-_' ]+)+ 
3696-                 )"# 
3697-             ) . unwrap( ) ; 
3698-         } 
3690+                 )"# , 
3691+             ) 
3692+             . unwrap ( ) 
3693+         } ) ; 
36993694
37003695        let  output = output. replace ( r"\\" ,  r"\" ) ; 
37013696
0 commit comments