Skip to content

Commit f005af8

Browse files
authored
Replace once_cell with std::sync::LazyLock (#776)
1 parent 6f56832 commit f005af8

File tree

10 files changed

+17
-26
lines changed

10 files changed

+17
-26
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sentry-backtrace/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ rust-version = "1.81"
1414

1515
[dependencies]
1616
backtrace = "0.3.44"
17-
once_cell = "1"
1817
regex = { version = "1.5.5", default-features = false, features = [
1918
"std",
2019
"unicode-perl",

sentry-backtrace/src/parse.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use once_cell::sync::Lazy;
1+
use std::sync::LazyLock;
2+
23
use regex::Regex;
34

45
use crate::utils::{demangle_symbol, filename, strip_symbol};
56
use crate::{Frame, Stacktrace};
67

7-
static FRAME_RE: Lazy<Regex> = Lazy::new(|| {
8+
static FRAME_RE: LazyLock<Regex> = LazyLock::new(|| {
89
Regex::new(
910
r#"(?xm)
1011
^

sentry-backtrace/src/utils.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use std::borrow::Cow;
1+
use std::{borrow::Cow, sync::LazyLock};
22

3-
use once_cell::sync::Lazy;
43
use regex::{Captures, Regex};
54

6-
static HASH_FUNC_RE: Lazy<Regex> = Lazy::new(|| {
5+
static HASH_FUNC_RE: LazyLock<Regex> = LazyLock::new(|| {
76
Regex::new(
87
r#"(?x)
98
^(.*)::h[a-f0-9]{16}$
@@ -12,7 +11,7 @@ static HASH_FUNC_RE: Lazy<Regex> = Lazy::new(|| {
1211
.unwrap()
1312
});
1413

15-
static CRATE_HASH_RE: Lazy<Regex> = Lazy::new(|| {
14+
static CRATE_HASH_RE: LazyLock<Regex> = LazyLock::new(|| {
1615
Regex::new(
1716
r"(?x)
1817
\b(\[[a-f0-9]{16}\])
@@ -21,7 +20,7 @@ static CRATE_HASH_RE: Lazy<Regex> = Lazy::new(|| {
2120
.unwrap()
2221
});
2322

24-
static CRATE_RE: Lazy<Regex> = Lazy::new(|| {
23+
static CRATE_RE: LazyLock<Regex> = LazyLock::new(|| {
2524
Regex::new(
2625
r"(?x)
2726
^
@@ -34,7 +33,7 @@ static CRATE_RE: Lazy<Regex> = Lazy::new(|| {
3433
.unwrap()
3534
});
3635

37-
static COMMON_RUST_SYMBOL_ESCAPES_RE: Lazy<Regex> = Lazy::new(|| {
36+
static COMMON_RUST_SYMBOL_ESCAPES_RE: LazyLock<Regex> = LazyLock::new(|| {
3837
Regex::new(
3938
r"(?x)
4039
\$

sentry-core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ release-health = []
3232
cadence = { version = "1.4.0", optional = true }
3333
crc32fast = { version = "1.4.0", optional = true }
3434
log = { version = "0.4.8", optional = true, features = ["std"] }
35-
once_cell = "1"
3635
rand = { version = "0.9.0", optional = true }
3736
regex = { version = "1.7.3", optional = true }
3837
sentry-types = { version = "0.37.0", path = "../sentry-types" }

sentry-core/src/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Not all constants are used when building without the "client" feature
22
#![allow(dead_code)]
33

4-
use once_cell::sync::Lazy;
4+
use std::sync::LazyLock;
55

66
use crate::protocol::{ClientSdkInfo, ClientSdkPackage};
77

88
/// The version of the library
99
const VERSION: &str = env!("CARGO_PKG_VERSION");
1010
pub(crate) const USER_AGENT: &str = concat!("sentry.rust/", env!("CARGO_PKG_VERSION"));
1111

12-
pub(crate) static SDK_INFO: Lazy<ClientSdkInfo> = Lazy::new(|| ClientSdkInfo {
12+
pub(crate) static SDK_INFO: LazyLock<ClientSdkInfo> = LazyLock::new(|| ClientSdkInfo {
1313
name: "sentry.rust".into(),
1414
version: VERSION.into(),
1515
packages: vec![ClientSdkPackage {

sentry-core/src/hub_impl.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
use std::cell::{Cell, UnsafeCell};
2-
use std::sync::{Arc, PoisonError, RwLock};
2+
use std::sync::{Arc, LazyLock, PoisonError, RwLock};
33
use std::thread;
44

55
use crate::Scope;
66
use crate::{scope::Stack, Client, Hub};
77

8-
use once_cell::sync::Lazy;
9-
10-
static PROCESS_HUB: Lazy<(Arc<Hub>, thread::ThreadId)> = Lazy::new(|| {
8+
static PROCESS_HUB: LazyLock<(Arc<Hub>, thread::ThreadId)> = LazyLock::new(|| {
119
(
1210
Arc::new(Hub::new(None, Arc::new(Default::default()))),
1311
thread::current().id(),

sentry-core/src/test.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
//! assert_eq!(events[0].message.as_ref().unwrap(), "Hello World!");
2020
//! ```
2121
22-
use std::sync::{Arc, Mutex};
23-
24-
use once_cell::sync::Lazy;
22+
use std::sync::{Arc, LazyLock, Mutex};
2523

2624
use crate::protocol::Event;
2725
use crate::types::Dsn;
2826
use crate::{ClientOptions, Envelope, Hub, Transport};
2927

30-
static TEST_DSN: Lazy<Dsn> = Lazy::new(|| "https://[email protected]/1".parse().unwrap());
28+
static TEST_DSN: LazyLock<Dsn> =
29+
LazyLock::new(|| "https://[email protected]/1".parse().unwrap());
3130

3231
/// Collects events instead of sending them.
3332
///

sentry-debug-images/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ rust-version = "1.81"
1414

1515
[dependencies]
1616
findshlibs = "=0.10.2"
17-
once_cell = "1"
1817
sentry-core = { version = "0.37.0", path = "../sentry-core" }

sentry-debug-images/src/integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::borrow::Cow;
2+
use std::sync::LazyLock;
23

3-
use once_cell::sync::Lazy;
44
use sentry_core::protocol::{DebugMeta, Event};
55
use sentry_core::{ClientOptions, Integration};
66

@@ -56,7 +56,7 @@ impl Integration for DebugImagesIntegration {
5656
mut event: Event<'static>,
5757
_opts: &ClientOptions,
5858
) -> Option<Event<'static>> {
59-
static DEBUG_META: Lazy<DebugMeta> = Lazy::new(|| DebugMeta {
59+
static DEBUG_META: LazyLock<DebugMeta> = LazyLock::new(|| DebugMeta {
6060
images: crate::debug_images(),
6161
..Default::default()
6262
});

0 commit comments

Comments
 (0)