Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lazycell and once_cell from compiletest dependencies #124434

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,9 @@ dependencies = [
"glob",
"home",
"indexmap",
"lazycell",
"libc",
"miow",
"miropt-test-tools",
"once_cell",
"regex",
"rustfix 0.8.1",
"serde",
Expand Down Expand Up @@ -2151,12 +2149,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "leb128"
version = "0.2.5"
Expand Down
2 changes: 0 additions & 2 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ regex = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rustfix = "0.8.1"
once_cell = "1.16.0"
walkdir = "2"
glob = "0.3.0"
lazycell = "1.3.0"
anyhow = "1"
home = "0.5.5"

Expand Down
12 changes: 3 additions & 9 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::iter;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;
use std::sync::OnceLock;

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

pub target_cfgs: AtomicLazyCell<TargetCfgs>,
pub target_cfgs: OnceLock<TargetCfgs>,

pub nocapture: bool,

Expand All @@ -406,13 +406,7 @@ impl Config {
}

pub fn target_cfgs(&self) -> &TargetCfgs {
match self.target_cfgs.borrow() {
Some(cfgs) => cfgs,
None => {
let _ = self.target_cfgs.fill(TargetCfgs::new(self));
self.target_cfgs.borrow().unwrap()
}
}
self.target_cfgs.get_or_init(|| TargetCfgs::new(self))
}

pub fn target_cfg(&self) -> &TargetCfg {
Expand Down
9 changes: 5 additions & 4 deletions src/tools/compiletest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::str::FromStr;
use std::sync::OnceLock;

use once_cell::sync::Lazy;
use regex::Regex;
use tracing::*;

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

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

match (test_revision, captures.name("revs")) {
// Only error messages that contain our revision between the square brackets apply to us.
Expand Down
9 changes: 5 additions & 4 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::io::prelude::*;
use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::OnceLock;

use once_cell::sync::Lazy;
use regex::Regex;
use tracing::*;

Expand Down Expand Up @@ -1021,8 +1021,9 @@ fn iter_header(
let mut line_number = 0;

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

loop {
line_number += 1;
Expand Down Expand Up @@ -1087,7 +1088,7 @@ fn iter_header(
});
// Then we try to check for legacy-style candidates, which are not the magic ~ERROR family
// error annotations.
} else if !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
} else if !revision_magic_comment_re.is_match(ln) {
let Some((_, rest)) = line_directive("//", ln) else {
continue;
};
Expand Down
5 changes: 2 additions & 3 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ use crate::util::logv;
use build_helper::git::{get_git_modified_files, get_git_untracked_files};
use core::panic;
use getopts::Options;
use lazycell::AtomicLazyCell;
use std::collections::HashSet;
use std::ffi::OsString;
use std::fs;
use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::{Arc, OnceLock};
use std::time::SystemTime;
use std::{env, vec};
use test::ColorConfig;
Expand All @@ -39,7 +39,6 @@ use walkdir::WalkDir;

use self::header::{make_test_description, EarlyProps};
use crate::header::HeadersCache;
use std::sync::Arc;

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

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

target_cfgs: AtomicLazyCell::new(),
target_cfgs: OnceLock::new(),

nocapture: matches.opt_present("nocapture"),

Expand Down
Loading
Loading