diff --git a/Cargo.lock b/Cargo.lock index 90564d14..a617219c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2666,7 +2666,7 @@ dependencies = [ "futures", "heck", "hex", - "lazy_static", + "once_cell", "proc-macro2", "quote", "serde", diff --git a/sqlx-macros/Cargo.toml b/sqlx-macros/Cargo.toml index 42077966..9437065f 100644 --- a/sqlx-macros/Cargo.toml +++ b/sqlx-macros/Cargo.toml @@ -59,7 +59,7 @@ futures = { version = "0.3.4", default-features = false, features = [ "executor" hex = { version = "0.4.2", optional = true } heck = "0.3.1" either = "1.5.3" -lazy_static = "1.4.0" +once_cell = "1.5.2" proc-macro2 = { version = "1.0.9", default-features = false } sqlx-core = { version = "0.4.2", default-features = false, path = "../sqlx-core" } sqlx-rt = { version = "0.2.0", default-features = false, path = "../sqlx-rt" } diff --git a/sqlx-macros/src/query/mod.rs b/sqlx-macros/src/query/mod.rs index 4f3b5c4e..11514fcf 100644 --- a/sqlx-macros/src/query/mod.rs +++ b/sqlx-macros/src/query/mod.rs @@ -17,7 +17,7 @@ use crate::database::DatabaseExt; use crate::query::data::QueryData; use crate::query::input::RecordType; use either::Either; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; mod args; mod data; @@ -26,19 +26,16 @@ mod output; // If we are in a workspace, lookup `workspace_root` since `CARGO_MANIFEST_DIR` won't // reflect the workspace dir: https://github.com/rust-lang/cargo/issues/3946 -lazy_static! { - static ref CRATE_ROOT: PathBuf = { - let manifest_dir = - env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` must be set"); +static CRATE_ROOT: Lazy = Lazy::new(|| { + let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` must be set"); - let metadata = cargo_metadata::MetadataCommand::new() - .current_dir(manifest_dir) - .exec() - .expect("Could not fetch metadata"); + let metadata = cargo_metadata::MetadataCommand::new() + .current_dir(manifest_dir) + .exec() + .expect("Could not fetch metadata"); - metadata.workspace_root - }; -} + metadata.workspace_root +}); pub fn expand_input(input: QueryMacroInput) -> crate::Result { let manifest_dir =