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:
Chayim Refael Friedman 2024-08-16 09:53:37 +03:00
parent 0daeb5c0b0
commit 955e609867
19 changed files with 49 additions and 54 deletions

View file

@ -4,6 +4,7 @@
//! get a super-set of matches. Then, we confirm each match using precise
//! name resolution.
use std::cell::LazyCell;
use std::mem;
use base_db::{salsa::Database, SourceDatabase, SourceRootDatabase};
@ -12,7 +13,6 @@ use hir::{
InFile, InRealFile, ModuleSource, PathResolution, Semantics, Visibility,
};
use memchr::memmem::Finder;
use once_cell::unsync::Lazy;
use parser::SyntaxKind;
use rustc_hash::FxHashMap;
use span::EditionedFileId;
@ -543,7 +543,7 @@ impl<'a> FindUsages<'a> {
for (text, file_id, search_range) in scope_files(sema, &search_scope) {
self.sema.db.unwind_if_cancelled();
let tree = Lazy::new(move || sema.parse(file_id).syntax().clone());
let tree = LazyCell::new(move || sema.parse(file_id).syntax().clone());
// Search for occurrences of the items name
for offset in match_indices(&text, finder, search_range) {
@ -589,7 +589,7 @@ impl<'a> FindUsages<'a> {
for (text, file_id, search_range) in scope_files(sema, &scope) {
self.sema.db.unwind_if_cancelled();
let tree = Lazy::new(move || sema.parse(file_id).syntax().clone());
let tree = LazyCell::new(move || sema.parse(file_id).syntax().clone());
for offset in match_indices(&text, finder, search_range) {
for name_ref in
@ -641,7 +641,7 @@ impl<'a> FindUsages<'a> {
let search_range =
search_range.unwrap_or_else(|| TextRange::up_to(TextSize::of(&*text)));
let tree = Lazy::new(|| sema.parse(file_id).syntax().clone());
let tree = LazyCell::new(|| sema.parse(file_id).syntax().clone());
let finder = &Finder::new("self");
for offset in match_indices(&text, finder, search_range) {