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

bootstrap: once_cell::sync::Lazy -> std::sync::LazyLock #127467

Merged
merged 1 commit into from
Jul 8, 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
1 change: 0 additions & 1 deletion src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ dependencies = [
"junction",
"libc",
"object",
"once_cell",
"opener",
"pretty_assertions",
"semver",
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ home = "0.5"
ignore = "0.4"
libc = "0.2"
object = { version = "0.32", default-features = false, features = ["archive", "coff", "read_core", "unaligned"] }
once_cell = "1.19"
opener = "0.5"
semver = "1.0"
serde = "1.0"
Expand Down
7 changes: 3 additions & 4 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::fs;
use std::hash::Hash;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use std::time::{Duration, Instant};

use crate::core::build_steps::tool::{self, SourceType};
Expand All @@ -27,8 +28,6 @@ use crate::utils::exec::{command, BootstrapCommand};
pub use crate::Compiler;

use clap::ValueEnum;
// FIXME: replace with std::lazy after it gets stabilized and reaches beta
use once_cell::sync::Lazy;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -498,7 +497,7 @@ impl StepDescription {

enum ReallyDefault<'a> {
Bool(bool),
Lazy(Lazy<bool, Box<dyn Fn() -> bool + 'a>>),
Lazy(LazyLock<bool, Box<dyn Fn() -> bool + 'a>>),
}

pub struct ShouldRun<'a> {
Expand Down Expand Up @@ -529,7 +528,7 @@ impl<'a> ShouldRun<'a> {
}

pub fn lazy_default_condition(mut self, lazy_cond: Box<dyn Fn() -> bool + 'a>) -> Self {
self.is_really_default = ReallyDefault::Lazy(Lazy::new(lazy_cond));
self.is_really_default = ReallyDefault::Lazy(LazyLock::new(lazy_cond));
self
}

Expand Down
7 changes: 2 additions & 5 deletions src/bootstrap/src/utils/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use std::marker::PhantomData;
use std::mem;
use std::ops::Deref;
use std::path::PathBuf;
use std::sync::Mutex;

// FIXME: replace with std::lazy after it gets stabilized and reaches beta
use once_cell::sync::Lazy;
use std::sync::{LazyLock, Mutex};

use crate::core::builder::Step;

Expand Down Expand Up @@ -196,7 +193,7 @@ impl Interner {
}
}

pub static INTERNER: Lazy<Interner> = Lazy::new(Interner::default);
pub static INTERNER: LazyLock<Interner> = LazyLock::new(Interner::default);

/// This is essentially a `HashMap` which allows storing any type in its input and
/// any type in its output. It is a write-once cache; values are never evicted,
Expand Down
Loading