Skip to content

Commit f351f34

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 e6d28d2 + c1a2db3 commit f351f34

File tree

40 files changed

+1250
-1215
lines changed

40 files changed

+1250
-1215
lines changed

compiler/rustc_codegen_cranelift/src/driver/jit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_span::Symbol;
1313

1414
use cranelift_jit::{JITBuilder, JITModule};
1515

16-
// FIXME use std::lazy::SyncOnceCell once it stabilizes
16+
// FIXME use std::sync::OnceLock once it stabilizes
1717
use once_cell::sync::OnceCell;
1818

1919
use crate::{prelude::*, BackendConfig};

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ use rustc_target::abi::Size;
3636

3737
use libc::c_uint;
3838
use smallvec::SmallVec;
39+
use std::cell::OnceCell;
3940
use std::cell::RefCell;
4041
use std::iter;
41-
use std::lazy::OnceCell;
4242
use tracing::debug;
4343

4444
mod create_scope_map;

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ use regex::Regex;
3838
use tempfile::Builder as TempFileBuilder;
3939

4040
use std::borrow::Borrow;
41+
use std::cell::OnceCell;
4142
use std::collections::BTreeSet;
4243
use std::ffi::OsString;
4344
use std::fs::{File, OpenOptions};
4445
use std::io::{BufWriter, Write};
45-
use std::lazy::OnceCell;
4646
use std::ops::Deref;
4747
use std::path::{Path, PathBuf};
4848
use std::process::{ExitStatus, Output, Stdio};

compiler/rustc_data_structures/src/jobserver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub use jobserver_crate::Client;
2-
use std::lazy::SyncLazy;
2+
use std::sync::LazyLock;
33

44
// We can only call `from_env` once per process
55

@@ -18,7 +18,7 @@ use std::lazy::SyncLazy;
1818
// Also note that we stick this in a global because there could be
1919
// multiple rustc instances in this process, and the jobserver is
2020
// per-process.
21-
static GLOBAL_CLIENT: SyncLazy<Client> = SyncLazy::new(|| unsafe {
21+
static GLOBAL_CLIENT: LazyLock<Client> = LazyLock::new(|| unsafe {
2222
Client::from_env().unwrap_or_else(|| {
2323
let client = Client::new(32).expect("failed to create jobserver");
2424
// Acquire a token for the main thread which we can release later

compiler/rustc_data_structures/src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ cfg_if! {
173173
pub use std::cell::RefMut as LockGuard;
174174
pub use std::cell::RefMut as MappedLockGuard;
175175

176-
pub use std::lazy::OnceCell;
176+
pub use std::cell::OnceCell;
177177

178178
use std::cell::RefCell as InnerRwLock;
179179
use std::cell::RefCell as InnerLock;
@@ -258,7 +258,7 @@ cfg_if! {
258258
pub use parking_lot::MutexGuard as LockGuard;
259259
pub use parking_lot::MappedMutexGuard as MappedLockGuard;
260260

261-
pub use std::lazy::SyncOnceCell as OnceCell;
261+
pub use std::sync::OnceLock as OnceCell;
262262

263263
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
264264

compiler/rustc_driver/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ use std::env;
4747
use std::ffi::OsString;
4848
use std::fs;
4949
use std::io::{self, Read, Write};
50-
use std::lazy::SyncLazy;
5150
use std::panic::{self, catch_unwind};
5251
use std::path::PathBuf;
5352
use std::process::{self, Command, Stdio};
5453
use std::str;
54+
use std::sync::LazyLock;
5555
use std::time::Instant;
5656

5757
pub mod args;
@@ -1141,8 +1141,8 @@ pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
11411141
}
11421142
}
11431143

1144-
static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
1145-
SyncLazy::new(|| {
1144+
static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
1145+
LazyLock::new(|| {
11461146
let hook = panic::take_hook();
11471147
panic::set_hook(Box::new(|info| {
11481148
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
@@ -1237,7 +1237,7 @@ pub fn install_ice_hook() {
12371237
if std::env::var("RUST_BACKTRACE").is_err() {
12381238
std::env::set_var("RUST_BACKTRACE", "full");
12391239
}
1240-
SyncLazy::force(&DEFAULT_HOOK);
1240+
LazyLock::force(&DEFAULT_HOOK);
12411241
}
12421242

12431243
/// This allows tools to enable rust logging without having to magically match rustc's

compiler/rustc_error_messages/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use std::path::{Path, PathBuf};
1818
use tracing::{instrument, trace};
1919

2020
#[cfg(not(parallel_compiler))]
21-
use std::lazy::Lazy;
21+
use std::cell::LazyCell as Lazy;
2222
#[cfg(parallel_compiler)]
23-
use std::lazy::SyncLazy as Lazy;
23+
use std::sync::LazyLock as Lazy;
2424

2525
#[cfg(parallel_compiler)]
2626
use intl_memoizer::concurrent::IntlLangMemoizer;

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{Features, Stability};
99
use rustc_data_structures::fx::FxHashMap;
1010
use rustc_span::symbol::{sym, Symbol};
1111

12-
use std::lazy::SyncLazy;
12+
use std::sync::LazyLock;
1313

1414
type GateFn = fn(&Features) -> bool;
1515

@@ -809,8 +809,8 @@ pub fn is_builtin_only_local(name: Symbol) -> bool {
809809
BUILTIN_ATTRIBUTE_MAP.get(&name).map_or(false, |attr| attr.only_local)
810810
}
811811

812-
pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &BuiltinAttribute>> =
813-
SyncLazy::new(|| {
812+
pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>> =
813+
LazyLock::new(|| {
814814
let mut map = FxHashMap::default();
815815
for attr in BUILTIN_ATTRIBUTES.iter() {
816816
if map.insert(attr.name, attr).is_some() {

compiler/rustc_hir/src/lang_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_macros::HashStable_Generic;
1717
use rustc_span::symbol::{kw, sym, Symbol};
1818
use rustc_span::Span;
1919

20-
use std::lazy::SyncLazy;
20+
use std::sync::LazyLock;
2121

2222
pub enum LangItemGroup {
2323
Op,
@@ -134,7 +134,7 @@ macro_rules! language_item_table {
134134
}
135135

136136
/// A mapping from the name of the lang item to its order and the form it must be of.
137-
pub static ITEM_REFS: SyncLazy<FxHashMap<Symbol, (usize, Target)>> = SyncLazy::new(|| {
137+
pub static ITEM_REFS: LazyLock<FxHashMap<Symbol, (usize, Target)>> = LazyLock::new(|| {
138138
let mut item_refs = FxHashMap::default();
139139
$( item_refs.insert($module::$name, (LangItem::$variant as usize, $target)); )*
140140
item_refs

compiler/rustc_hir/src/weak_lang_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use rustc_ast as ast;
77
use rustc_data_structures::stable_map::StableMap;
88
use rustc_span::symbol::{sym, Symbol};
99

10-
use std::lazy::SyncLazy;
10+
use std::sync::LazyLock;
1111

1212
macro_rules! weak_lang_items {
1313
($($name:ident, $item:ident, $sym:ident;)*) => (
1414

15-
pub static WEAK_ITEMS_REFS: SyncLazy<StableMap<Symbol, LangItem>> = SyncLazy::new(|| {
15+
pub static WEAK_ITEMS_REFS: LazyLock<StableMap<Symbol, LangItem>> = LazyLock::new(|| {
1616
let mut map = StableMap::default();
1717
$(map.insert(sym::$name, LangItem::$item);)*
1818
map

0 commit comments

Comments
 (0)