Skip to content

Commit 2c16121

Browse files
committed
fixme: std::sync::OnceLock used
1 parent 1ca9594 commit 2c16121

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/bootstrap/builder.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::io::{BufRead, BufReader};
1010
use std::ops::Deref;
1111
use std::path::{Path, PathBuf};
1212
use std::process::Command;
13+
use std::sync::OnceLock;
1314
use std::time::{Duration, Instant};
1415

1516
use crate::cache::{Cache, Interned, INTERNER};
@@ -29,12 +30,9 @@ use crate::{clean, dist};
2930
use crate::{Build, CLang, DocTests, GitRepo, Mode};
3031

3132
pub use crate::Compiler;
32-
// FIXME:
33-
// - use std::lazy for `Lazy`
34-
// - use std::cell for `OnceCell`
35-
// Once they get stabilized and reach beta.
3633
use clap::ValueEnum;
37-
use once_cell::sync::{Lazy, OnceCell};
34+
// FIXME: use std::lazy for `Lazy` once stabilised and in beta.
35+
use once_cell::sync::Lazy;
3836

3937
pub struct Builder<'a> {
4038
pub build: &'a Build,
@@ -494,7 +492,7 @@ impl<'a> ShouldRun<'a> {
494492
///
495493
/// [`path`]: ShouldRun::path
496494
pub fn paths(mut self, paths: &[&str]) -> Self {
497-
static SUBMODULES_PATHS: OnceCell<Vec<String>> = OnceCell::new();
495+
static SUBMODULES_PATHS: OnceLock<Vec<String>> = OnceLock::new();
498496

499497
let init_submodules_paths = |src: &PathBuf| {
500498
let file = File::open(src.join(".gitmodules")).unwrap();

src/bootstrap/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::io::IsTerminal;
1616
use std::path::{Path, PathBuf};
1717
use std::process::Command;
1818
use std::str::FromStr;
19+
use std::sync::OnceLock;
1920

2021
use crate::cache::{Interned, INTERNER};
2122
use crate::cc_detect::{ndk_compiler, Language};
@@ -25,7 +26,6 @@ pub use crate::flags::Subcommand;
2526
use crate::flags::{Color, Flags, Warnings};
2627
use crate::util::{exe, output, t};
2728
use build_helper::exit;
28-
use once_cell::sync::OnceCell;
2929
use semver::Version;
3030
use serde::{Deserialize, Deserializer};
3131
use serde_derive::Deserialize;
@@ -1913,7 +1913,7 @@ impl Config {
19131913
}
19141914

19151915
pub(crate) fn download_rustc_commit(&self) -> Option<&str> {
1916-
static DOWNLOAD_RUSTC: OnceCell<Option<String>> = OnceCell::new();
1916+
static DOWNLOAD_RUSTC: OnceLock<Option<String>> = OnceLock::new();
19171917
if self.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
19181918
// avoid trying to actually download the commit
19191919
return self.download_rustc_commit.as_deref();

src/bootstrap/download.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use std::{
55
io::{BufRead, BufReader, BufWriter, ErrorKind, Write},
66
path::{Path, PathBuf},
77
process::{Command, Stdio},
8+
sync::OnceLock,
89
};
910

1011
use build_helper::ci::CiEnv;
11-
use once_cell::sync::OnceCell;
1212
use xz2::bufread::XzDecoder;
1313

1414
use crate::{
@@ -19,7 +19,7 @@ use crate::{
1919
Config,
2020
};
2121

22-
static SHOULD_FIX_BINS_AND_DYLIBS: OnceCell<bool> = OnceCell::new();
22+
static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new();
2323

2424
/// `Config::try_run` wrapper for this module to avoid warnings on `try_run`, since we don't have access to a `builder` yet.
2525
fn try_run(config: &Config, cmd: &mut Command) -> Result<(), ()> {
@@ -125,7 +125,7 @@ impl Config {
125125
println!("attempting to patch {}", fname.display());
126126

127127
// Only build `.nix-deps` once.
128-
static NIX_DEPS_DIR: OnceCell<PathBuf> = OnceCell::new();
128+
static NIX_DEPS_DIR: OnceLock<PathBuf> = OnceLock::new();
129129
let mut nix_build_succeeded = true;
130130
let nix_deps_dir = NIX_DEPS_DIR.get_or_init(|| {
131131
// Run `nix-build` to "build" each dependency (which will likely reuse

src/bootstrap/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use std::io;
2525
use std::path::{Path, PathBuf};
2626
use std::process::{Command, Stdio};
2727
use std::str;
28+
use std::sync::OnceLock;
2829

2930
use build_helper::ci::{gha, CiEnv};
3031
use build_helper::exit;
3132
use channel::GitInfo;
3233
use config::{DryRun, Target};
3334
use filetime::FileTime;
34-
use once_cell::sync::OnceCell;
3535

3636
use crate::builder::Kind;
3737
use crate::config::{LlvmLibunwind, TargetSelection};
@@ -945,7 +945,7 @@ impl Build {
945945

946946
/// Returns the sysroot of the snapshot compiler.
947947
fn rustc_snapshot_sysroot(&self) -> &Path {
948-
static SYSROOT_CACHE: OnceCell<PathBuf> = once_cell::sync::OnceCell::new();
948+
static SYSROOT_CACHE: OnceLock<PathBuf> = OnceLock::new();
949949
SYSROOT_CACHE.get_or_init(|| {
950950
let mut rustc = Command::new(&self.initial_rustc);
951951
rustc.args(&["--print", "sysroot"]);

src/bootstrap/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use std::io;
1010
use std::path::{Path, PathBuf};
1111
use std::process::{Command, Stdio};
1212
use std::str;
13+
use std::sync::OnceLock;
1314
use std::time::{Instant, SystemTime, UNIX_EPOCH};
1415

1516
use crate::builder::Builder;
1617
use crate::config::{Config, TargetSelection};
17-
use crate::OnceCell;
1818

1919
/// A helper macro to `unwrap` a result except also print out details like:
2020
///
@@ -480,7 +480,7 @@ pub fn get_clang_cl_resource_dir(clang_cl_path: &str) -> PathBuf {
480480
}
481481

482482
pub fn lld_flag_no_threads(is_windows: bool) -> &'static str {
483-
static LLD_NO_THREADS: OnceCell<(&'static str, &'static str)> = OnceCell::new();
483+
static LLD_NO_THREADS: OnceLock<(&'static str, &'static str)> = OnceLock::new();
484484
let (windows, other) = LLD_NO_THREADS.get_or_init(|| {
485485
let out = output(Command::new("lld").arg("-flavor").arg("ld").arg("--version"));
486486
let newer = match (out.find(char::is_numeric), out.find('.')) {

0 commit comments

Comments
 (0)