diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index f5d2c83a8f..e850e43925 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -80,8 +80,8 @@ pub enum BlockStyle { Sticky, } -pub struct BlockContext<'a, 'b, 'c, 'd> { - pub view_context: &'d mut ViewContext<'a, 'b, 'c, Editor>, +pub struct BlockContext<'a, 'b, 'c> { + pub view_context: &'c mut ViewContext<'a, 'b, Editor>, pub anchor_x: f32, pub scroll_x: f32, pub gutter_width: f32, @@ -932,15 +932,15 @@ impl BlockDisposition { } } -impl<'a, 'b, 'c, 'd> Deref for BlockContext<'a, 'b, 'c, 'd> { - type Target = ViewContext<'a, 'b, 'c, Editor>; +impl<'a, 'b, 'c> Deref for BlockContext<'a, 'b, 'c> { + type Target = ViewContext<'a, 'b, Editor>; fn deref(&self) -> &Self::Target { self.view_context } } -impl DerefMut for BlockContext<'_, '_, '_, '_> { +impl DerefMut for BlockContext<'_, '_, '_> { fn deref_mut(&mut self) -> &mut Self::Target { self.view_context } diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 762837c478..c53a2f2c24 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -69,7 +69,7 @@ pub trait Entity: 'static { pub trait View: Entity + Sized { fn ui_name() -> &'static str; - fn render(&mut self, cx: &mut ViewContext<'_, '_, '_, Self>) -> Element; + fn render(&mut self, cx: &mut ViewContext<'_, '_, Self>) -> Element; fn focus_in(&mut self, _: AnyViewHandle, _: &mut ViewContext) {} fn focus_out(&mut self, _: AnyViewHandle, _: &mut ViewContext) {} fn key_down(&mut self, _: &KeyDownEvent, _: &mut ViewContext) -> bool { @@ -2518,12 +2518,7 @@ pub trait AnyView { ) -> Option>>>; fn ui_name(&self) -> &'static str; fn render(&mut self, cx: &mut WindowContext, view_id: usize) -> Box; - fn focus_in<'a, 'b>( - &mut self, - focused_id: usize, - cx: &mut WindowContext<'a, 'b>, - view_id: usize, - ); + fn focus_in<'a, 'b>(&mut self, focused_id: usize, cx: &mut WindowContext<'a>, view_id: usize); fn focus_out(&mut self, focused_id: usize, cx: &mut WindowContext, view_id: usize); fn key_down(&mut self, event: &KeyDownEvent, cx: &mut WindowContext, view_id: usize) -> bool; fn key_up(&mut self, event: &KeyUpEvent, cx: &mut WindowContext, view_id: usize) -> bool; @@ -2919,28 +2914,28 @@ impl DerefMut for ModelContext<'_, M> { } } -pub struct ViewContext<'a, 'b, 'c, T: ?Sized> { - window_context: Reference<'c, WindowContext<'a, 'b>>, +pub struct ViewContext<'a, 'b, T: ?Sized> { + window_context: Reference<'b, WindowContext<'a>>, view_id: usize, view_type: PhantomData, } -impl<'a, 'b, 'c, T: View> Deref for ViewContext<'a, 'b, 'c, T> { - type Target = WindowContext<'a, 'b>; +impl<'a, 'b, T: View> Deref for ViewContext<'a, 'b, T> { + type Target = WindowContext<'a>; fn deref(&self) -> &Self::Target { &self.window_context } } -impl DerefMut for ViewContext<'_, '_, '_, T> { +impl DerefMut for ViewContext<'_, '_, T> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.window_context } } -impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> { - pub(crate) fn mutable(window_context: &'c mut WindowContext<'a, 'b>, view_id: usize) -> Self { +impl<'a, 'b, V: View> ViewContext<'a, 'b, V> { + pub(crate) fn mutable(window_context: &'b mut WindowContext<'a>, view_id: usize) -> Self { Self { window_context: Reference::Mutable(window_context), view_id, @@ -2948,7 +2943,7 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> { } } - pub(crate) fn immutable(window_context: &'c WindowContext<'a, 'b>, view_id: usize) -> Self { + pub(crate) fn immutable(window_context: &'b WindowContext<'a>, view_id: usize) -> Self { Self { window_context: Reference::Immutable(window_context), view_id, @@ -2956,7 +2951,7 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> { } } - pub fn window_context(&mut self) -> &mut WindowContext<'a, 'b> { + pub fn window_context(&mut self) -> &mut WindowContext<'a> { &mut self.window_context } @@ -3450,7 +3445,7 @@ impl<'a, 'b, 'c, V: View> ViewContext<'a, 'b, 'c, V> { } } -impl UpgradeModelHandle for ViewContext<'_, '_, '_, V> { +impl UpgradeModelHandle for ViewContext<'_, '_, V> { fn upgrade_model_handle( &self, handle: &WeakModelHandle, @@ -3467,7 +3462,7 @@ impl UpgradeModelHandle for ViewContext<'_, '_, '_, V> { } } -impl UpgradeViewHandle for ViewContext<'_, '_, '_, V> { +impl UpgradeViewHandle for ViewContext<'_, '_, V> { fn upgrade_view_handle(&self, handle: &WeakViewHandle) -> Option> { self.window_context.upgrade_view_handle(handle) } @@ -3477,13 +3472,13 @@ impl UpgradeViewHandle for ViewContext<'_, '_, '_, V> { } } -impl ReadModel for ViewContext<'_, '_, '_, V> { +impl ReadModel for ViewContext<'_, '_, V> { fn read_model(&self, handle: &ModelHandle) -> &T { self.window_context.read_model(handle) } } -impl UpdateModel for ViewContext<'_, '_, '_, V> { +impl UpdateModel for ViewContext<'_, '_, V> { fn update_model( &mut self, handle: &ModelHandle, @@ -3493,13 +3488,13 @@ impl UpdateModel for ViewContext<'_, '_, '_, V> { } } -impl ReadView for ViewContext<'_, '_, '_, V> { +impl ReadView for ViewContext<'_, '_, V> { fn read_view(&self, handle: &ViewHandle) -> &T { self.window_context.read_view(handle) } } -impl UpdateView for ViewContext<'_, '_, '_, V> { +impl UpdateView for ViewContext<'_, '_, V> { type Output = S; fn update_view( @@ -3514,13 +3509,13 @@ impl UpdateView for ViewContext<'_, '_, '_, V> { } } -pub struct EventContext<'a, 'b, 'c, 'd, V: View> { - view_context: &'d mut ViewContext<'a, 'b, 'c, V>, +pub struct EventContext<'a, 'b, 'c, V: View> { + view_context: &'c mut ViewContext<'a, 'b, V>, pub(crate) handled: bool, } -impl<'a, 'b, 'c, 'd, V: View> EventContext<'a, 'b, 'c, 'd, V> { - pub(crate) fn new(view_context: &'d mut ViewContext<'a, 'b, 'c, V>) -> Self { +impl<'a, 'b, 'c, V: View> EventContext<'a, 'b, 'c, V> { + pub(crate) fn new(view_context: &'c mut ViewContext<'a, 'b, V>) -> Self { EventContext { view_context, handled: true, @@ -3532,21 +3527,21 @@ impl<'a, 'b, 'c, 'd, V: View> EventContext<'a, 'b, 'c, 'd, V> { } } -impl<'a, 'b, 'c, 'd, V: View> Deref for EventContext<'a, 'b, 'c, 'd, V> { - type Target = ViewContext<'a, 'b, 'c, V>; +impl<'a, 'b, 'c, V: View> Deref for EventContext<'a, 'b, 'c, V> { + type Target = ViewContext<'a, 'b, V>; fn deref(&self) -> &Self::Target { &self.view_context } } -impl DerefMut for EventContext<'_, '_, '_, '_, V> { +impl DerefMut for EventContext<'_, '_, '_, V> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.view_context } } -impl UpdateModel for EventContext<'_, '_, '_, '_, V> { +impl UpdateModel for EventContext<'_, '_, '_, V> { fn update_model( &mut self, handle: &ModelHandle, @@ -3556,13 +3551,13 @@ impl UpdateModel for EventContext<'_, '_, '_, '_, V> { } } -impl ReadView for EventContext<'_, '_, '_, '_, V> { +impl ReadView for EventContext<'_, '_, '_, V> { fn read_view(&self, handle: &crate::ViewHandle) -> &W { self.view_context.read_view(handle) } } -impl UpdateView for EventContext<'_, '_, '_, '_, V> { +impl UpdateView for EventContext<'_, '_, '_, V> { type Output = S; fn update_view( @@ -3577,7 +3572,7 @@ impl UpdateView for EventContext<'_, '_, '_, '_, V> { } } -impl UpgradeModelHandle for EventContext<'_, '_, '_, '_, V> { +impl UpgradeModelHandle for EventContext<'_, '_, '_, V> { fn upgrade_model_handle( &self, handle: &WeakModelHandle, @@ -3594,7 +3589,7 @@ impl UpgradeModelHandle for EventContext<'_, '_, '_, '_, V> { } } -impl UpgradeViewHandle for EventContext<'_, '_, '_, '_, V> { +impl UpgradeViewHandle for EventContext<'_, '_, '_, V> { fn upgrade_view_handle(&self, handle: &WeakViewHandle) -> Option> { self.view_context.upgrade_view_handle(handle) } @@ -4106,7 +4101,7 @@ impl AnyViewHandle { self.view_type } - pub fn debug_json<'a, 'b>(&self, cx: &'b WindowContext<'a, 'b>) -> serde_json::Value { + pub fn debug_json<'a, 'b>(&self, cx: &'b WindowContext<'a>) -> serde_json::Value { cx.views .get(&(self.window_id, self.view_id)) .map_or_else(|| serde_json::Value::Null, |view| view.debug_json(cx)) diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rs index 306e83652a..598bba10de 100644 --- a/crates/gpui/src/app/window.rs +++ b/crates/gpui/src/app/window.rs @@ -111,15 +111,15 @@ impl Window { } } -pub struct WindowContext<'a: 'b, 'b> { +pub struct WindowContext<'a> { pub(crate) app_context: Reference<'a, AppContext>, - pub(crate) window: Reference<'b, Window>, + pub(crate) window: Reference<'a, Window>, pub(crate) window_id: usize, pub(crate) refreshing: bool, pub(crate) removed: bool, } -impl Deref for WindowContext<'_, '_> { +impl Deref for WindowContext<'_> { type Target = AppContext; fn deref(&self) -> &Self::Target { @@ -127,19 +127,19 @@ impl Deref for WindowContext<'_, '_> { } } -impl DerefMut for WindowContext<'_, '_> { +impl DerefMut for WindowContext<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.app_context } } -impl ReadModel for WindowContext<'_, '_> { +impl ReadModel for WindowContext<'_> { fn read_model(&self, handle: &ModelHandle) -> &T { self.app_context.read_model(handle) } } -impl UpdateModel for WindowContext<'_, '_> { +impl UpdateModel for WindowContext<'_> { fn update_model( &mut self, handle: &ModelHandle, @@ -149,13 +149,13 @@ impl UpdateModel for WindowContext<'_, '_> { } } -impl ReadView for WindowContext<'_, '_> { +impl ReadView for WindowContext<'_> { fn read_view(&self, handle: &crate::ViewHandle) -> &W { self.app_context.read_view(handle) } } -impl UpdateView for WindowContext<'_, '_> { +impl UpdateView for WindowContext<'_> { type Output = S; fn update_view( @@ -179,7 +179,7 @@ impl UpdateView for WindowContext<'_, '_> { } } -impl UpgradeModelHandle for WindowContext<'_, '_> { +impl UpgradeModelHandle for WindowContext<'_> { fn upgrade_model_handle( &self, handle: &WeakModelHandle, @@ -196,7 +196,7 @@ impl UpgradeModelHandle for WindowContext<'_, '_> { } } -impl UpgradeViewHandle for WindowContext<'_, '_> { +impl UpgradeViewHandle for WindowContext<'_> { fn upgrade_view_handle(&self, handle: &WeakViewHandle) -> Option> { self.app_context.upgrade_view_handle(handle) } @@ -206,10 +206,10 @@ impl UpgradeViewHandle for WindowContext<'_, '_> { } } -impl<'a: 'b, 'b> WindowContext<'a, 'b> { +impl<'a> WindowContext<'a> { pub fn mutable( app_context: &'a mut AppContext, - window: &'b mut Window, + window: &'a mut Window, window_id: usize, ) -> Self { Self { @@ -221,7 +221,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> { } } - pub fn immutable(app_context: &'a AppContext, window: &'b Window, window_id: usize) -> Self { + pub fn immutable(app_context: &'a AppContext, window: &'a Window, window_id: usize) -> Self { Self { app_context: Reference::Immutable(app_context), window: Reference::Immutable(window),