diff --git a/src/parser.rs b/src/parser.rs index 3c4859263..e2c5207a0 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -32,7 +32,6 @@ use crate::wchar::{wstr, WString, L}; use crate::wutil::{perror, wgettext, wgettext_fmt}; use crate::{function, FLOG}; use libc::c_int; -use once_cell::sync::Lazy; use printf_compat::sprintf; use std::cell::{Ref, RefCell, RefMut}; use std::ffi::{CStr, OsStr}; @@ -402,9 +401,11 @@ impl Parser { /// Get the "principal" parser, whatever that is. Can only be called by the main thread. pub fn principal_parser() -> &'static Parser { - static PRINCIPAL: Lazy> = - Lazy::new(|| MainThread::new(Parser::new(EnvStack::principal().clone(), true))); - PRINCIPAL.get() + use std::cell::OnceCell; + static PRINCIPAL: MainThread> = MainThread::new(OnceCell::new()); + &PRINCIPAL + .get() + .get_or_init(|| Parser::new(EnvStack::principal().clone(), true)) } /// Assert that this parser is allowed to execute on the current thread.