Skip to content

Commit 31af4f8

Browse files
committed
Remove lazycell and once_cell from compiletest dependencies
1 parent 35194e7 commit 31af4f8

File tree

7 files changed

+80
-112
lines changed

7 files changed

+80
-112
lines changed

Cargo.lock

-8
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,9 @@ dependencies = [
760760
"glob",
761761
"home",
762762
"indexmap",
763-
"lazycell",
764763
"libc",
765764
"miow",
766765
"miropt-test-tools",
767-
"once_cell",
768766
"regex",
769767
"rustfix 0.8.1",
770768
"serde",
@@ -2151,12 +2149,6 @@ version = "1.4.0"
21512149
source = "registry+https://github.com/rust-lang/crates.io-index"
21522150
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
21532151

2154-
[[package]]
2155-
name = "lazycell"
2156-
version = "1.3.0"
2157-
source = "registry+https://github.com/rust-lang/crates.io-index"
2158-
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
2159-
21602152
[[package]]
21612153
name = "leb128"
21622154
version = "0.2.5"

src/tools/compiletest/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ regex = "1.0"
2121
serde = { version = "1.0", features = ["derive"] }
2222
serde_json = "1.0"
2323
rustfix = "0.8.1"
24-
once_cell = "1.16.0"
2524
walkdir = "2"
2625
glob = "0.3.0"
27-
lazycell = "1.3.0"
2826
anyhow = "1"
2927
home = "0.5.5"
3028

src/tools/compiletest/src/common.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::iter;
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
88
use std::str::FromStr;
9+
use std::sync::OnceLock;
910

1011
use crate::util::{add_dylib_path, PathBufExt};
1112
use build_helper::git::GitConfig;
12-
use lazycell::AtomicLazyCell;
1313
use serde::de::{Deserialize, Deserializer, Error as _};
1414
use std::collections::{HashMap, HashSet};
1515
use test::{ColorConfig, OutputFormat};
@@ -384,7 +384,7 @@ pub struct Config {
384384
/// Only rerun the tests that result has been modified accoring to Git status
385385
pub only_modified: bool,
386386

387-
pub target_cfgs: AtomicLazyCell<TargetCfgs>,
387+
pub target_cfgs: OnceLock<TargetCfgs>,
388388

389389
pub nocapture: bool,
390390

@@ -406,13 +406,7 @@ impl Config {
406406
}
407407

408408
pub fn target_cfgs(&self) -> &TargetCfgs {
409-
match self.target_cfgs.borrow() {
410-
Some(cfgs) => cfgs,
411-
None => {
412-
let _ = self.target_cfgs.fill(TargetCfgs::new(self));
413-
self.target_cfgs.borrow().unwrap()
414-
}
415-
}
409+
self.target_cfgs.get_or_init(|| TargetCfgs::new(self))
416410
}
417411

418412
pub fn target_cfg(&self) -> &TargetCfg {

src/tools/compiletest/src/errors.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::io::prelude::*;
66
use std::io::BufReader;
77
use std::path::Path;
88
use std::str::FromStr;
9+
use std::sync::OnceLock;
910

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

@@ -117,10 +117,11 @@ fn parse_expected(
117117
// //~^^^^^
118118
// //[rev1]~
119119
// //[rev1,rev2]~^^
120-
static RE: Lazy<Regex> =
121-
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w\-,]+)])?~(?P<adjust>\||\^*)").unwrap());
120+
static RE: OnceLock<Regex> = OnceLock::new();
122121

123-
let captures = RE.captures(line)?;
122+
let captures = RE
123+
.get_or_init(|| Regex::new(r"//(?:\[(?P<revs>[\w\-,]+)])?~(?P<adjust>\||\^*)").unwrap())
124+
.captures(line)?;
124125

125126
match (test_revision, captures.name("revs")) {
126127
// Only error messages that contain our revision between the square brackets apply to us.

src/tools/compiletest/src/header.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::io::prelude::*;
55
use std::io::BufReader;
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
8+
use std::sync::OnceLock;
89

9-
use once_cell::sync::Lazy;
1010
use regex::Regex;
1111
use tracing::*;
1212

@@ -1021,8 +1021,9 @@ fn iter_header(
10211021
let mut line_number = 0;
10221022

10231023
// Match on error annotations like `//~ERROR`.
1024-
static REVISION_MAGIC_COMMENT_RE: Lazy<Regex> =
1025-
Lazy::new(|| Regex::new("//(\\[.*\\])?~.*").unwrap());
1024+
static REVISION_MAGIC_COMMENT_RE: OnceLock<Regex> = OnceLock::new();
1025+
let revision_magic_comment_re =
1026+
REVISION_MAGIC_COMMENT_RE.get_or_init(|| Regex::new("//(\\[.*\\])?~.*").unwrap());
10261027

10271028
loop {
10281029
line_number += 1;
@@ -1087,7 +1088,7 @@ fn iter_header(
10871088
});
10881089
// Then we try to check for legacy-style candidates, which are not the magic ~ERROR family
10891090
// error annotations.
1090-
} else if !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
1091+
} else if !revision_magic_comment_re.is_match(ln) {
10911092
let Some((_, rest)) = line_directive("//", ln) else {
10921093
continue;
10931094
};

src/tools/compiletest/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ use crate::util::logv;
2424
use build_helper::git::{get_git_modified_files, get_git_untracked_files};
2525
use core::panic;
2626
use getopts::Options;
27-
use lazycell::AtomicLazyCell;
2827
use std::collections::HashSet;
2928
use std::ffi::OsString;
3029
use std::fs;
3130
use std::io::{self, ErrorKind};
3231
use std::path::{Path, PathBuf};
3332
use std::process::{Command, Stdio};
33+
use std::sync::{Arc, OnceLock};
3434
use std::time::SystemTime;
3535
use std::{env, vec};
3636
use test::ColorConfig;
@@ -39,7 +39,6 @@ use walkdir::WalkDir;
3939

4040
use self::header::{make_test_description, EarlyProps};
4141
use crate::header::HeadersCache;
42-
use std::sync::Arc;
4342

4443
pub fn parse_config(args: Vec<String>) -> Config {
4544
let mut opts = Options::new();
@@ -320,7 +319,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
320319

321320
force_rerun: matches.opt_present("force-rerun"),
322321

323-
target_cfgs: AtomicLazyCell::new(),
322+
target_cfgs: OnceLock::new(),
324323

325324
nocapture: matches.opt_present("nocapture"),
326325

0 commit comments

Comments
 (0)