@@ -32,7 +32,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
32
32
use std:: str;
33
33
34
34
use glob:: glob;
35
- use lazy_static :: lazy_static ;
35
+ use once_cell :: sync :: Lazy ;
36
36
use tracing:: * ;
37
37
38
38
use crate :: extract_gdb_version;
@@ -52,9 +52,8 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
52
52
use winapi:: um:: errhandlingapi:: SetErrorMode ;
53
53
use winapi:: um:: winbase:: SEM_NOGPFAULTERRORBOX ;
54
54
55
- lazy_static ! {
56
- static ref LOCK : Mutex <( ) > = Mutex :: new( ( ) ) ;
57
- }
55
+ static LOCK : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
56
+
58
57
// Error mode is a global variable, so lock it so only one thread will change it
59
58
let _lock = LOCK . lock ( ) . unwrap ( ) ;
60
59
@@ -2848,11 +2847,10 @@ impl<'test> TestCx<'test> {
2848
2847
// the form <crate-name1>.<crate-disambiguator1>-in-<crate-name2>.<crate-disambiguator2>,
2849
2848
// remove all crate-disambiguators.
2850
2849
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
+ } ) ;
2856
2854
2857
2855
let captures =
2858
2856
RE . captures ( cgu) . unwrap_or_else ( || panic ! ( "invalid cgu name encountered: {}" , cgu) ) ;
@@ -3170,12 +3168,12 @@ impl<'test> TestCx<'test> {
3170
3168
// 'uploaded "$TEST_BUILD_DIR/<test_executable>, waiting for result"'
3171
3169
// is printed to stdout by the client and then captured in the ProcRes,
3172
3170
// 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 (
3175
3173
"^uploaded \" \\ $TEST_BUILD_DIR(/[[:alnum:]_\\ -.]+)+\" , waiting for result\n "
3176
3174
)
3177
- . unwrap( ) ;
3178
- }
3175
+ . unwrap ( )
3176
+ } ) ;
3179
3177
REMOTE_TEST_RE
3180
3178
. replace (
3181
3179
& self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ,
@@ -3620,10 +3618,8 @@ impl<'test> TestCx<'test> {
3620
3618
// with placeholders as we do not want tests needing updated when compiler source code
3621
3619
// changes.
3622
3620
// 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 ( ) ) ;
3627
3623
3628
3624
normalized = SRC_DIR_RE . replace_all ( & normalized, "SRC_DIR$1:LL:COL" ) . into_owned ( ) ;
3629
3625
@@ -3634,19 +3630,17 @@ impl<'test> TestCx<'test> {
3634
3630
// since they duplicate actual errors and make the output hard to read.
3635
3631
// This mirrors the regex in src/tools/tidy/src/style.rs, please update
3636
3632
// 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 ( ) ) ;
3640
3635
3641
3636
normalized = ANNOTATION_RE . replace_all ( & normalized, "" ) . into_owned ( ) ;
3642
3637
3643
3638
// This code normalizes various hashes in v0 symbol mangling that is
3644
3639
// 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 ( ) ) ;
3650
3644
3651
3645
const V0_CRATE_HASH_PLACEHOLDER : & str = r"CsCRATE_HASH_" ;
3652
3646
if V0_CRATE_HASH_PREFIX_RE . is_match ( & normalized) {
@@ -3655,10 +3649,9 @@ impl<'test> TestCx<'test> {
3655
3649
V0_CRATE_HASH_RE . replace_all ( & normalized, V0_CRATE_HASH_PLACEHOLDER ) . into_owned ( ) ;
3656
3650
}
3657
3651
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 ( ) ) ;
3662
3655
3663
3656
const V0_BACK_REF_PLACEHOLDER : & str = r"B<REF>_" ;
3664
3657
if V0_BACK_REF_PREFIX_RE . is_match ( & normalized) {
@@ -3681,21 +3674,23 @@ impl<'test> TestCx<'test> {
3681
3674
/// Replaces backslashes in paths with forward slashes, and replaces CRLF line endings
3682
3675
/// with LF.
3683
3676
fn 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)
3690
3684
(?:
3691
3685
# Match paths that don't include spaces.
3692
3686
(?:\\[\pL\pN\.\-_']+)+\.\pL+
3693
3687
|
3694
3688
# If the path starts with a well-known root, then allow spaces.
3695
3689
\$(?:DIR|SRC_DIR|TEST_BUILD_DIR|BUILD_DIR|LIB_DIR)(?:\\[\pL\pN\.\-_' ]+)+
3696
- )"#
3697
- ) . unwrap( ) ;
3698
- }
3690
+ )"# ,
3691
+ )
3692
+ . unwrap ( )
3693
+ } ) ;
3699
3694
3700
3695
let output = output. replace ( r"\\" , r"\" ) ;
3701
3696
0 commit comments