diff --git a/Cargo.lock b/Cargo.lock index 58e0fae16..5640f5d79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3184,7 +3184,6 @@ name = "sentry-backtrace" version = "0.37.0" dependencies = [ "backtrace", - "once_cell", "regex", "sentry-core", ] @@ -3212,7 +3211,6 @@ dependencies = [ "criterion", "futures", "log", - "once_cell", "rand 0.9.0", "rayon", "regex", @@ -3230,7 +3228,6 @@ name = "sentry-debug-images" version = "0.37.0" dependencies = [ "findshlibs", - "once_cell", "sentry-core", ] diff --git a/sentry-backtrace/Cargo.toml b/sentry-backtrace/Cargo.toml index a3f58eb9e..30c9a63aa 100644 --- a/sentry-backtrace/Cargo.toml +++ b/sentry-backtrace/Cargo.toml @@ -14,7 +14,6 @@ rust-version = "1.81" [dependencies] backtrace = "0.3.44" -once_cell = "1" regex = { version = "1.5.5", default-features = false, features = [ "std", "unicode-perl", diff --git a/sentry-backtrace/src/parse.rs b/sentry-backtrace/src/parse.rs index 03f3df892..f2e82fc03 100644 --- a/sentry-backtrace/src/parse.rs +++ b/sentry-backtrace/src/parse.rs @@ -1,10 +1,11 @@ -use once_cell::sync::Lazy; +use std::sync::LazyLock; + use regex::Regex; use crate::utils::{demangle_symbol, filename, strip_symbol}; use crate::{Frame, Stacktrace}; -static FRAME_RE: Lazy = Lazy::new(|| { +static FRAME_RE: LazyLock = LazyLock::new(|| { Regex::new( r#"(?xm) ^ diff --git a/sentry-backtrace/src/utils.rs b/sentry-backtrace/src/utils.rs index f638eed45..fa8b04400 100644 --- a/sentry-backtrace/src/utils.rs +++ b/sentry-backtrace/src/utils.rs @@ -1,9 +1,8 @@ -use std::borrow::Cow; +use std::{borrow::Cow, sync::LazyLock}; -use once_cell::sync::Lazy; use regex::{Captures, Regex}; -static HASH_FUNC_RE: Lazy = Lazy::new(|| { +static HASH_FUNC_RE: LazyLock = LazyLock::new(|| { Regex::new( r#"(?x) ^(.*)::h[a-f0-9]{16}$ @@ -12,7 +11,7 @@ static HASH_FUNC_RE: Lazy = Lazy::new(|| { .unwrap() }); -static CRATE_HASH_RE: Lazy = Lazy::new(|| { +static CRATE_HASH_RE: LazyLock = LazyLock::new(|| { Regex::new( r"(?x) \b(\[[a-f0-9]{16}\]) @@ -21,7 +20,7 @@ static CRATE_HASH_RE: Lazy = Lazy::new(|| { .unwrap() }); -static CRATE_RE: Lazy = Lazy::new(|| { +static CRATE_RE: LazyLock = LazyLock::new(|| { Regex::new( r"(?x) ^ @@ -34,7 +33,7 @@ static CRATE_RE: Lazy = Lazy::new(|| { .unwrap() }); -static COMMON_RUST_SYMBOL_ESCAPES_RE: Lazy = Lazy::new(|| { +static COMMON_RUST_SYMBOL_ESCAPES_RE: LazyLock = LazyLock::new(|| { Regex::new( r"(?x) \$ diff --git a/sentry-core/Cargo.toml b/sentry-core/Cargo.toml index 09b4574bf..4c101ea25 100644 --- a/sentry-core/Cargo.toml +++ b/sentry-core/Cargo.toml @@ -32,7 +32,6 @@ release-health = [] cadence = { version = "1.4.0", optional = true } crc32fast = { version = "1.4.0", optional = true } log = { version = "0.4.8", optional = true, features = ["std"] } -once_cell = "1" rand = { version = "0.9.0", optional = true } regex = { version = "1.7.3", optional = true } sentry-types = { version = "0.37.0", path = "../sentry-types" } diff --git a/sentry-core/src/constants.rs b/sentry-core/src/constants.rs index f33a606b4..d2ce87fb2 100644 --- a/sentry-core/src/constants.rs +++ b/sentry-core/src/constants.rs @@ -1,7 +1,7 @@ // Not all constants are used when building without the "client" feature #![allow(dead_code)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::protocol::{ClientSdkInfo, ClientSdkPackage}; @@ -9,7 +9,7 @@ use crate::protocol::{ClientSdkInfo, ClientSdkPackage}; const VERSION: &str = env!("CARGO_PKG_VERSION"); pub(crate) const USER_AGENT: &str = concat!("sentry.rust/", env!("CARGO_PKG_VERSION")); -pub(crate) static SDK_INFO: Lazy = Lazy::new(|| ClientSdkInfo { +pub(crate) static SDK_INFO: LazyLock = LazyLock::new(|| ClientSdkInfo { name: "sentry.rust".into(), version: VERSION.into(), packages: vec![ClientSdkPackage { diff --git a/sentry-core/src/hub_impl.rs b/sentry-core/src/hub_impl.rs index 42d1fa6b3..5786daa36 100644 --- a/sentry-core/src/hub_impl.rs +++ b/sentry-core/src/hub_impl.rs @@ -1,13 +1,11 @@ use std::cell::{Cell, UnsafeCell}; -use std::sync::{Arc, PoisonError, RwLock}; +use std::sync::{Arc, LazyLock, PoisonError, RwLock}; use std::thread; use crate::Scope; use crate::{scope::Stack, Client, Hub}; -use once_cell::sync::Lazy; - -static PROCESS_HUB: Lazy<(Arc, thread::ThreadId)> = Lazy::new(|| { +static PROCESS_HUB: LazyLock<(Arc, thread::ThreadId)> = LazyLock::new(|| { ( Arc::new(Hub::new(None, Arc::new(Default::default()))), thread::current().id(), diff --git a/sentry-core/src/test.rs b/sentry-core/src/test.rs index ed92c1c48..a2e150f8e 100644 --- a/sentry-core/src/test.rs +++ b/sentry-core/src/test.rs @@ -19,15 +19,14 @@ //! assert_eq!(events[0].message.as_ref().unwrap(), "Hello World!"); //! ``` -use std::sync::{Arc, Mutex}; - -use once_cell::sync::Lazy; +use std::sync::{Arc, LazyLock, Mutex}; use crate::protocol::Event; use crate::types::Dsn; use crate::{ClientOptions, Envelope, Hub, Transport}; -static TEST_DSN: Lazy = Lazy::new(|| "https://public@sentry.invalid/1".parse().unwrap()); +static TEST_DSN: LazyLock = + LazyLock::new(|| "https://public@sentry.invalid/1".parse().unwrap()); /// Collects events instead of sending them. /// diff --git a/sentry-debug-images/Cargo.toml b/sentry-debug-images/Cargo.toml index 7f4df4c28..035dcc57f 100644 --- a/sentry-debug-images/Cargo.toml +++ b/sentry-debug-images/Cargo.toml @@ -14,5 +14,4 @@ rust-version = "1.81" [dependencies] findshlibs = "=0.10.2" -once_cell = "1" sentry-core = { version = "0.37.0", path = "../sentry-core" } diff --git a/sentry-debug-images/src/integration.rs b/sentry-debug-images/src/integration.rs index 2a60e1713..0039045ca 100644 --- a/sentry-debug-images/src/integration.rs +++ b/sentry-debug-images/src/integration.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; +use std::sync::LazyLock; -use once_cell::sync::Lazy; use sentry_core::protocol::{DebugMeta, Event}; use sentry_core::{ClientOptions, Integration}; @@ -56,7 +56,7 @@ impl Integration for DebugImagesIntegration { mut event: Event<'static>, _opts: &ClientOptions, ) -> Option> { - static DEBUG_META: Lazy = Lazy::new(|| DebugMeta { + static DEBUG_META: LazyLock = LazyLock::new(|| DebugMeta { images: crate::debug_images(), ..Default::default() });