diff --git a/crates/feature_flags2/src/feature_flags2.rs b/crates/feature_flags2/src/feature_flags2.rs index 7b1c0dd4d7..446a2867e5 100644 --- a/crates/feature_flags2/src/feature_flags2.rs +++ b/crates/feature_flags2/src/feature_flags2.rs @@ -28,7 +28,7 @@ pub trait FeatureFlagViewExt { F: Fn(bool, &mut V, &mut ViewContext) + Send + Sync + 'static; } -impl FeatureFlagViewExt for ViewContext<'_, '_, V> +impl FeatureFlagViewExt for ViewContext<'_, V> where V: 'static + Send + Sync, { diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rs index 1e09136bdb..1b9bc023fc 100644 --- a/crates/gpui2/src/app.rs +++ b/crates/gpui2/src/app.rs @@ -308,7 +308,7 @@ impl AppContext { pub fn update_window_root( &mut self, handle: &WindowHandle, - update: impl FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> R, + update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R, ) -> Result where V: 'static + Send, @@ -882,7 +882,7 @@ impl MainThread { pub fn update_window_root( &mut self, handle: &WindowHandle, - update: impl FnOnce(&mut V, &mut MainThread>) -> R, + update: impl FnOnce(&mut V, &mut MainThread>) -> R, ) -> Result where V: 'static + Send, diff --git a/crates/gpui2/src/app/async_context.rs b/crates/gpui2/src/app/async_context.rs index 3a9a68a033..ae0a20d8fa 100644 --- a/crates/gpui2/src/app/async_context.rs +++ b/crates/gpui2/src/app/async_context.rs @@ -81,7 +81,7 @@ impl AsyncAppContext { pub fn update_window_root( &mut self, handle: &WindowHandle, - update: impl FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> R, + update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R, ) -> Result where V: 'static + Send, @@ -259,11 +259,11 @@ impl Context for AsyncWindowContext { } impl VisualContext for AsyncWindowContext { - type ViewContext<'a, 'w, V: 'static> = ViewContext<'a, 'w, V>; + type ViewContext<'a, V: 'static> = ViewContext<'a, V>; fn build_view( &mut self, - build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V, + build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, ) -> Self::Result> where V: 'static + Send, @@ -275,7 +275,7 @@ impl VisualContext for AsyncWindowContext { fn update_view( &mut self, view: &View, - update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, '_, V>) -> R, + update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, V>) -> R, ) -> Self::Result { self.app .update_window(self.window, |cx| cx.update_view(view, update)) diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs index a715ed30ee..d11c007186 100644 --- a/crates/gpui2/src/element.rs +++ b/crates/gpui2/src/element.rs @@ -221,7 +221,7 @@ impl Element for Option where V: 'static, E: 'static + Component + Send, - F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static, + F: FnOnce(&mut V, &mut ViewContext<'_, V>) -> E + Send + 'static, { type ElementState = AnyElement; @@ -265,7 +265,7 @@ impl Component for Option where V: 'static, E: 'static + Component + Send, - F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static, + F: FnOnce(&mut V, &mut ViewContext<'_, V>) -> E + Send + 'static, { fn render(self) -> AnyElement { AnyElement::new(self) @@ -276,7 +276,7 @@ impl Component for F where V: 'static, E: 'static + Component + Send, - F: FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static, + F: FnOnce(&mut V, &mut ViewContext<'_, V>) -> E + Send + 'static, { fn render(self) -> AnyElement { AnyElement::new(Some(self)) diff --git a/crates/gpui2/src/gpui2.rs b/crates/gpui2/src/gpui2.rs index 74d87449b9..704ff6c5b1 100644 --- a/crates/gpui2/src/gpui2.rs +++ b/crates/gpui2/src/gpui2.rs @@ -95,11 +95,11 @@ pub trait Context { } pub trait VisualContext: Context { - type ViewContext<'a, 'w, V: 'static>; + type ViewContext<'a, V: 'static>; fn build_view( &mut self, - build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V, + build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, ) -> Self::Result> where V: 'static + Send; @@ -107,7 +107,7 @@ pub trait VisualContext: Context { fn update_view( &mut self, view: &View, - update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, '_, V>) -> R, + update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, V>) -> R, ) -> Self::Result; } @@ -184,11 +184,11 @@ impl Context for MainThread { } impl VisualContext for MainThread { - type ViewContext<'a, 'w, V: 'static> = MainThread>; + type ViewContext<'a, V: 'static> = MainThread>; fn build_view( &mut self, - build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V, + build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, ) -> Self::Result> where V: 'static + Send, @@ -196,8 +196,8 @@ impl VisualContext for MainThread { self.0.build_view(|cx| { let cx = unsafe { mem::transmute::< - &mut C::ViewContext<'_, '_, V>, - &mut MainThread>, + &mut C::ViewContext<'_, V>, + &mut MainThread>, >(cx) }; build_view_state(cx) @@ -207,13 +207,13 @@ impl VisualContext for MainThread { fn update_view( &mut self, view: &View, - update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, '_, V>) -> R, + update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, V>) -> R, ) -> Self::Result { self.0.update_view(view, |view_state, cx| { let cx = unsafe { mem::transmute::< - &mut C::ViewContext<'_, '_, V>, - &mut MainThread>, + &mut C::ViewContext<'_, V>, + &mut MainThread>, >(cx) }; update(view_state, cx) diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rs index 366172889a..89757434a9 100644 --- a/crates/gpui2/src/view.rs +++ b/crates/gpui2/src/view.rs @@ -53,7 +53,7 @@ impl View { pub fn update( &self, cx: &mut C, - f: impl FnOnce(&mut V, &mut C::ViewContext<'_, '_, V>) -> R, + f: impl FnOnce(&mut V, &mut C::ViewContext<'_, V>) -> R, ) -> C::Result where C: VisualContext, @@ -152,7 +152,7 @@ impl WeakView { pub fn update( &self, cx: &mut C, - f: impl FnOnce(&mut V, &mut C::ViewContext<'_, '_, V>) -> R, + f: impl FnOnce(&mut V, &mut C::ViewContext<'_, V>) -> R, ) -> Result where C: VisualContext, diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs index bd62ff44f7..c90fce8003 100644 --- a/crates/gpui2/src/window.rs +++ b/crates/gpui2/src/window.rs @@ -1305,11 +1305,11 @@ impl Context for WindowContext<'_, '_> { } impl VisualContext for WindowContext<'_, '_> { - type ViewContext<'a, 'w, V: 'static> = ViewContext<'a, 'w, V>; + type ViewContext<'a, V: 'static> = ViewContext<'a, V>; fn build_view( &mut self, - build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V, + build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, ) -> Self::Result> where V: 'static + Send, @@ -1328,7 +1328,7 @@ impl VisualContext for WindowContext<'_, '_> { fn update_view( &mut self, view: &View, - update: impl FnOnce(&mut T, &mut Self::ViewContext<'_, '_, T>) -> R, + update: impl FnOnce(&mut T, &mut Self::ViewContext<'_, T>) -> R, ) -> Self::Result { let mut lease = self.app.entities.lease(&view.model); let mut cx = ViewContext::new(&mut *self.app, &mut *self.window, &view); @@ -1540,37 +1540,37 @@ impl BorrowMut for WindowContext<'_, '_> { impl BorrowWindow for T where T: BorrowMut + BorrowMut {} -pub struct ViewContext<'a, 'w, V> { - window_cx: WindowContext<'a, 'w>, - view: &'w View, +pub struct ViewContext<'a, V> { + window_cx: WindowContext<'a, 'a>, + view: &'a View, } -impl Borrow for ViewContext<'_, '_, V> { +impl Borrow for ViewContext<'_, V> { fn borrow(&self) -> &AppContext { &*self.window_cx.app } } -impl BorrowMut for ViewContext<'_, '_, V> { +impl BorrowMut for ViewContext<'_, V> { fn borrow_mut(&mut self) -> &mut AppContext { &mut *self.window_cx.app } } -impl Borrow for ViewContext<'_, '_, V> { +impl Borrow for ViewContext<'_, V> { fn borrow(&self) -> &Window { &*self.window_cx.window } } -impl BorrowMut for ViewContext<'_, '_, V> { +impl BorrowMut for ViewContext<'_, V> { fn borrow_mut(&mut self) -> &mut Window { &mut *self.window_cx.window } } -impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { - pub(crate) fn new(app: &'a mut AppContext, window: &'w mut Window, view: &'w View) -> Self { +impl<'a, V: 'static> ViewContext<'a, V> { + pub(crate) fn new(app: &'a mut AppContext, window: &'a mut Window, view: &'a View) -> Self { Self { window_cx: WindowContext::mutable(app, window), view, @@ -1612,7 +1612,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { pub fn observe( &mut self, entity: &E, - mut on_notify: impl FnMut(&mut V, E, &mut ViewContext<'_, '_, V>) + Send + 'static, + mut on_notify: impl FnMut(&mut V, E, &mut ViewContext<'_, V>) + Send + 'static, ) -> Subscription where V2: 'static, @@ -1642,7 +1642,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { pub fn subscribe( &mut self, entity: &E, - mut on_event: impl FnMut(&mut V, E, &V2::Event, &mut ViewContext<'_, '_, V>) + Send + 'static, + mut on_event: impl FnMut(&mut V, E, &V2::Event, &mut ViewContext<'_, V>) + Send + 'static, ) -> Subscription where V2: EventEmitter, @@ -1687,7 +1687,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { pub fn observe_release( &mut self, entity: &E, - mut on_release: impl FnMut(&mut V, &mut V2, &mut ViewContext<'_, '_, V>) + Send + 'static, + mut on_release: impl FnMut(&mut V, &mut V2, &mut ViewContext<'_, V>) + Send + 'static, ) -> Subscription where V: Any + Send, @@ -1816,7 +1816,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { pub fn run_on_main( &mut self, view: &mut V, - f: impl FnOnce(&mut V, &mut MainThread>) -> R + Send + 'static, + f: impl FnOnce(&mut V, &mut MainThread>) -> R + Send + 'static, ) -> Task> where R: Send + 'static, @@ -1857,7 +1857,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { pub fn observe_global( &mut self, - f: impl Fn(&mut V, &mut ViewContext<'_, '_, V>) + Send + 'static, + f: impl Fn(&mut V, &mut ViewContext<'_, V>) + Send + 'static, ) -> Subscription { let window_handle = self.window.handle; let view = self.view().downgrade(); @@ -1885,10 +1885,10 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> { } } -impl<'a, 'w, V> ViewContext<'a, 'w, V> +impl ViewContext<'_, V> where V: EventEmitter, - V::Event: Any + Send, + V::Event: 'static + Send, { pub fn emit(&mut self, event: V::Event) { let emitter = self.view.model.entity_id; @@ -1899,7 +1899,7 @@ where } } -impl<'a, 'w, V: 'static> MainThread> { +impl MainThread> { fn platform_window(&self) -> &dyn PlatformWindow { self.window.platform_window.borrow_on_main_thread().as_ref() } @@ -1909,7 +1909,7 @@ impl<'a, 'w, V: 'static> MainThread> { } } -impl<'a, 'w, V> Context for ViewContext<'a, 'w, V> { +impl Context for ViewContext<'_, V> { type ModelContext<'b, U> = ModelContext<'b, U>; type Result = U; @@ -1932,12 +1932,12 @@ impl<'a, 'w, V> Context for ViewContext<'a, 'w, V> { } } -impl VisualContext for ViewContext<'_, '_, V> { - type ViewContext<'a, 'w, V2: 'static> = ViewContext<'a, 'w, V2>; +impl VisualContext for ViewContext<'_, V> { + type ViewContext<'a, W: 'static> = ViewContext<'a, W>; fn build_view( &mut self, - build_view: impl FnOnce(&mut Self::ViewContext<'_, '_, W>) -> W, + build_view: impl FnOnce(&mut Self::ViewContext<'_, W>) -> W, ) -> Self::Result> { self.window_cx.build_view(build_view) } @@ -1945,21 +1945,21 @@ impl VisualContext for ViewContext<'_, '_, V> { fn update_view( &mut self, view: &View, - update: impl FnOnce(&mut V2, &mut Self::ViewContext<'_, '_, V2>) -> R, + update: impl FnOnce(&mut V2, &mut Self::ViewContext<'_, V2>) -> R, ) -> Self::Result { self.window_cx.update_view(view, update) } } -impl<'a, 'w, V> std::ops::Deref for ViewContext<'a, 'w, V> { - type Target = WindowContext<'a, 'w>; +impl<'a, V> std::ops::Deref for ViewContext<'a, V> { + type Target = WindowContext<'a, 'a>; fn deref(&self) -> &Self::Target { &self.window_cx } } -impl<'a, 'w, V> std::ops::DerefMut for ViewContext<'a, 'w, V> { +impl<'a, V> std::ops::DerefMut for ViewContext<'a, V> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.window_cx } diff --git a/crates/gpui2_macros/src/derive_component.rs b/crates/gpui2_macros/src/derive_component.rs index d1919c8bc4..a946703310 100644 --- a/crates/gpui2_macros/src/derive_component.rs +++ b/crates/gpui2_macros/src/derive_component.rs @@ -30,7 +30,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream { let expanded = quote! { impl #impl_generics gpui2::Component<#view_type> for #name #ty_generics #where_clause { fn render(self) -> gpui2::AnyElement<#view_type> { - (move |view_state: &mut #view_type, cx: &mut gpui2::ViewContext<'_, '_, #view_type>| self.render(view_state, cx)) + (move |view_state: &mut #view_type, cx: &mut gpui2::ViewContext<'_, #view_type>| self.render(view_state, cx)) .render() } }