component: Replace linkme with inventory (#30705)

This PR replaces the use of `linkme` with `inventory` for the component
preview registration.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-05-14 23:29:11 +02:00 committed by GitHub
parent 87cb498a41
commit 607bfd3b1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 28 additions and 27 deletions

View file

@ -5,7 +5,7 @@ use syn::{DeriveInput, parse_macro_input};
pub fn derive_register_component(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let name = input.ident;
let reg_fn_name = syn::Ident::new(
let register_fn_name = syn::Ident::new(
&format!("__component_registry_internal_register_{}", name),
name.span(),
);
@ -16,10 +16,13 @@ pub fn derive_register_component(input: TokenStream) -> TokenStream {
};
#[allow(non_snake_case)]
#[linkme::distributed_slice(component::__ALL_COMPONENTS)]
fn #reg_fn_name() {
fn #register_fn_name() {
component::register_component::<#name>();
}
component::__private::inventory::submit! {
component::ComponentFn::new(#register_fn_name)
}
};
expanded.into()
}