diff --git a/Cargo.lock b/Cargo.lock index e97bd174..40ad67f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4038,7 +4038,6 @@ dependencies = [ "itertools 0.13.0", "log", "lsp-types", - "once_cell", "open", "parking_lot", "paste", @@ -4235,7 +4234,6 @@ dependencies = [ "itertools 0.13.0", "log", "lsp-types", - "once_cell", "parking_lot", "percent-encoding", "rayon", @@ -4889,7 +4887,6 @@ dependencies = [ "futures", "indexmap 2.8.0", "log", - "once_cell", "parking_lot", "reflexo-typst", "reflexo-vec2svg", diff --git a/Cargo.toml b/Cargo.toml index 8e08d0c9..65c87dc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ members = ["benches/*", "crates/*", "tests"] anyhow = "1" if_chain = "1" itertools = "0.13" -once_cell = "1" paste = "1.0" cfg-if = "1.0" strum = { version = "0.26.2", features = ["derive"] } diff --git a/crates/tinymist-query/Cargo.toml b/crates/tinymist-query/Cargo.toml index f5224061..89064b45 100644 --- a/crates/tinymist-query/Cargo.toml +++ b/crates/tinymist-query/Cargo.toml @@ -27,7 +27,6 @@ serde.workspace = true serde_json.workspace = true parking_lot.workspace = true ena.workspace = true -once_cell.workspace = true toml.workspace = true walkdir.workspace = true indexmap.workspace = true @@ -61,7 +60,6 @@ tinymist-std.workspace = true tinymist-l10n.workspace = true [dev-dependencies] -once_cell.workspace = true insta.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/crates/tinymist-query/src/analysis/completion.rs b/crates/tinymist-query/src/analysis/completion.rs index 4bde1941..65be27f9 100644 --- a/crates/tinymist-query/src/analysis/completion.rs +++ b/crates/tinymist-query/src/analysis/completion.rs @@ -7,7 +7,6 @@ use std::ops::Range; use ecow::{eco_format, EcoString}; use if_chain::if_chain; use lsp_types::InsertTextFormat; -use once_cell::sync::Lazy; use regex::{Captures, Regex}; use serde::{Deserialize, Serialize}; use tinymist_analysis::syntax::{bad_completion_cursor, BadCompletionCursor}; @@ -890,8 +889,8 @@ fn slice_at(s: &str, mut rng: Range) -> &str { &s[rng] } -static TYPST_SNIPPET_PLACEHOLDER_RE: Lazy = - Lazy::new(|| Regex::new(r"\$\{(.*?)\}").unwrap()); +static TYPST_SNIPPET_PLACEHOLDER_RE: LazyLock = + LazyLock::new(|| Regex::new(r"\$\{(.*?)\}").unwrap()); /// Adds numbering to placeholders in snippets fn to_lsp_snippet(typst_snippet: &str) -> EcoString { diff --git a/crates/tinymist-query/src/analysis/global.rs b/crates/tinymist-query/src/analysis/global.rs index 94cf2d93..ba519d2b 100644 --- a/crates/tinymist-query/src/analysis/global.rs +++ b/crates/tinymist-query/src/analysis/global.rs @@ -1,11 +1,11 @@ use std::num::NonZeroUsize; use std::ops::DerefMut; use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::OnceLock; use std::{collections::HashSet, ops::Deref}; use comemo::{Track, Tracked}; use lsp_types::Url; -use once_cell::sync::OnceCell; use parking_lot::Mutex; use rustc_hash::FxHashMap; use tinymist_project::LspWorld; @@ -1009,7 +1009,7 @@ impl SharedContext { } // Needed by recursive computation -type DeferredCompute = Arc>; +type DeferredCompute = Arc>; #[derive(Clone)] struct IncrCacheMap { @@ -1142,9 +1142,9 @@ pub struct AnalysisGlobalCaches { #[derive(Default)] pub struct AnalysisLocalCaches { modules: HashMap, - completion_files: OnceCell>, - root_files: OnceCell>, - module_deps: OnceCell>, + completion_files: OnceLock>, + root_files: OnceLock>, + module_deps: OnceLock>, } /// A local cache for module-level analysis results of a module. @@ -1153,8 +1153,8 @@ pub struct AnalysisLocalCaches { /// change. #[derive(Default)] pub struct ModuleAnalysisLocalCache { - expr_stage: OnceCell>, - type_check: OnceCell>, + expr_stage: OnceLock>, + type_check: OnceLock>, } /// A revision-managed (per input change) cache for all level of analysis diff --git a/crates/tinymist-query/src/diagnostics.rs b/crates/tinymist-query/src/diagnostics.rs index 53551e7f..1addd0c9 100644 --- a/crates/tinymist-query/src/diagnostics.rs +++ b/crates/tinymist-query/src/diagnostics.rs @@ -5,7 +5,6 @@ use typst::syntax::Span; use crate::{prelude::*, LspWorldExt}; -use once_cell::sync::Lazy; use regex::RegexSet; /// Stores diagnostics for files. @@ -198,7 +197,7 @@ trait DiagnosticRefiner { struct DeprecationRefiner(); -static DEPRECATION_PATTERNS: Lazy = Lazy::new(|| { +static DEPRECATION_PATTERNS: LazyLock = LazyLock::new(|| { RegexSet::new([ r"unknown variable: style", r"unexpected argument: fill", diff --git a/crates/tinymist-query/src/signature_help.rs b/crates/tinymist-query/src/signature_help.rs index 46eef732..4d39a019 100644 --- a/crates/tinymist-query/src/signature_help.rs +++ b/crates/tinymist-query/src/signature_help.rs @@ -1,4 +1,3 @@ -use once_cell::sync::OnceCell; use typst_shim::syntax::LinkedNodeExt; use crate::{ @@ -52,7 +51,7 @@ impl SemanticRequest for SignatureHelpRequest { label.push('('); let mut real_offset = 0; - let focus_name = OnceCell::new(); + let focus_name = OnceLock::new(); for (idx, (param, ty)) in sig.params().enumerate() { if is_set && !param.attrs.settable { continue; diff --git a/crates/tinymist-query/src/syntax/module.rs b/crates/tinymist-query/src/syntax/module.rs index dae75edd..f2f421b6 100644 --- a/crates/tinymist-query/src/syntax/module.rs +++ b/crates/tinymist-query/src/syntax/module.rs @@ -1,6 +1,5 @@ use std::sync::Once; -use once_cell::sync::Lazy; use regex::RegexSet; use crate::prelude::*; @@ -95,7 +94,7 @@ pub(crate) fn scan_workspace_files( } /// this is a temporary solution to ignore some common build directories - static IGNORE_REGEX: Lazy = Lazy::new(|| { + static IGNORE_REGEX: LazyLock = LazyLock::new(|| { RegexSet::new([ r#"^build$"#, r#"^target$"#, diff --git a/crates/tinymist-query/src/tests.rs b/crates/tinymist-query/src/tests.rs index 09579305..b9d1bd8d 100644 --- a/crates/tinymist-query/src/tests.rs +++ b/crates/tinymist-query/src/tests.rs @@ -8,7 +8,6 @@ use std::{ path::{Path, PathBuf}, }; -use once_cell::sync::Lazy; use serde_json::{ser::PrettyFormatter, Serializer, Value}; use tinymist_project::{CompileFontArgs, ExportTarget, LspCompileSnapshot, LspComputeGraph}; use tinymist_std::path::unix_slash; @@ -353,7 +352,7 @@ pub fn make_range_annoation(source: &Source) -> String { // pub static REDACT_URI: Lazy = Lazy::new(|| // RedactFields::from_iter(["uri"])); -pub static REDACT_LOC: Lazy = Lazy::new(|| { +pub static REDACT_LOC: LazyLock = LazyLock::new(|| { RedactFields::from_iter([ "location", "contents", diff --git a/crates/tinymist-query/src/ty/builtin.rs b/crates/tinymist-query/src/ty/builtin.rs index c6e62f50..24d54ab7 100644 --- a/crates/tinymist-query/src/ty/builtin.rs +++ b/crates/tinymist-query/src/ty/builtin.rs @@ -1,8 +1,8 @@ use core::fmt; use std::path::Path; +use std::sync::LazyLock; use ecow::{eco_format, EcoString}; -use once_cell::sync::Lazy; use regex::RegexSet; use strum::{EnumIter, IntoEnumIterator}; use typst::foundations::{CastInfo, Regex}; @@ -36,31 +36,33 @@ pub enum PathPreference { impl PathPreference { pub fn ext_matcher(&self) -> &'static RegexSet { + type RegSet = LazyLock; + fn make_regex(patterns: &[&str]) -> RegexSet { let patterns = patterns.iter().map(|pattern| format!("(?i)^{pattern}$")); RegexSet::new(patterns).unwrap() } - static SOURCE_REGSET: Lazy = Lazy::new(|| make_regex(&["typ", "typc"])); - static WASM_REGSET: Lazy = Lazy::new(|| make_regex(&["wasm"])); - static IMAGE_REGSET: Lazy = Lazy::new(|| { + static SOURCE_REGSET: RegSet = RegSet::new(|| make_regex(&["typ", "typc"])); + static WASM_REGSET: RegSet = RegSet::new(|| make_regex(&["wasm"])); + static IMAGE_REGSET: RegSet = RegSet::new(|| { make_regex(&[ "ico", "bmp", "png", "webp", "jpg", "jpeg", "jfif", "tiff", "gif", "svg", "svgz", ]) }); - static JSON_REGSET: Lazy = Lazy::new(|| make_regex(&["json", "jsonc", "json5"])); - static YAML_REGSET: Lazy = Lazy::new(|| make_regex(&["yaml", "yml"])); - static XML_REGSET: Lazy = Lazy::new(|| make_regex(&["xml"])); - static TOML_REGSET: Lazy = Lazy::new(|| make_regex(&["toml"])); - static CSV_REGSET: Lazy = Lazy::new(|| make_regex(&["csv"])); - static BIB_REGSET: Lazy = Lazy::new(|| make_regex(&["yaml", "yml", "bib"])); - static CSL_REGSET: Lazy = Lazy::new(|| make_regex(&["csl"])); - static RAW_THEME_REGSET: Lazy = Lazy::new(|| make_regex(&["tmTheme", "xml"])); - static RAW_SYNTAX_REGSET: Lazy = - Lazy::new(|| make_regex(&["tmLanguage", "sublime-syntax"])); + static JSON_REGSET: RegSet = RegSet::new(|| make_regex(&["json", "jsonc", "json5"])); + static YAML_REGSET: RegSet = RegSet::new(|| make_regex(&["yaml", "yml"])); + static XML_REGSET: RegSet = RegSet::new(|| make_regex(&["xml"])); + static TOML_REGSET: RegSet = RegSet::new(|| make_regex(&["toml"])); + static CSV_REGSET: RegSet = RegSet::new(|| make_regex(&["csv"])); + static BIB_REGSET: RegSet = RegSet::new(|| make_regex(&["yaml", "yml", "bib"])); + static CSL_REGSET: RegSet = RegSet::new(|| make_regex(&["csl"])); + static RAW_THEME_REGSET: RegSet = RegSet::new(|| make_regex(&["tmTheme", "xml"])); + static RAW_SYNTAX_REGSET: RegSet = + RegSet::new(|| make_regex(&["tmLanguage", "sublime-syntax"])); - static ALL_REGSET: Lazy = Lazy::new(|| RegexSet::new([r".*"]).unwrap()); - static ALL_SPECIAL_REGSET: Lazy = Lazy::new(|| { + static ALL_REGSET: RegSet = RegSet::new(|| RegexSet::new([r".*"]).unwrap()); + static ALL_SPECIAL_REGSET: RegSet = RegSet::new(|| { RegexSet::new({ let patterns = SOURCE_REGSET.patterns(); let patterns = patterns.iter().chain(WASM_REGSET.patterns()); @@ -501,7 +503,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { Ty::from_cast_info(¶m.input), ])), ("link", "dest") => { - static LINK_DEST_TYPE: Lazy = Lazy::new(|| { + static LINK_DEST_TYPE: LazyLock = LazyLock::new(|| { flow_union!( literally(RefLabel), Ty::Builtin(BuiltinTy::Type(Type::of::())), @@ -515,7 +517,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { Some(LINK_DEST_TYPE.clone()) } ("bibliography", "path" | "sources") => { - static BIB_PATH_TYPE: Lazy = Lazy::new(|| { + static BIB_PATH_TYPE: LazyLock = LazyLock::new(|| { let bib_path_ty = literally(Path(PathPreference::Bibliography)); Ty::iter_union([bib_path_ty.clone(), Ty::Array(bib_path_ty.into())]) }); @@ -524,13 +526,13 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { ("text", "size") => Some(literally(TextSize)), ("text", "font") => { // todo: the dict can be completed, but we have bugs... - static FONT_TYPE: Lazy = Lazy::new(|| { + static FONT_TYPE: LazyLock = LazyLock::new(|| { Ty::iter_union([literally(TextFont), Ty::Array(literally(TextFont).into())]) }); Some(FONT_TYPE.clone()) } ("text", "feature") => { - static FONT_TYPE: Lazy = Lazy::new(|| { + static FONT_TYPE: LazyLock = LazyLock::new(|| { Ty::iter_union([ // todo: the key can only be the text feature Ty::Builtin(BuiltinTy::Type(Type::of::())), @@ -540,7 +542,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { Some(FONT_TYPE.clone()) } ("text", "costs") => { - static FONT_TYPE: Lazy = Lazy::new(|| { + static FONT_TYPE: LazyLock = LazyLock::new(|| { Ty::Dict(flow_record!( "hyphenation" => literally(BuiltinTy::Type(Type::of::())), "runt" => literally(BuiltinTy::Type(Type::of::())), @@ -554,7 +556,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { ("text", "region") => Some(literally(TextRegion)), ("text" | "stack", "dir") => Some(literally(Dir)), ("par", "first-line-indent") => { - static FIRST_LINE_INDENT: Lazy = Lazy::new(|| { + static FIRST_LINE_INDENT: LazyLock = LazyLock::new(|| { Ty::iter_union([ literally(Length), Ty::Dict(RecordTy::new(vec![ @@ -581,7 +583,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { } ("block" | "box" | "rect" | "square" | "highlight", "radius") => Some(literally(Radius)), ("grid" | "table", "columns" | "rows" | "gutter" | "column-gutter" | "row-gutter") => { - static COLUMN_TYPE: Lazy = Lazy::new(|| { + static COLUMN_TYPE: LazyLock = LazyLock::new(|| { flow_union!( Ty::Value(InsTy::new(Value::Auto)), Ty::Value(InsTy::new(Value::Type(Type::of::()))), @@ -592,7 +594,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { Some(COLUMN_TYPE.clone()) } ("pattern" | "tiling", "size") => { - static PATTERN_SIZE_TYPE: Lazy = Lazy::new(|| { + static PATTERN_SIZE_TYPE: LazyLock = LazyLock::new(|| { flow_union!( Ty::Value(InsTy::new(Value::Auto)), Ty::Array(Ty::Builtin(Length).into()), @@ -613,7 +615,7 @@ pub(super) fn param_mapping(func: &Func, param: &ParamInfo) -> Option { } } -static FLOW_STROKE_DASH_TYPE: Lazy = Lazy::new(|| { +static FLOW_STROKE_DASH_TYPE: LazyLock = LazyLock::new(|| { flow_union!( "solid", "dotted", @@ -633,7 +635,7 @@ static FLOW_STROKE_DASH_TYPE: Lazy = Lazy::new(|| { ) }); -pub static FLOW_STROKE_DICT: Lazy> = Lazy::new(|| { +pub static FLOW_STROKE_DICT: LazyLock> = LazyLock::new(|| { flow_record!( "paint" => literally(Color), "thickness" => literally(Length), @@ -644,7 +646,7 @@ pub static FLOW_STROKE_DICT: Lazy> = Lazy::new(|| { ) }); -pub static FLOW_MARGIN_DICT: Lazy> = Lazy::new(|| { +pub static FLOW_MARGIN_DICT: LazyLock> = LazyLock::new(|| { flow_record!( "top" => literally(Length), "right" => literally(Length), @@ -658,7 +660,7 @@ pub static FLOW_MARGIN_DICT: Lazy> = Lazy::new(|| { ) }); -pub static FLOW_INSET_DICT: Lazy> = Lazy::new(|| { +pub static FLOW_INSET_DICT: LazyLock> = LazyLock::new(|| { flow_record!( "top" => literally(Length), "right" => literally(Length), @@ -670,7 +672,7 @@ pub static FLOW_INSET_DICT: Lazy> = Lazy::new(|| { ) }); -pub static FLOW_OUTSET_DICT: Lazy> = Lazy::new(|| { +pub static FLOW_OUTSET_DICT: LazyLock> = LazyLock::new(|| { flow_record!( "top" => literally(Length), "right" => literally(Length), @@ -682,7 +684,7 @@ pub static FLOW_OUTSET_DICT: Lazy> = Lazy::new(|| { ) }); -pub static FLOW_RADIUS_DICT: Lazy> = Lazy::new(|| { +pub static FLOW_RADIUS_DICT: LazyLock> = LazyLock::new(|| { flow_record!( "top" => literally(Length), "right" => literally(Length), @@ -696,7 +698,7 @@ pub static FLOW_RADIUS_DICT: Lazy> = Lazy::new(|| { ) }); -pub static FLOW_TEXT_FONT_DICT: Lazy> = Lazy::new(|| { +pub static FLOW_TEXT_FONT_DICT: LazyLock> = LazyLock::new(|| { flow_record!( "name" => literally(TextFont), "covers" => flow_union!("latin-in-cjk", BuiltinTy::Type(Type::of::())), diff --git a/crates/tinymist-query/src/ty/def.rs b/crates/tinymist-query/src/ty/def.rs index f390d664..bbb3b9f9 100644 --- a/crates/tinymist-query/src/ty/def.rs +++ b/crates/tinymist-query/src/ty/def.rs @@ -5,11 +5,10 @@ use core::fmt; use std::{ hash::{Hash, Hasher}, - sync::Arc, + sync::{Arc, OnceLock}, }; use ecow::EcoString; -use once_cell::sync::OnceCell; use parking_lot::{Mutex, RwLock}; use rustc_hash::{FxHashMap, FxHashSet}; use serde::{Deserialize, Serialize}; @@ -283,7 +282,7 @@ pub struct TypeSource { /// A name node with span pub name_node: SyntaxNode, /// A lazy evaluated name - pub name_repr: OnceCell, + pub name_repr: OnceLock, /// Attached documentation pub doc: StrRef, } @@ -509,7 +508,7 @@ impl InsTy { val, syntax: Some(Interned::new(TypeSource { name_node: name, - name_repr: OnceCell::new(), + name_repr: OnceLock::new(), doc: "".into(), })), }) @@ -520,7 +519,7 @@ impl InsTy { val, syntax: Some(Interned::new(TypeSource { name_node: SyntaxNode::default(), - name_repr: OnceCell::new(), + name_repr: OnceLock::new(), doc: doc.into(), })), }) diff --git a/crates/tinymist-query/src/upstream/mod.rs b/crates/tinymist-query/src/upstream/mod.rs index 886459e2..cd67efa2 100644 --- a/crates/tinymist-query/src/upstream/mod.rs +++ b/crates/tinymist-query/src/upstream/mod.rs @@ -1,8 +1,7 @@ -use std::{collections::HashMap, fmt::Write}; +use std::{collections::HashMap, fmt::Write, sync::LazyLock}; use comemo::Tracked; use ecow::{eco_format, EcoString}; -use once_cell::sync::Lazy; use serde::Deserialize; use serde_yaml as yaml; use typst::{ @@ -105,7 +104,7 @@ impl GroupData { } } -static GROUPS: Lazy> = Lazy::new(|| { +static GROUPS: LazyLock> = LazyLock::new(|| { let mut groups: Vec = yaml::from_str(include_str!("groups.yml")).unwrap(); for group in &mut groups { if group.filter.is_empty() { @@ -170,7 +169,7 @@ fn resolve_known(head: &str, base: &str) -> Option { }) } -static LIBRARY: Lazy = Lazy::new(Library::default); +static LIBRARY: LazyLock = LazyLock::new(Library::default); /// Extract a module from another module. #[track_caller] @@ -274,7 +273,7 @@ impl PartialEq for CatKey { impl Eq for CatKey {} // todo: category of types -static ROUTE_MAPS: Lazy> = Lazy::new(|| { +static ROUTE_MAPS: LazyLock> = LazyLock::new(|| { // todo: this is a false positive for clippy on LazyHash #[allow(clippy::mutable_key_type)] let mut map = HashMap::new(); diff --git a/crates/tinymist/Cargo.toml b/crates/tinymist/Cargo.toml index 3cdaddbb..a80bf68e 100644 --- a/crates/tinymist/Cargo.toml +++ b/crates/tinymist/Cargo.toml @@ -42,7 +42,6 @@ hyper-tungstenite = { workspace = true, optional = true } itertools.workspace = true lsp-types.workspace = true log.workspace = true -once_cell.workspace = true open.workspace = true parking_lot.workspace = true paste.workspace = true diff --git a/crates/tinymist/src/config.rs b/crates/tinymist/src/config.rs index 826f4aae..c009c892 100644 --- a/crates/tinymist/src/config.rs +++ b/crates/tinymist/src/config.rs @@ -1,11 +1,10 @@ use core::fmt; use std::path::{Path, PathBuf}; -use std::sync::Arc; +use std::sync::{Arc, LazyLock, OnceLock}; use clap::Parser; use itertools::Itertools; use lsp_types::*; -use once_cell::sync::{Lazy, OnceCell}; use reflexo::error::IgnoreLogging; use reflexo::CowStr; use reflexo_typst::{ImmutPath, TypstDict}; @@ -97,7 +96,7 @@ pub struct Config { /// Specifies the font paths pub font_paths: Vec, /// Computed fonts based on configuration. - pub fonts: OnceCell>>, + pub fonts: OnceLock>>, /// Whether to use system fonts. pub system_fonts: Option, @@ -533,7 +532,7 @@ impl Config { opts.font_paths.clone_from(paths); } - let root = OnceCell::new(); + let root = OnceLock::new(); for path in opts.font_paths.iter_mut() { if path.is_relative() { if let Some(root) = root.get_or_init(|| self.entry_resolver.root(None)) { @@ -586,7 +585,7 @@ impl Config { } fn user_inputs(&self) -> ImmutDict { - static EMPTY: Lazy = Lazy::new(ImmutDict::default); + static EMPTY: LazyLock = LazyLock::new(ImmutDict::default); if let Some(extras) = &self.typst_extra_args { return extras.inputs.clone(); @@ -852,7 +851,6 @@ pub(crate) fn get_semantic_tokens_options() -> SemanticTokensOptions { mod tests { use super::*; use serde_json::json; - use tinymist_project::PathPattern; fn update_config(config: &mut Config, update: &JsonValue) -> Result<()> { temp_env::with_vars_unset(Vec::::new(), || config.update(update)) diff --git a/crates/tinymist/src/lsp.rs b/crates/tinymist/src/lsp.rs index 7ba8996b..6d80ae57 100644 --- a/crates/tinymist/src/lsp.rs +++ b/crates/tinymist/src/lsp.rs @@ -1,6 +1,7 @@ +use std::sync::OnceLock; + use lsp_types::request::WorkspaceConfiguration; use lsp_types::*; -use once_cell::sync::OnceCell; use reflexo::ImmutPath; use request::{RegisterCapability, UnregisterCapability}; use serde_json::{Map, Value as JsonValue}; @@ -149,7 +150,7 @@ impl ServerState { } if old_config.primary_opts() != self.config.primary_opts() { - self.config.fonts = OnceCell::new(); // todo: don't reload fonts if not changed + self.config.fonts = OnceLock::new(); // todo: don't reload fonts if not changed self.reload_projects() .log_error("could not restart primary"); } diff --git a/crates/tinymist/src/main.rs b/crates/tinymist/src/main.rs index 55f0ba2c..ac4d6782 100644 --- a/crates/tinymist/src/main.rs +++ b/crates/tinymist/src/main.rs @@ -5,12 +5,12 @@ mod args; use std::io; use std::path::{Path, PathBuf}; use std::str::FromStr; +use std::sync::LazyLock; use clap::Parser; use clap_builder::CommandFactory; use clap_complete::generate; use futures::future::MaybeDone; -use once_cell::sync::Lazy; use reflexo::ImmutPath; use reflexo_typst::package::PackageSpec; use sync_ls::transport::{with_stdio_transport, MirrorArgs}; @@ -53,7 +53,7 @@ impl Default for Runtimes { } } -static RUNTIMES: Lazy = Lazy::new(Runtimes::default); +static RUNTIMES: LazyLock = LazyLock::new(Runtimes::default); /// The main entry point. fn main() -> Result<()> { diff --git a/crates/tinymist/src/resource/mod.rs b/crates/tinymist/src/resource/mod.rs index dd7c8054..553d543d 100644 --- a/crates/tinymist/src/resource/mod.rs +++ b/crates/tinymist/src/resource/mod.rs @@ -5,7 +5,6 @@ mod prelude { pub use std::collections::HashMap; - pub use once_cell::sync::Lazy; pub use reflexo_vec2svg::ir::{GlyphItem, GlyphRef}; pub use reflexo_vec2svg::{DefaultExportFeature, SvgTask, SvgText}; pub use serde::{Deserialize, Serialize}; diff --git a/crates/tinymist/src/resource/symbols.rs b/crates/tinymist/src/resource/symbols.rs index df762d4a..6600ac0d 100644 --- a/crates/tinymist/src/resource/symbols.rs +++ b/crates/tinymist/src/resource/symbols.rs @@ -1,3 +1,4 @@ +use std::sync::LazyLock; use std::{collections::BTreeMap, path::Path, sync::Arc}; use reflexo_typst::TypstPagedDocument; @@ -85,7 +86,7 @@ struct FontItem { type ResourceSymbolMap = BTreeMap; -static CAT_MAP: Lazy> = Lazy::new(|| { +static CAT_MAP: LazyLock> = LazyLock::new(|| { use SymCategory::*; HashMap::from_iter([ diff --git a/crates/typst-preview/Cargo.toml b/crates/typst-preview/Cargo.toml index 448f9a20..a2000ac8 100644 --- a/crates/typst-preview/Cargo.toml +++ b/crates/typst-preview/Cargo.toml @@ -19,7 +19,6 @@ comemo.workspace = true reflexo-vec2svg.workspace = true reflexo-typst.workspace = true -once_cell.workspace = true tokio.workspace = true env_logger.workspace = true log.workspace = true diff --git a/crates/typst-preview/src/lib.rs b/crates/typst-preview/src/lib.rs index 44ba7f8d..3c8cbad9 100644 --- a/crates/typst-preview/src/lib.rs +++ b/crates/typst-preview/src/lib.rs @@ -10,10 +10,10 @@ pub use actor::editor::{ pub use args::*; pub use outline::Outline; +use std::sync::OnceLock; use std::{collections::HashMap, future::Future, path::PathBuf, pin::Pin, sync::Arc}; use futures::sink::SinkExt; -use once_cell::sync::OnceCell; use reflexo_typst::debug_loc::{DocumentPosition, SourceSpanOffset}; use reflexo_typst::Error; use serde::{Deserialize, Serialize}; @@ -197,7 +197,7 @@ pub struct PreviewBuilder { webview_conn: BroadcastChannel, doc_sender: Arc>>>, - compile_watcher: OnceCell>, + compile_watcher: OnceLock>, } impl PreviewBuilder { @@ -209,7 +209,7 @@ impl PreviewBuilder { editor_conn: mpsc::unbounded_channel(), webview_conn: broadcast::channel(32), doc_sender: Arc::new(parking_lot::RwLock::new(None)), - compile_watcher: OnceCell::new(), + compile_watcher: OnceLock::new(), } }