diff options
| author | Philipp Hansch <dev@phansch.net> | 2020-10-06 08:18:11 +0200 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2020-10-06 08:18:11 +0200 |
| commit | 4b459596a96a7d6f4797d4f1444311d88df60009 (patch) | |
| tree | 7cfb38ea561c67eadd61948b4185446befd00025 | |
| parent | 2ed5143c0ec88fe4cf0e3528bb4aca11059c2c83 (diff) | |
| download | rust-4b459596a96a7d6f4797d4f1444311d88df60009.tar.gz rust-4b459596a96a7d6f4797d4f1444311d88df60009.zip | |
clippy_dev: Replace lazy_static with SyncLazy
| -rw-r--r-- | clippy_dev/Cargo.toml | 1 | ||||
| -rw-r--r-- | clippy_dev/src/lib.rs | 42 |
2 files changed, 23 insertions, 20 deletions
diff --git a/clippy_dev/Cargo.toml b/clippy_dev/Cargo.toml index c861efc8afb..d745000eac7 100644 --- a/clippy_dev/Cargo.toml +++ b/clippy_dev/Cargo.toml @@ -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" diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 5baa31d5cde..567831354f5 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -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"; |
