gpui: Switch from linkme to inventory for action registration (#24087)

This switches how actions are registered in GPUI from
[dtolnay/linkme](https://github.com/dtolnay/linkme) to
[dtolany/inventory](https://github.com/dtolnay/inventory), fixing the
linking error seen in #15902, which also occurs on nightly toolchains.
I'm not sure if that issue should be closed or not given the other
problems on Chimera though.

This also fixes zed-industries/create-gpui-app#10

Release Notes:

- N/A
This commit is contained in:
someone13574 2025-02-02 12:13:46 -05:00 committed by GitHub
parent f4f51c198c
commit 4a65315f3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 49 deletions

View file

@ -13,9 +13,6 @@ pub fn register_action_macro(ident: TokenStream) -> TokenStream {
}
pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
let static_slice_name =
format_ident!("__GPUI_ACTIONS_{}", type_name.to_string().to_uppercase());
let action_builder_fn_name = format_ident!(
"__gpui_actions_builder_{}",
type_name.to_string().to_lowercase()
@ -38,10 +35,10 @@ pub(crate) fn register_action(type_name: &Ident) -> proc_macro2::TokenStream {
json_schema: <#type_name as gpui::Action>::action_json_schema,
}
}
#[doc(hidden)]
#[gpui::private::linkme::distributed_slice(gpui::__GPUI_ACTIONS)]
#[linkme(crate = gpui::private::linkme)]
static #static_slice_name: gpui::MacroActionBuilder = #action_builder_fn_name;
gpui::private::inventory::submit! {
gpui::MacroActionBuilder(#action_builder_fn_name)
}
}
}