From bd49eec3d76d5894b539a28309c2fe24f915ee94 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Sun, 30 Aug 2020 11:41:36 +0100 Subject: [PATCH] interface: use `OnceCell` from standard library --- Cargo.lock | 1 - compiler/rustc_interface/Cargo.toml | 1 - compiler/rustc_interface/src/passes.rs | 6 +++--- compiler/rustc_interface/src/util.rs | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7be90aaf9e6..3fe024ce318 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3606,7 +3606,6 @@ name = "rustc_interface" version = "0.0.0" dependencies = [ "libc", - "once_cell", "rustc-rayon", "rustc_ast", "rustc_ast_lowering", diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index 9affe4ec6d8..e214493a567 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -43,7 +43,6 @@ rustc_resolve = { path = "../rustc_resolve" } rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_ty = { path = "../rustc_ty" } tempfile = "3.0.5" -once_cell = "1" [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["libloaderapi"] } diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index f33dcec8ba7..66d3765d347 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -2,7 +2,6 @@ use crate::interface::{Compiler, Result}; use crate::proc_macro_decls; use crate::util; -use once_cell::sync::Lazy; use rustc_ast::mut_visit::MutVisitor; use rustc_ast::{self as ast, visit}; use rustc_codegen_ssa::back::link::emit_metadata; @@ -46,6 +45,7 @@ use std::any::Any; use std::cell::RefCell; use std::ffi::OsString; use std::io::{self, BufWriter, Write}; +use std::lazy::SyncLazy; use std::path::PathBuf; use std::rc::Rc; use std::{env, fs, iter, mem}; @@ -681,7 +681,7 @@ pub fn prepare_outputs( Ok(outputs) } -pub static DEFAULT_QUERY_PROVIDERS: Lazy = Lazy::new(|| { +pub static DEFAULT_QUERY_PROVIDERS: SyncLazy = SyncLazy::new(|| { let providers = &mut Providers::default(); providers.analysis = analysis; proc_macro_decls::provide(providers); @@ -704,7 +704,7 @@ pub static DEFAULT_QUERY_PROVIDERS: Lazy = Lazy::new(|| { *providers }); -pub static DEFAULT_EXTERN_QUERY_PROVIDERS: Lazy = Lazy::new(|| { +pub static DEFAULT_EXTERN_QUERY_PROVIDERS: SyncLazy = SyncLazy::new(|| { let mut extern_providers = *DEFAULT_QUERY_PROVIDERS; rustc_metadata::provide_extern(&mut extern_providers); rustc_codegen_ssa::provide_extern(&mut extern_providers); diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 8816ba198cf..b1b39fd1ad2 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -25,6 +25,7 @@ use rustc_span::symbol::{sym, Symbol}; use smallvec::SmallVec; use std::env; use std::io::{self, Write}; +use std::lazy::SyncOnceCell; use std::mem; use std::ops::DerefMut; use std::path::{Path, PathBuf}; @@ -243,8 +244,7 @@ pub fn get_codegen_backend(sess: &Session) -> Box { // loading, so we leave the code here. It is potentially useful for other tools // that want to invoke the rustc binary while linking to rustc as well. pub fn rustc_path<'a>() -> Option<&'a Path> { - static RUSTC_PATH: once_cell::sync::OnceCell> = - once_cell::sync::OnceCell::new(); + static RUSTC_PATH: SyncOnceCell> = SyncOnceCell::new(); const BIN_PATH: &str = env!("RUSTC_INSTALL_BINDIR");