diff --git a/crates/codegen/grammar/src/dsl.rs b/crates/codegen/grammar/src/dsl.rs index d8c08b0614..b59fc77269 100644 --- a/crates/codegen/grammar/src/dsl.rs +++ b/crates/codegen/grammar/src/dsl.rs @@ -182,11 +182,14 @@ macro_rules! slang_grammar_definition { impl $name { const SOURCE_LOCATION: $crate::SourceLocation = slang_location!(); const NAME: &str = stringify!($name); - const INSTANCE: ::std::cell::OnceCell> = ::std::cell::OnceCell::new(); fn instance() -> $crate::$trait_ref { - Self::INSTANCE - .get_or_init(::std::default::Default::default) - .clone() + use ::std::rc::Rc; + + thread_local! { + static INSTANCE: Rc<$name> = Rc::default(); + } + + INSTANCE.with(Rc::clone) } }