Skip to content

Commit c292def

Browse files
authored
Rollup merge of #108306 - klensy:compiletest-up, r=wesleywiser
compiletest: up deps update `miow` 0.3.7 -> 0.5.0 (which moved from `winapi` to `windows-rs`, [changelog](https://github.com/yoshuawuyts/miow/blob/master/CHANGELOG.md#v050---2022-11-10)) replace `lazy_static` with `once_cell` (there is slow transition to the second crate, in hope of eventually stable stdlib version, yes?)
2 parents ae01430 + 58e7470 commit c292def

File tree

4 files changed

+40
-47
lines changed

4 files changed

+40
-47
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -891,11 +891,11 @@ dependencies = [
891891
"diff",
892892
"getopts",
893893
"glob",
894-
"lazy_static",
895894
"lazycell",
896895
"libc",
897-
"miow 0.3.7",
896+
"miow 0.5.0",
898897
"miropt-test-tools",
898+
"once_cell",
899899
"regex",
900900
"rustfix",
901901
"serde",

src/tools/compiletest/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ regex = "1.0"
1616
serde = { version = "1.0", features = ["derive"] }
1717
serde_json = "1.0"
1818
rustfix = "0.6.0"
19-
lazy_static = "1.0"
19+
once_cell = "1.16.0"
2020
walkdir = "2"
2121
glob = "0.3.0"
2222
lazycell = "1.3.0"
@@ -25,5 +25,5 @@ lazycell = "1.3.0"
2525
libc = "0.2"
2626

2727
[target.'cfg(windows)'.dependencies]
28-
miow = "0.3"
28+
miow = "0.5"
2929
winapi = { version = "0.3", features = ["winerror"] }

src/tools/compiletest/src/errors.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::BufReader;
77
use std::path::Path;
88
use std::str::FromStr;
99

10-
use lazy_static::lazy_static;
10+
use once_cell::sync::Lazy;
1111
use regex::Regex;
1212
use tracing::*;
1313

@@ -117,10 +117,8 @@ fn parse_expected(
117117
// //~^^^^^
118118
// //[cfg1]~
119119
// //[cfg1,cfg2]~^^
120-
lazy_static! {
121-
static ref RE: Regex =
122-
Regex::new(r"//(?:\[(?P<cfgs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap();
123-
}
120+
static RE: Lazy<Regex> =
121+
Lazy::new(|| Regex::new(r"//(?:\[(?P<cfgs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap());
124122

125123
let captures = RE.captures(line)?;
126124

src/tools/compiletest/src/runtest.rs

+33-38
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
3232
use std::str;
3333

3434
use glob::glob;
35-
use lazy_static::lazy_static;
35+
use once_cell::sync::Lazy;
3636
use tracing::*;
3737

3838
use 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.
36833676
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)
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

Comments
 (0)