sqlx-macros: Replace lazy_static by once_cell

This commit is contained in:
Jonas Platte 2021-01-11 21:08:40 +01:00 committed by Ryan Leckey
parent 890f289f2f
commit e8c367db6e
No known key found for this signature in database
GPG Key ID: F8AA68C235AB08C9
3 changed files with 11 additions and 14 deletions

2
Cargo.lock generated
View File

@ -2666,7 +2666,7 @@ dependencies = [
"futures",
"heck",
"hex",
"lazy_static",
"once_cell",
"proc-macro2",
"quote",
"serde",

View File

@ -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" }

View File

@ -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<PathBuf> = 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<TokenStream> {
let manifest_dir =