Skip to content

Commit 4b45959

Browse files
committed
clippy_dev: Replace lazy_static with SyncLazy
1 parent 2ed5143 commit 4b45959

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

clippy_dev/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ bytecount = "0.6"
99
clap = "2.33"
1010
itertools = "0.9"
1111
regex = "1"
12-
lazy_static = "1.0"
1312
shell-escape = "0.1"
1413
walkdir = "2"
1514

clippy_dev/src/lib.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
2+
#![feature(once_cell)]
23

34
use itertools::Itertools;
4-
use lazy_static::lazy_static;
55
use regex::Regex;
66
use std::collections::HashMap;
77
use std::ffi::OsStr;
88
use std::fs;
9+
use std::lazy::SyncLazy;
910
use std::path::{Path, PathBuf};
1011
use walkdir::WalkDir;
1112

@@ -15,28 +16,31 @@ pub mod ra_setup;
1516
pub mod stderr_length_check;
1617
pub mod update_lints;
1718

18-
lazy_static! {
19-
static ref DEC_CLIPPY_LINT_RE: Regex = Regex::new(
19+
static DEC_CLIPPY_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
20+
Regex::new(
2021
r#"(?x)
21-
declare_clippy_lint!\s*[\{(]
22-
(?:\s+///.*)*
23-
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
24-
(?P<cat>[a-z_]+)\s*,\s*
25-
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
26-
"#
22+
declare_clippy_lint!\s*[\{(]
23+
(?:\s+///.*)*
24+
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
25+
(?P<cat>[a-z_]+)\s*,\s*
26+
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
27+
"#,
2728
)
28-
.unwrap();
29-
static ref DEC_DEPRECATED_LINT_RE: Regex = Regex::new(
29+
.unwrap()
30+
});
31+
32+
static DEC_DEPRECATED_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
33+
Regex::new(
3034
r#"(?x)
31-
declare_deprecated_lint!\s*[{(]\s*
32-
(?:\s+///.*)*
33-
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
34-
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
35-
"#
35+
declare_deprecated_lint!\s*[{(]\s*
36+
(?:\s+///.*)*
37+
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
38+
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
39+
"#,
3640
)
37-
.unwrap();
38-
static ref NL_ESCAPE_RE: Regex = Regex::new(r#"\\\n\s*"#).unwrap();
39-
}
41+
.unwrap()
42+
});
43+
static NL_ESCAPE_RE: SyncLazy<Regex> = SyncLazy::new(|| Regex::new(r#"\\\n\s*"#).unwrap());
4044

4145
pub static DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html";
4246

0 commit comments

Comments
 (0)