diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-12-19 02:44:42 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-18 16:14:42 -0500 |
commit | 6de53b631fcdb96d72639b6d2db3592d5fa8498d (patch) | |
tree | 9a93d868f5f434a4898f212cb6bd53e65ca49ce0 /cli/diagnostics.rs | |
parent | 3db18bf9e6466c74efd9052df4d372ea0b581154 (diff) |
refactor: use `once_cell` instead of `lazy_static` (#13135)
Diffstat (limited to 'cli/diagnostics.rs')
-rw-r--r-- | cli/diagnostics.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 0671dc500..03255950b 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -7,6 +7,7 @@ use deno_core::serde::Deserializer; use deno_core::serde::Serialize; use deno_core::serde::Serializer; use deno_graph::ModuleGraphError; +use once_cell::sync::Lazy; use regex::Regex; use std::error::Error; use std::fmt; @@ -65,13 +66,13 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "utimeSync", ]; -lazy_static::lazy_static! { - static ref MSG_MISSING_PROPERTY_DENO: Regex = - Regex::new(r#"Property '([^']+)' does not exist on type 'typeof Deno'"#) - .unwrap(); - static ref MSG_SUGGESTION: Regex = - Regex::new(r#" Did you mean '([^']+)'\?"#).unwrap(); -} +static MSG_MISSING_PROPERTY_DENO: Lazy<Regex> = Lazy::new(|| { + Regex::new(r#"Property '([^']+)' does not exist on type 'typeof Deno'"#) + .unwrap() +}); + +static MSG_SUGGESTION: Lazy<Regex> = + Lazy::new(|| Regex::new(r#" Did you mean '([^']+)'\?"#).unwrap()); /// Potentially convert a "raw" diagnostic message from TSC to something that /// provides a more sensible error message given a Deno runtime context. |