Skip to content

Commit 67f93c4

Browse files
committed
Replace lazy_static! macro with once_cell
lazy_static! has fallen out of favor since better, non-macro ways of accomplishing lazy init have been found. rust-lang-nursery/lazy-static.rs#111
1 parent d7085db commit 67f93c4

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

Cargo.lock

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

derive/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ proc-macro2 = "1.0"
1717
rustpython-compiler = { path = "../compiler", version = "0.1.1" }
1818
rustpython-bytecode = { path = "../bytecode", version = "0.1.1" }
1919
maplit = "1.0"
20-
lazy_static = "1"
20+
once_cell = "1.3.1"

derive/src/compile_bytecode.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ use std::fs;
2424
use std::path::{Path, PathBuf};
2525
use syn::parse::{Parse, ParseStream, Result as ParseResult};
2626
use syn::{self, parse2, Lit, LitByteStr, LitStr, Meta, Token};
27+
use once_cell::sync::Lazy;
2728

28-
lazy_static::lazy_static! {
29-
static ref CARGO_MANIFEST_DIR: PathBuf = PathBuf::from(
30-
env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not present"),
31-
);
32-
}
29+
static CARGO_MANIFEST_DIR: Lazy<PathBuf> = Lazy::new(|| {
30+
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not present"))
31+
});
3332

3433
enum CompilationSourceKind {
3534
File(PathBuf),

vm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ rustc_version_runtime = "0.1.*"
4646
statrs = "0.12.0"
4747
caseless = "0.2.1"
4848
chrono = { version = "=0.4.9", features = ["wasmbind"] }
49-
lazy_static = "^1.0.1"
49+
once_cell = "1.3.1"
5050
lexical = "4"
5151
itertools = "0.8"
5252
hex = "0.4.0"

vm/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ extern crate flamer;
2020

2121
#[macro_use]
2222
extern crate bitflags;
23-
#[macro_use]
24-
extern crate lazy_static;
2523
extern crate lexical;
2624
#[macro_use]
2725
extern crate log;

vm/src/vm.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::sync::{Mutex, MutexGuard};
1515
use arr_macro::arr;
1616
use num_bigint::BigInt;
1717
use num_traits::ToPrimitive;
18+
use once_cell::sync::Lazy;
1819
#[cfg(feature = "rustpython-compiler")]
1920
use rustpython_compiler::{compile, error::CompileError};
2021

@@ -1322,9 +1323,7 @@ impl Default for VirtualMachine {
13221323
}
13231324
}
13241325

1325-
lazy_static! {
1326-
static ref REPR_GUARDS: Mutex<HashSet<usize>> = { Mutex::new(HashSet::new()) };
1327-
}
1326+
static REPR_GUARDS: Lazy<Mutex<HashSet<usize>>> = Lazy::new(|| Mutex::new(HashSet::new()));
13281327

13291328
pub struct ReprGuard {
13301329
id: usize,

0 commit comments

Comments
 (0)