diff --git a/CHANGELOG.md b/CHANGELOG.md index fc658ab5..ff5a52ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Made more code public for miri to use +* Replaced `lazy_static` with std's `OnceLock` ### Removed diff --git a/Cargo.lock b/Cargo.lock index 0bedd2a5..118e12e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -605,7 +605,6 @@ dependencies = [ "crossbeam-channel", "ctrlc", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/Cargo.toml b/Cargo.toml index 4783824b..2a49de93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ doctest = false # but no doc tests [dependencies] rustc_version = "0.4" colored = "2" -lazy_static = "1.4.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" cargo_metadata = "0.18" diff --git a/src/filter.rs b/src/filter.rs index 0221cf20..f9e8c68f 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -1,10 +1,10 @@ //! Datastructures and operations used for normalizing test output. use bstr::ByteSlice; -use lazy_static::lazy_static; use regex::bytes::{Captures, Regex}; use std::borrow::Cow; use std::path::Path; +use std::sync::OnceLock; use crate::display; @@ -25,9 +25,11 @@ impl Match { Match::Regex(regex) => regex.replace_all(text, replacement), Match::Exact(needle) => text.replace(needle, replacement).into(), Match::PathBackslash => { - lazy_static! { - static ref PATH_RE: Regex = Regex::new( - r"(?x) + static PATH_RE: OnceLock = OnceLock::new(); + PATH_RE + .get_or_init(|| { + Regex::new( + r"(?x) (?: # Match paths to files with extensions that don't include spaces \\(?:[\pL\pN.\-_']+[/\\])*[\pL\pN.\-_']+\.\pL+ @@ -35,13 +37,12 @@ impl Match { # Allow spaces in absolute paths [A-Z]:\\(?:[\pL\pN.\-_'\ ]+[/\\])+ )", - ) - .unwrap(); - } - - PATH_RE.replace_all(text, |caps: &Captures<'_>| { - caps[0].replace(r"\", replacement) - }) + ) + .unwrap() + }) + .replace_all(text, |caps: &Captures<'_>| { + caps[0].replace(r"\", replacement) + }) } } } diff --git a/tests/integrations/basic-bin/Cargo.lock b/tests/integrations/basic-bin/Cargo.lock index c9179913..3d7d75c7 100644 --- a/tests/integrations/basic-bin/Cargo.lock +++ b/tests/integrations/basic-bin/Cargo.lock @@ -728,7 +728,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/tests/integrations/basic-fail-mode/Cargo.lock b/tests/integrations/basic-fail-mode/Cargo.lock index 315181a4..806d3727 100644 --- a/tests/integrations/basic-fail-mode/Cargo.lock +++ b/tests/integrations/basic-fail-mode/Cargo.lock @@ -728,7 +728,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/tests/integrations/basic-fail/Cargo.lock b/tests/integrations/basic-fail/Cargo.lock index 56a949f6..1aacb5fe 100644 --- a/tests/integrations/basic-fail/Cargo.lock +++ b/tests/integrations/basic-fail/Cargo.lock @@ -728,7 +728,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/tests/integrations/basic/Cargo.lock b/tests/integrations/basic/Cargo.lock index c222f2c6..1ea5665c 100644 --- a/tests/integrations/basic/Cargo.lock +++ b/tests/integrations/basic/Cargo.lock @@ -651,7 +651,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/tests/integrations/cargo-run/Cargo.lock b/tests/integrations/cargo-run/Cargo.lock index c9179913..3d7d75c7 100644 --- a/tests/integrations/cargo-run/Cargo.lock +++ b/tests/integrations/cargo-run/Cargo.lock @@ -728,7 +728,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/tests/integrations/dep-fail/Cargo.lock b/tests/integrations/dep-fail/Cargo.lock index 6f14efcd..0e7dc0ff 100644 --- a/tests/integrations/dep-fail/Cargo.lock +++ b/tests/integrations/dep-fail/Cargo.lock @@ -577,7 +577,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex", diff --git a/tests/integrations/ui_test_dep_bug/Cargo.lock b/tests/integrations/ui_test_dep_bug/Cargo.lock index c4be0c4d..2c989214 100644 --- a/tests/integrations/ui_test_dep_bug/Cargo.lock +++ b/tests/integrations/ui_test_dep_bug/Cargo.lock @@ -582,7 +582,6 @@ dependencies = [ "comma", "crossbeam-channel", "indicatif", - "lazy_static", "levenshtein", "prettydiff", "regex",