Skip to content

Commit 675a022

Browse files
committed
Eliminate uses of once_cell::sync::Lazy
1 parent 3ebb0e8 commit 675a022

File tree

30 files changed

+31
-61
lines changed

30 files changed

+31
-61
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.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ pedantic = { level = "warn", priority = -1 }
6666
option-if-let-else = "allow"
6767
missing-errors-doc = "allow"
6868
missing-panics-doc = "allow"
69-
non-std-lazy-statics = "allow"
7069
significant-drop-tightening = "allow"
7170
struct-field-names = "allow"
7271

cargo-dylint/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ cargo_metadata = { workspace = true }
2727
ctor = { workspace = true }
2828
glob = { workspace = true }
2929
log = { workspace = true }
30-
once_cell = { workspace = true }
3130
predicates = { workspace = true }
3231
regex = { workspace = true }
3332
semver = { workspace = true }

cargo-dylint/tests/ci.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use anyhow::Result;
44
use assert_cmd::Command;
55
use cargo_metadata::{Dependency, Metadata, MetadataCommand};
66
use dylint_internal::{cargo::current_metadata, env, examples, home};
7-
use once_cell::sync::Lazy;
87
use regex::Regex;
98
use semver::{Op, Version};
109
use similar_asserts::SimpleDiff;
@@ -15,10 +14,10 @@ use std::{
1514
fs::{read_dir, read_to_string, write},
1615
io::{Write as _, stderr},
1716
path::{Component, Path},
18-
sync::Mutex,
17+
sync::{LazyLock, Mutex},
1918
};
2019

21-
static METADATA: Lazy<Metadata> = Lazy::new(|| current_metadata().unwrap());
20+
static METADATA: LazyLock<Metadata> = LazyLock::new(|| current_metadata().unwrap());
2221

2322
#[ctor::ctor]
2423
fn initialize() {

driver/Cargo.lock

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

dylint/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use cargo_metadata::MetadataCommand;
88
use dylint_internal::{
99
CommandExt, driver as dylint_driver, env, parse_path_filename, rustup::SanitizeEnvironment,
1010
};
11-
use once_cell::sync::Lazy;
1211
use std::{
1312
collections::BTreeMap,
1413
env::{consts, current_dir},
1514
ffi::OsStr,
1615
fs::{OpenOptions, metadata},
1716
path::{MAIN_SEPARATOR, Path, PathBuf},
17+
sync::LazyLock,
1818
};
1919

2020
type Object = serde_json::Map<String, serde_json::Value>;
@@ -43,7 +43,7 @@ pub mod opts;
4343
#[cfg(feature = "package_options")]
4444
mod package_options;
4545

46-
static REQUIRED_FORM: Lazy<String> = Lazy::new(|| {
46+
static REQUIRED_FORM: LazyLock<String> = LazyLock::new(|| {
4747
format!(
4848
r#""{}" LIBRARY_NAME "@" TOOLCHAIN "{}""#,
4949
consts::DLL_PREFIX,
@@ -527,7 +527,7 @@ mod test {
527527
// The easiest solution is to just run the tests sequentially.
528528
static MUTEX: Mutex<()> = Mutex::new(());
529529

530-
static OPTS: Lazy<opts::Dylint> = Lazy::new(|| opts::Dylint {
530+
static OPTS: LazyLock<opts::Dylint> = LazyLock::new(|| opts::Dylint {
531531
operation: opts::Operation::Check(opts::Check {
532532
lib_sel: opts::LibrarySelection {
533533
manifest_path: Some(String::from("../fixtures/name_toolchain_map/Cargo.toml")),

dylint/src/opts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! [struct update syntax]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax
1818
1919
#[cfg(feature = "package_options")]
20-
use once_cell::sync::Lazy;
20+
use std::sync::LazyLock;
2121

2222
#[allow(clippy::struct_excessive_bools)]
2323
#[derive(Clone, Debug, Default)]
@@ -139,7 +139,7 @@ impl LibrarySelection {
139139
}
140140

141141
#[cfg(feature = "package_options")]
142-
static LIBRARY_SELECTION: Lazy<LibrarySelection> = Lazy::new(LibrarySelection::default);
142+
static LIBRARY_SELECTION: LazyLock<LibrarySelection> = LazyLock::new(LibrarySelection::default);
143143

144144
impl Operation {
145145
const fn has_library_selection(&self) -> bool {

dylint/src/package_options/auto_correct/tokenization.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use anyhow::Result;
2-
use once_cell::sync::Lazy;
2+
use std::sync::LazyLock;
33
use syntect::parsing::{ParseState, ScopeStackOp, SyntaxReference, SyntaxSet};
44

5-
static SYNTAX_SET: Lazy<SyntaxSet> = Lazy::new(SyntaxSet::load_defaults_nonewlines);
5+
static SYNTAX_SET: LazyLock<SyntaxSet> = LazyLock::new(SyntaxSet::load_defaults_nonewlines);
66

7-
static SYNTAX: Lazy<&SyntaxReference> =
8-
Lazy::new(|| SYNTAX_SET.find_syntax_by_extension("rs").unwrap());
7+
static SYNTAX: LazyLock<&SyntaxReference> =
8+
LazyLock::new(|| SYNTAX_SET.find_syntax_by_extension("rs").unwrap());
99

1010
pub fn tokenize_lines<T: AsRef<str>>(lines: &[T]) -> Result<Vec<&str>> {
1111
let tokens = lines

dylint/src/package_options/revs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ impl Iterator for RevIter<'_> {
125125
#[cfg(test)]
126126
mod test {
127127
use super::*;
128-
use once_cell::sync::Lazy;
128+
use std::sync::LazyLock;
129129

130-
static EXAMPLES: Lazy<[Rev; 6]> = Lazy::new(|| {
130+
static EXAMPLES: LazyLock<[Rev; 6]> = LazyLock::new(|| {
131131
[
132132
Rev {
133133
version: "0.1.65".to_owned(),

examples/experimental/derive_opportunity/Cargo.lock

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

0 commit comments

Comments
 (0)