Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP: Fix compilation of `gpui2`
Marshall Bowers8b972f6d8ebb
diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rsindex e20d26b3d71..c6707049a68 100644--- a/crates/gpui2/src/element.rs+++ b/crates/gpui2/src/element.rs@@ -41,7 +41,7 @@ pub trait Element<V: 'static>: IntoAnyElement<V> {#[derive(Deref, DerefMut, Default, Clone, Debug, Eq, PartialEq, Hash)]pub struct GlobalElementId(SmallVec<[ElementId; 32]>);-pub trait ParentElement<V>: Element<V> {+pub trait ParentElement<V: 'static>: Element<V> {fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]>;fn child(mut self, child: impl IntoAnyElement<V>) -> Self@@ -68,7 +68,7 @@ trait ElementObject<V> {fn paint(&mut self, view_state: &mut V, cx: &mut ViewContext<V>);}-struct RenderedElement<V, E: Element<V>> {+struct RenderedElement<V: 'static, E: Element<V>> {element: E,phase: ElementRenderPhase<E::ElementState>,}@@ -181,6 +181,7 @@ pub struct AnyElement<V>(Box<dyn ElementObject<V> + Send + Sync>);impl<V> AnyElement<V> {pub fn new<E>(element: E) -> Selfwhere+ V: 'static,E: 'static + Send + Sync,E: Element<V>,E::ElementState: Any + Send + Sync,diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rsindex 9e1414e91af..fbef75ab1c0 100644--- a/crates/gpui2/src/elements/div.rs+++ b/crates/gpui2/src/elements/div.rs@@ -160,7 +160,7 @@ impl<V: 'static> Div<V, StatelessInteraction<V>, FocusDisabled> {}}-impl<V, I> Focusable for Div<V, I, FocusEnabled<V>>+impl<V, I> Focusable<V> for Div<V, I, FocusEnabled<V>>whereV: 'static,I: ElementInteraction<V>,diff --git a/crates/gpui2/src/elements/img.rs b/crates/gpui2/src/elements/img.rsindex e52b1ca3326..d64536a7ed7 100644--- a/crates/gpui2/src/elements/img.rs+++ b/crates/gpui2/src/elements/img.rs@@ -161,7 +161,7 @@ where}}-impl<V, I> Focusable for Img<V, I, FocusEnabled<V>>+impl<V, I> Focusable<V> for Img<V, I, FocusEnabled<V>>whereV: 'static,I: ElementInteraction<V>,diff --git a/crates/gpui2/src/elements/svg.rs b/crates/gpui2/src/elements/svg.rsindex ae388efb3f0..409094d740e 100644--- a/crates/gpui2/src/elements/svg.rs+++ b/crates/gpui2/src/elements/svg.rs@@ -135,7 +135,7 @@ where}}-impl<V: 'static, I> Focusable for Svg<V, I, FocusEnabled<V>>+impl<V: 'static, I> Focusable<V> for Svg<V, I, FocusEnabled<V>>whereI: ElementInteraction<V>,{diff --git a/crates/gpui2/src/elements/text.rs b/crates/gpui2/src/elements/text.rsindex 7b0052826cd..e054da87a68 100644--- a/crates/gpui2/src/elements/text.rs+++ b/crates/gpui2/src/elements/text.rs@@ -53,8 +53,7 @@ impl<V: 'static> IntoAnyElement<V> for Text<V> {}}-impl<V: 'static> Element for Text<V> {- type ViewState = V;+impl<V: 'static> Element<V> for Text<V> {type ElementState = Arc<Mutex<Option<TextElementState>>>;fn id(&self) -> Option<crate::ElementId> {diff --git a/crates/gpui2/src/focusable.rs b/crates/gpui2/src/focusable.rsindex 0d2e09ec49f..c283998ca26 100644--- a/crates/gpui2/src/focusable.rs+++ b/crates/gpui2/src/focusable.rs@@ -11,7 +11,7 @@ pub type FocusListeners<V> = SmallVec<[FocusListener<V>; 2]>;pub type FocusListener<V> =Arc<dyn Fn(&mut V, &FocusHandle, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static>;-pub trait Focusable<V>: Element<V> {+pub trait Focusable<V: 'static>: Element<V> {fn focus_listeners(&mut self) -> &mut FocusListeners<V>;fn set_focus_style(&mut self, style: StyleRefinement);fn set_focus_in_style(&mut self, style: StyleRefinement);@@ -43,10 +43,7 @@ pub trait Focusable<V>: Element<V> {fn on_focus(mut self,- listener: impl Fn(&mut Self::ViewState, &FocusEvent, &mut ViewContext<Self::ViewState>)- + Send- + Sync- + 'static,+ listener: impl Fn(&mut V, &FocusEvent, &mut ViewContext<V>) + Send + Sync + 'static,) -> SelfwhereSelf: Sized,diff --git a/crates/gpui2/src/interactive.rs b/crates/gpui2/src/interactive.rsindex 7cc014e7231..f00e24b4724 100644--- a/crates/gpui2/src/interactive.rs+++ b/crates/gpui2/src/interactive.rs@@ -19,7 +19,7 @@ use std::{const DRAG_THRESHOLD: f64 = 2.;-pub trait StatelessInteractive<V>: Element<V> {+pub trait StatelessInteractive<V: 'static>: Element<V> {fn stateless_interaction(&mut self) -> &mut StatelessInteraction<V>;fn hover(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self@@ -279,7 +279,7 @@ pub trait StatelessInteractive<V>: Element<V> {}}-pub trait StatefulInteractive<V>: StatelessInteractive<V> {+pub trait StatefulInteractive<V: 'static>: StatelessInteractive<V> {fn stateful_interaction(&mut self) -> &mut StatefulInteraction<V>;fn active(mut self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self@@ -870,6 +870,7 @@ pub struct ClickEvent {pub struct Drag<S, R, V, E>whereR: Fn(&mut V, &mut ViewContext<V>) -> E,+ V: 'static,E: Element<V>,{pub state: S,@@ -880,6 +881,7 @@ whereimpl<S, R, V, E> Drag<S, R, V, E>whereR: Fn(&mut V, &mut ViewContext<V>) -> E,+ V: 'static,E: Element<V>,{pub fn new(state: S, render_drag_handle: R) -> Self {diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rsindex 13f29e641d0..b1b287c4ab2 100644--- a/crates/gpui2/src/view.rs+++ b/crates/gpui2/src/view.rs@@ -194,8 +194,7 @@ impl<ParentV: 'static> IntoAnyElement<ParentV> for AnyView {}}-impl Element for AnyView {- type ViewState = ();+impl Element<()> for AnyView {type ElementState = AnyBox;fn id(&self) -> Option<crate::ElementId> {@@ -204,18 +203,18 @@ impl Element for AnyView {fn initialize(&mut self,- _: &mut Self::ViewState,+ _: &mut (),_: Option<Self::ElementState>,- cx: &mut ViewContext<Self::ViewState>,+ cx: &mut ViewContext<()>,) -> Self::ElementState {self.view.lock().initialize(cx)}fn layout(&mut self,- _: &mut Self::ViewState,+ _: &mut (),element: &mut Self::ElementState,- cx: &mut ViewContext<Self::ViewState>,+ cx: &mut ViewContext<()>,) -> LayoutId {self.view.lock().layout(element, cx)}@@ -225,7 +224,7 @@ impl Element for AnyView {bounds: Bounds<Pixels>,_: &mut (),element: &mut AnyBox,- cx: &mut ViewContext<Self::ViewState>,+ cx: &mut ViewContext<()>,) {self.view.lock().paint(bounds, element, cx)}