Skip to content

Commit ff62067

Browse files
authored
Merge pull request #271 from klensy/lazy_static
replace lazy_static with std's OnceLock
2 parents ae2726d + 9ede463 commit ff62067

File tree

11 files changed

+13
-20
lines changed

11 files changed

+13
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Changed
1515

1616
* Made more code public for miri to use
17+
* Replaced `lazy_static` with std's `OnceLock`
1718

1819
### Removed
1920

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.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ doctest = false # but no doc tests
1414
[dependencies]
1515
rustc_version = "0.4"
1616
colored = "2"
17-
lazy_static = "1.4.0"
1817
serde = { version = "1.0", features = ["derive"] }
1918
serde_json = "1.0"
2019
cargo_metadata = "0.18"

src/filter.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Datastructures and operations used for normalizing test output.
22
33
use bstr::ByteSlice;
4-
use lazy_static::lazy_static;
54
use regex::bytes::{Captures, Regex};
65
use std::borrow::Cow;
76
use std::path::Path;
7+
use std::sync::OnceLock;
88

99
use crate::display;
1010

@@ -25,23 +25,24 @@ impl Match {
2525
Match::Regex(regex) => regex.replace_all(text, replacement),
2626
Match::Exact(needle) => text.replace(needle, replacement).into(),
2727
Match::PathBackslash => {
28-
lazy_static! {
29-
static ref PATH_RE: Regex = Regex::new(
30-
r"(?x)
28+
static PATH_RE: OnceLock<Regex> = OnceLock::new();
29+
PATH_RE
30+
.get_or_init(|| {
31+
Regex::new(
32+
r"(?x)
3133
(?:
3234
# Match paths to files with extensions that don't include spaces
3335
\\(?:[\pL\pN.\-_']+[/\\])*[\pL\pN.\-_']+\.\pL+
3436
|
3537
# Allow spaces in absolute paths
3638
[A-Z]:\\(?:[\pL\pN.\-_'\ ]+[/\\])+
3739
)",
38-
)
39-
.unwrap();
40-
}
41-
42-
PATH_RE.replace_all(text, |caps: &Captures<'_>| {
43-
caps[0].replace(r"\", replacement)
44-
})
40+
)
41+
.unwrap()
42+
})
43+
.replace_all(text, |caps: &Captures<'_>| {
44+
caps[0].replace(r"\", replacement)
45+
})
4546
}
4647
}
4748
}

tests/integrations/basic-bin/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.

tests/integrations/basic-fail-mode/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.

tests/integrations/basic-fail/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.

tests/integrations/basic/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.

tests/integrations/cargo-run/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.

tests/integrations/dep-fail/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)