@@ -674,7 +674,6 @@ dependencies = [
"language",
"language_model",
"language_models",
- "linkme",
"log",
"markdown",
"open",
@@ -3177,7 +3176,7 @@ version = "0.1.0"
dependencies = [
"collections",
"gpui",
- "linkme",
+ "inventory",
"parking_lot",
"strum 0.27.1",
"theme",
@@ -4327,7 +4326,6 @@ dependencies = [
"gpui",
"indoc",
"language",
- "linkme",
"log",
"lsp",
"markdown",
@@ -6026,7 +6024,6 @@ dependencies = [
"language",
"language_model",
"linkify",
- "linkme",
"log",
"markdown",
"menu",
@@ -9105,7 +9102,6 @@ dependencies = [
"component",
"db",
"gpui",
- "linkme",
"rpc",
"settings",
"sum_tree",
@@ -15707,7 +15703,6 @@ dependencies = [
"component",
"editor",
"gpui",
- "linkme",
"settings",
"theme",
"ui",
@@ -16940,7 +16935,6 @@ dependencies = [
"gpui",
"install_cli",
"language",
- "linkme",
"picker",
"project",
"schemars",
@@ -795,7 +795,6 @@ ignored = [
"prost_build",
"serde",
"component",
- "linkme",
"documented",
"workspace-hack",
]
@@ -9,13 +9,12 @@
mod component_layout;
-pub use component_layout::*;
-
use std::sync::LazyLock;
+pub use component_layout::*;
+
use collections::HashMap;
use gpui::{AnyElement, App, SharedString, Window};
-use linkme::distributed_slice;
use parking_lot::RwLock;
use strum::{Display, EnumString};
@@ -24,12 +23,27 @@ pub fn components() -> ComponentRegistry {
}
pub fn init() {
- let component_fns: Vec<_> = __ALL_COMPONENTS.iter().cloned().collect();
- for f in component_fns {
- f();
+ for f in inventory::iter::<ComponentFn>() {
+ (f.0)();
+ }
+}
+
+pub struct ComponentFn(fn());
+
+impl ComponentFn {
+ pub const fn new(f: fn()) -> Self {
+ Self(f)
}
}
+inventory::collect!(ComponentFn);
+
+/// Private internals for macros.
+#[doc(hidden)]
+pub mod __private {
+ pub use inventory;
+}
+
pub fn register_component<T: Component>() {
let id = T::id();
let metadata = ComponentMetadata {
@@ -46,9 +60,6 @@ pub fn register_component<T: Component>() {
data.components.insert(id, metadata);
}
-#[distributed_slice]
-pub static __ALL_COMPONENTS: [fn()] = [..];
-
pub static COMPONENT_DATA: LazyLock<RwLock<ComponentRegistry>> =
LazyLock::new(|| RwLock::new(ComponentRegistry::default()));
@@ -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()
}