clippy_dev: Replace lazy_static with SyncLazy

This commit is contained in:
Philipp Hansch 2020-10-06 08:18:11 +02:00
parent 2ed5143c0e
commit 4b459596a9
No known key found for this signature in database
GPG Key ID: 188FE733728652B1
2 changed files with 23 additions and 20 deletions

View File

@ -9,7 +9,6 @@ bytecount = "0.6"
clap = "2.33"
itertools = "0.9"
regex = "1"
lazy_static = "1.0"
shell-escape = "0.1"
walkdir = "2"

View File

@ -1,11 +1,12 @@
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![feature(once_cell)]
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs;
use std::lazy::SyncLazy;
use std::path::{Path, PathBuf};
use walkdir::WalkDir;
@ -15,28 +16,31 @@ pub mod ra_setup;
pub mod stderr_length_check;
pub mod update_lints;
lazy_static! {
static ref DEC_CLIPPY_LINT_RE: Regex = Regex::new(
static DEC_CLIPPY_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
Regex::new(
r#"(?x)
declare_clippy_lint!\s*[\{(]
(?:\s+///.*)*
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
(?P<cat>[a-z_]+)\s*,\s*
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
"#
declare_clippy_lint!\s*[\{(]
(?:\s+///.*)*
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
(?P<cat>[a-z_]+)\s*,\s*
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
"#,
)
.unwrap();
static ref DEC_DEPRECATED_LINT_RE: Regex = Regex::new(
.unwrap()
});
static DEC_DEPRECATED_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
Regex::new(
r#"(?x)
declare_deprecated_lint!\s*[{(]\s*
(?:\s+///.*)*
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
"#
declare_deprecated_lint!\s*[{(]\s*
(?:\s+///.*)*
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
"#,
)
.unwrap();
static ref NL_ESCAPE_RE: Regex = Regex::new(r#"\\\n\s*"#).unwrap();
}
.unwrap()
});
static NL_ESCAPE_RE: SyncLazy<Regex> = SyncLazy::new(|| Regex::new(r#"\\\n\s*"#).unwrap());
pub static DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html";