rust-lang-nursery / lazy-static.rs

A small macro for defining lazy evaluated static variables in Rust.
Apache License 2.0
1.9k stars 111 forks source link

lazy_static without unsafe? #125

Closed matthiasbeyer closed 5 years ago

matthiasbeyer commented 5 years ago

Hi,

I'm trying to use #![forbid(unsafe_code)] but I also want to use lazy_static!() - is there a way?

My failling travis job is here

KodrAus commented 5 years ago

Hmm, the problem here is that the macro-generated deref impl for lazy statics uses an unsafe block because it accesses a 'static mut. In #124 we're removing the need for 'static mut, so we should be able to work properly with crates that #![forbid(unsafe_code)].

KodrAus commented 5 years ago

Alrighty! It should be possible now to use lazy_static 1.2.0 alongside #![forbid(unsafe_code)].