Skip to content

Commit 4737e9e

Browse files
authored
Rollup merge of rust-lang#98165 - WaffleLapkin:once_things_renamings, r=m-ou-se
once cell renamings This PR does the renamings proposed in rust-lang#74465 (comment) - Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}` - Move/rename `lazy::{SyncOnceCell, SyncLazy}` to `sync::{OnceLock, LazyLock}` (I used `Lazy...` instead of `...Lazy` as it seems to be more consistent, easier to pronounce, etc) ```@rustbot``` label +T-libs-api -T-libs
2 parents 09c9301 + f095f80 commit 4737e9e

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

clippy_dev/src/bless.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
use crate::cargo_clippy_path;
55
use std::ffi::OsStr;
66
use std::fs;
7-
use std::lazy::SyncLazy;
87
use std::path::{Path, PathBuf};
8+
use std::sync::LazyLock;
99
use walkdir::{DirEntry, WalkDir};
1010

11-
static CLIPPY_BUILD_TIME: SyncLazy<Option<std::time::SystemTime>> =
12-
SyncLazy::new(|| cargo_clippy_path().metadata().ok()?.modified().ok());
11+
static CLIPPY_BUILD_TIME: LazyLock<Option<std::time::SystemTime>> =
12+
LazyLock::new(|| cargo_clippy_path().metadata().ok()?.modified().ok());
1313

1414
/// # Panics
1515
///

clippy_utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub use self::hir_utils::{
6464

6565
use std::collections::hash_map::Entry;
6666
use std::hash::BuildHasherDefault;
67-
use std::lazy::SyncOnceCell;
67+
use std::sync::OnceLock;
6868
use std::sync::{Mutex, MutexGuard};
6969

7070
use if_chain::if_chain;
@@ -2080,7 +2080,7 @@ pub fn is_hir_ty_cfg_dependant(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
20802080
false
20812081
}
20822082

2083-
static TEST_ITEM_NAMES_CACHE: SyncOnceCell<Mutex<FxHashMap<LocalDefId, Vec<Symbol>>>> = SyncOnceCell::new();
2083+
static TEST_ITEM_NAMES_CACHE: OnceLock<Mutex<FxHashMap<LocalDefId, Vec<Symbol>>>> = OnceLock::new();
20842084

20852085
fn with_test_item_names<'tcx>(tcx: TyCtxt<'tcx>, module: LocalDefId, f: impl Fn(&[Symbol]) -> bool) -> bool {
20862086
let cache = TEST_ITEM_NAMES_CACHE.get_or_init(|| Mutex::new(FxHashMap::default()));

src/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ use rustc_tools_util::VersionInfo;
2121

2222
use std::borrow::Cow;
2323
use std::env;
24-
use std::lazy::SyncLazy;
2524
use std::ops::Deref;
2625
use std::panic;
2726
use std::path::{Path, PathBuf};
2827
use std::process::{exit, Command};
28+
use std::sync::LazyLock;
2929

3030
/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
3131
/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
@@ -152,7 +152,7 @@ You can use tool lints to allow or deny lints from your code, eg.:
152152

153153
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new";
154154

155-
static ICE_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> = SyncLazy::new(|| {
155+
static ICE_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> = LazyLock::new(|| {
156156
let hook = panic::take_hook();
157157
panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL)));
158158
hook
@@ -219,7 +219,7 @@ fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<Pat
219219
#[allow(clippy::too_many_lines)]
220220
pub fn main() {
221221
rustc_driver::init_rustc_env_logger();
222-
SyncLazy::force(&ICE_HOOK);
222+
LazyLock::force(&ICE_HOOK);
223223
exit(rustc_driver::catch_with_exit_code(move || {
224224
let mut orig_args: Vec<String> = env::args().collect();
225225

tests/compile-test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::env::{self, remove_var, set_var, var_os};
1212
use std::ffi::{OsStr, OsString};
1313
use std::fs;
1414
use std::io;
15-
use std::lazy::SyncLazy;
1615
use std::path::{Path, PathBuf};
16+
use std::sync::LazyLock;
1717
use test_utils::IS_RUSTC_TEST_SUITE;
1818

1919
mod test_utils;
@@ -69,7 +69,7 @@ extern crate tokio;
6969
/// dependencies must be added to Cargo.toml at the project root. Test
7070
/// dependencies that are not *directly* used by this test module require an
7171
/// `extern crate` declaration.
72-
static EXTERN_FLAGS: SyncLazy<String> = SyncLazy::new(|| {
72+
static EXTERN_FLAGS: LazyLock<String> = LazyLock::new(|| {
7373
let current_exe_depinfo = {
7474
let mut path = env::current_exe().unwrap();
7575
path.set_extension("d");

tests/test_utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(dead_code)] // see https://github.com/rust-lang/rust/issues/46379
22

3-
use std::lazy::SyncLazy;
43
use std::path::PathBuf;
4+
use std::sync::LazyLock;
55

6-
pub static CARGO_CLIPPY_PATH: SyncLazy<PathBuf> = SyncLazy::new(|| {
6+
pub static CARGO_CLIPPY_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
77
let mut path = std::env::current_exe().unwrap();
88
assert!(path.pop()); // deps
99
path.set_file_name("cargo-clippy");

0 commit comments

Comments
 (0)