mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/Lock
This doesn't get rid of the once_cell dependency, unfortunately, since we have dependencies that use it, but it's a nice to do cleanup. And when our deps will eventually get rid of once_cell we will get rid of it for free.
This commit is contained in:
parent
0daeb5c0b0
commit
955e609867
19 changed files with 49 additions and 54 deletions
|
@ -1,10 +1,10 @@
|
|||
//! Interface with `rustc_pattern_analysis`.
|
||||
|
||||
use std::cell::LazyCell;
|
||||
use std::fmt;
|
||||
|
||||
use hir_def::{DefWithBodyId, EnumId, EnumVariantId, HasModule, LocalFieldId, ModuleId, VariantId};
|
||||
use intern::sym;
|
||||
use once_cell::unsync::Lazy;
|
||||
use rustc_pattern_analysis::{
|
||||
constructor::{Constructor, ConstructorSet, VariantVisibility},
|
||||
usefulness::{compute_match_usefulness, PlaceValidity, UsefulnessReport},
|
||||
|
@ -388,8 +388,9 @@ impl<'db> PatCx for MatchCheckCtx<'db> {
|
|||
let variant = Self::variant_id_for_adt(self.db, ctor, adt).unwrap();
|
||||
|
||||
// Whether we must not match the fields of this variant exhaustively.
|
||||
let is_non_exhaustive = Lazy::new(|| self.is_foreign_non_exhaustive(adt));
|
||||
let visibilities = Lazy::new(|| self.db.field_visibilities(variant));
|
||||
let is_non_exhaustive =
|
||||
LazyCell::new(|| self.is_foreign_non_exhaustive(adt));
|
||||
let visibilities = LazyCell::new(|| self.db.field_visibilities(variant));
|
||||
|
||||
self.list_variant_fields(ty, variant)
|
||||
.map(move |(fid, ty)| {
|
||||
|
|
|
@ -22,7 +22,7 @@ mod pat;
|
|||
mod path;
|
||||
pub(crate) mod unify;
|
||||
|
||||
use std::{convert::identity, iter, ops::Index};
|
||||
use std::{cell::OnceCell, convert::identity, iter, ops::Index};
|
||||
|
||||
use chalk_ir::{
|
||||
cast::Cast,
|
||||
|
@ -50,7 +50,6 @@ use hir_expand::name::Name;
|
|||
use indexmap::IndexSet;
|
||||
use intern::sym;
|
||||
use la_arena::{ArenaMap, Entry};
|
||||
use once_cell::unsync::OnceCell;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use stdx::{always, never};
|
||||
use triomphe::Arc;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//!
|
||||
//! This usually involves resolving names, collecting generic arguments etc.
|
||||
use std::{
|
||||
cell::{Cell, RefCell, RefMut},
|
||||
cell::{Cell, OnceCell, RefCell, RefMut},
|
||||
iter,
|
||||
ops::{self, Not as _},
|
||||
};
|
||||
|
@ -43,7 +43,6 @@ use hir_def::{
|
|||
use hir_expand::{name::Name, ExpandResult};
|
||||
use intern::Interned;
|
||||
use la_arena::{Arena, ArenaMap};
|
||||
use once_cell::unsync::OnceCell;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustc_pattern_analysis::Captures;
|
||||
use smallvec::SmallVec;
|
||||
|
|
|
@ -11,6 +11,7 @@ mod simple;
|
|||
mod traits;
|
||||
|
||||
use std::env;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use base_db::SourceDatabaseFileInputExt as _;
|
||||
use expect_test::Expect;
|
||||
|
@ -24,7 +25,6 @@ use hir_def::{
|
|||
AssocItemId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleDefId,
|
||||
};
|
||||
use hir_expand::{db::ExpandDatabase, FileRange, InFile};
|
||||
use once_cell::race::OnceBool;
|
||||
use rustc_hash::FxHashMap;
|
||||
use stdx::format_to;
|
||||
use syntax::{
|
||||
|
@ -49,8 +49,8 @@ use crate::{
|
|||
// `env UPDATE_EXPECT=1 cargo test -p hir_ty` to update the snapshots.
|
||||
|
||||
fn setup_tracing() -> Option<tracing::subscriber::DefaultGuard> {
|
||||
static ENABLE: OnceBool = OnceBool::new();
|
||||
if !ENABLE.get_or_init(|| env::var("CHALK_DEBUG").is_ok()) {
|
||||
static ENABLE: LazyLock<bool> = LazyLock::new(|| env::var("CHALK_DEBUG").is_ok());
|
||||
if !*ENABLE {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue