diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 262ec456373..331291e6d0d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -10250,14 +10250,6 @@ impl ScrollbarLayoutInformation { } } -impl IntoElement for EditorElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - pub struct EditorLayout { position_map: Rc, hitbox: Hitbox, diff --git a/crates/editor/src/split_editor_view.rs b/crates/editor/src/split_editor_view.rs index 2dee964f356..bb6aab56fe8 100644 --- a/crates/editor/src/split_editor_view.rs +++ b/crates/editor/src/split_editor_view.rs @@ -261,14 +261,6 @@ struct SplitBufferHeadersPrepaintState { non_sticky_headers: Vec, } -impl IntoElement for SplitBufferHeadersElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for SplitBufferHeadersElement { type RequestLayoutState = (); type PrepaintState = SplitBufferHeadersPrepaintState; diff --git a/crates/gpui/examples/input.rs b/crates/gpui/examples/input.rs index 5bff4ce3423..7b1a212b98f 100644 --- a/crates/gpui/examples/input.rs +++ b/crates/gpui/examples/input.rs @@ -470,14 +470,6 @@ struct PrepaintState { selection: Option, } -impl IntoElement for TextElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for TextElement { type RequestLayoutState = (); type PrepaintState = PrepaintState; diff --git a/crates/gpui/examples/view_example/example_editor.rs b/crates/gpui/examples/view_example/example_editor.rs index 2064d7cacef..4655455f394 100644 --- a/crates/gpui/examples/view_example/example_editor.rs +++ b/crates/gpui/examples/view_example/example_editor.rs @@ -349,14 +349,6 @@ struct EditorTextPrepaint { cursor: Option, } -impl IntoElement for EditorText { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for EditorText { type RequestLayoutState = (); type PrepaintState = EditorTextPrepaint; diff --git a/crates/gpui/src/element.rs b/crates/gpui/src/element.rs index 8f980bd53a9..c9ec80acfa9 100644 --- a/crates/gpui/src/element.rs +++ b/crates/gpui/src/element.rs @@ -49,7 +49,7 @@ use std::{ /// Elements form a tree and are laid out according to web-based layout rules, as implemented by Taffy. /// You can create custom elements by implementing this trait, see the module-level documentation /// for more details. -pub trait Element: 'static + IntoElement { +pub trait Element: 'static + Sized { /// The type of state returned from [`Element::request_layout`]. A mutable reference to this state is subsequently /// provided to [`Element::prepaint`] and [`Element::paint`]. type RequestLayoutState: 'static; @@ -138,7 +138,15 @@ pub trait Element: 'static + IntoElement { /// Convert this element into a dynamically-typed [`AnyElement`]. fn into_any(self) -> AnyElement { - AnyElement::new(self) + AnyElement::new_please_call_into_any_to_avoid_double_box(self) + } +} + +impl IntoElement for T { + type Element = Self; + + fn into_element(self) -> Self::Element { + self } } @@ -650,7 +658,12 @@ where pub struct AnyElement(ArenaBox); impl AnyElement { - pub(crate) fn new(element: E) -> Self + /// Boxes `element` into an `AnyElement`, erasing its concrete type. + /// + /// This always allocates and always adds a level of boxing, even when `element` is + /// already an [`AnyElement`], which would nest one `AnyElement` inside another. Call + /// [`Element::into_any`] instead; it skips the wrapper for `AnyElement` itself. + fn new_please_call_into_any_to_avoid_double_box(element: E) -> Self where E: 'static + Element, E::RequestLayoutState: Any, @@ -772,16 +785,8 @@ impl Element for AnyElement { ) { self.paint(window, cx); } -} -impl IntoElement for AnyElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - - fn into_any_element(self) -> AnyElement { + fn into_any(self) -> AnyElement { self } } @@ -789,14 +794,6 @@ impl IntoElement for AnyElement { /// The empty element, which renders nothing. pub struct Empty; -impl IntoElement for Empty { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for Empty { type RequestLayoutState = (); type PrepaintState = (); diff --git a/crates/gpui/src/elements/anchored.rs b/crates/gpui/src/elements/anchored.rs index 12f3f086c14..63a07b03b76 100644 --- a/crates/gpui/src/elements/anchored.rs +++ b/crates/gpui/src/elements/anchored.rs @@ -4,8 +4,8 @@ use smallvec::SmallVec; use crate::{ Anchor, AnyElement, App, Axis, Bounds, Display, Edges, Element, GlobalElementId, - InspectorElementId, IntoElement, LayoutId, ParentElement, Pixels, Point, Position, Size, Style, - Window, point, px, + InspectorElementId, LayoutId, ParentElement, Pixels, Point, Position, Size, Style, Window, + point, px, }; /// The state that the anchored element element uses to track its children. @@ -307,14 +307,6 @@ impl Element for Anchored { } } -impl IntoElement for Anchored { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - /// Which side of a box `anchor` is on along `axis`. `Less` is left or top, `Equal` is the /// center, and `Greater` is right or bottom. fn side_along(anchor: Anchor, axis: Axis) -> Ordering { diff --git a/crates/gpui/src/elements/animation.rs b/crates/gpui/src/elements/animation.rs index 70613f38c5a..33f7bc19fd6 100644 --- a/crates/gpui/src/elements/animation.rs +++ b/crates/gpui/src/elements/animation.rs @@ -196,14 +196,6 @@ impl SpringAnimationElement { } } -impl IntoElement for SpringAnimationElement { - type Element = SpringAnimationElement; - - fn into_element(self) -> Self::Element { - self - } -} - impl ParentElement for AnimationElement { fn extend(&mut self, elements: impl IntoIterator) { let Some(element) = &mut self.element else { @@ -223,14 +215,6 @@ impl AnimationElement { } } -impl IntoElement for AnimationElement { - type Element = AnimationElement; - - fn into_element(self) -> Self::Element { - self - } -} - struct AnimationState { start: Instant, animation_ix: usize, diff --git a/crates/gpui/src/elements/canvas.rs b/crates/gpui/src/elements/canvas.rs index d57d2f60416..8c06494f04b 100644 --- a/crates/gpui/src/elements/canvas.rs +++ b/crates/gpui/src/elements/canvas.rs @@ -1,8 +1,8 @@ use refineable::Refineable as _; use crate::{ - App, Bounds, Element, ElementId, GlobalElementId, InspectorElementId, IntoElement, Pixels, - Style, StyleRefinement, Styled, Window, + App, Bounds, Element, ElementId, GlobalElementId, InspectorElementId, Pixels, Style, + StyleRefinement, Styled, Window, }; /// Construct a canvas element with the given paint callback. @@ -26,14 +26,6 @@ pub struct Canvas { style: StyleRefinement, } -impl IntoElement for Canvas { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for Canvas { type RequestLayoutState = Style; type PrepaintState = Option; diff --git a/crates/gpui/src/elements/container_query.rs b/crates/gpui/src/elements/container_query.rs index 0363ce69008..e4e1ed8b21e 100644 --- a/crates/gpui/src/elements/container_query.rs +++ b/crates/gpui/src/elements/container_query.rs @@ -111,14 +111,6 @@ impl Element for ContainerQuery { } } -impl IntoElement for ContainerQuery { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Styled for ContainerQuery { fn style(&mut self) -> &mut StyleRefinement { &mut self.style diff --git a/crates/gpui/src/elements/deferred.rs b/crates/gpui/src/elements/deferred.rs index 3496268a532..f54056159f6 100644 --- a/crates/gpui/src/elements/deferred.rs +++ b/crates/gpui/src/elements/deferred.rs @@ -78,14 +78,6 @@ impl Element for Deferred { } } -impl IntoElement for Deferred { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Deferred { /// Sets a priority for the element. A higher priority conceptually means painting the element /// on top of deferred draws with a lower priority (i.e. closer to the viewer). diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index f28f091739d..ce038047780 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -19,12 +19,12 @@ use crate::{ Action, AnyDrag, AnyElement, AnyTooltip, AnyView, App, BackGestureEvent, Bounds, ClickEvent, DispatchPhase, Display, Element, ElementId, Entity, EntityId, ExternalDragPayload, ExternalDragPayloadSource, FileDropEvent, FocusHandle, Global, GlobalElementId, Hitbox, - HitboxBehavior, HitboxId, InspectorElementId, IntoElement, IsZero, KeyContext, KeyDownEvent, - KeyUpEvent, KeyboardButton, KeyboardClickEvent, LayoutId, LongPressEvent, - ModifiersChangedEvent, MouseButton, MouseClickEvent, MouseDownEvent, MouseExitEvent, - MouseMoveEvent, MousePressureEvent, MouseUpEvent, OngoingScroll, Overflow, ParentElement, - PinchEvent, Pixels, Point, Render, ScrollEvent, SharedString, Size, Style, StyleRefinement, - Styled, Task, TooltipId, TouchPhase, Visibility, Window, WindowControlArea, point, px, size, + HitboxBehavior, HitboxId, InspectorElementId, IsZero, KeyContext, KeyDownEvent, KeyUpEvent, + KeyboardButton, KeyboardClickEvent, LayoutId, LongPressEvent, ModifiersChangedEvent, + MouseButton, MouseClickEvent, MouseDownEvent, MouseExitEvent, MouseMoveEvent, + MousePressureEvent, MouseUpEvent, OngoingScroll, Overflow, ParentElement, PinchEvent, Pixels, + Point, Render, ScrollEvent, SharedString, Size, Style, StyleRefinement, Styled, Task, + TooltipId, TouchPhase, Visibility, Window, WindowControlArea, point, px, size, }; use collections::HashMap; use gpui_util::ResultExt; @@ -2196,14 +2196,6 @@ impl Element for Div { } } -impl IntoElement for Div { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - #[derive(Default)] pub(crate) struct AriaProperties { pub(crate) author_id: Option, @@ -4282,17 +4274,6 @@ where } } -impl IntoElement for Stateful -where - E: Element, -{ - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl ParentElement for Stateful where E: ParentElement, @@ -4555,8 +4536,9 @@ impl ScrollHandle { mod tests { use super::*; use crate::{ - AnyWindowHandle, AppContext as _, Context, GestureTuning, InputEvent, Keystroke, - MouseMoveEvent, TestAppContext, TouchEvent, TouchId, canvas, util::FluentBuilder as _, + AnyWindowHandle, AppContext as _, Context, GestureTuning, InputEvent, IntoElement, + Keystroke, MouseMoveEvent, TestAppContext, TouchEvent, TouchId, canvas, + util::FluentBuilder as _, }; use std::{cell::Cell, rc::Weak}; @@ -4900,14 +4882,6 @@ mod tests { captured_active_tooltip: CapturedActiveTooltip, } - impl IntoElement for TooltipCaptureElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - } - impl Element for TooltipCaptureElement { type RequestLayoutState = (); type PrepaintState = (); diff --git a/crates/gpui/src/elements/image_cache.rs b/crates/gpui/src/elements/image_cache.rs index 1920944299b..3d9d4ce6113 100644 --- a/crates/gpui/src/elements/image_cache.rs +++ b/crates/gpui/src/elements/image_cache.rs @@ -1,6 +1,6 @@ use crate::{ AnyElement, AnyEntity, App, AppContext, Asset, AssetLogger, Bounds, Element, ElementId, Entity, - GlobalElementId, ImageAssetLoader, ImageCacheError, InspectorElementId, IntoElement, LayoutId, + GlobalElementId, ImageAssetLoader, ImageCacheError, InspectorElementId, LayoutId, ParentElement, Pixels, RenderImage, Resource, Style, StyleRefinement, Styled, Window, hash, }; @@ -86,14 +86,6 @@ impl Styled for ImageCacheElement { } } -impl IntoElement for ImageCacheElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for ImageCacheElement { type RequestLayoutState = SmallVec<[LayoutId; 4]>; type PrepaintState = (); diff --git a/crates/gpui/src/elements/img.rs b/crates/gpui/src/elements/img.rs index a9878f4f70c..6cc5db89ab0 100644 --- a/crates/gpui/src/elements/img.rs +++ b/crates/gpui/src/elements/img.rs @@ -1,9 +1,9 @@ use crate::{ AnyElement, AnyImageCache, App, Asset, AssetLogger, Bounds, DefiniteLength, Element, ElementId, Entity, GlobalElementId, Hitbox, Image, ImageCache, InspectorElementId, InteractiveElement, - Interactivity, IntoElement, LayoutId, Length, ObjectFit, Pixels, RenderImage, Resource, - SharedString, SharedUri, StyleRefinement, Styled, Task, Window, decode_gif_image, - decode_static_image, decode_webp_image, px, + Interactivity, LayoutId, Length, ObjectFit, Pixels, RenderImage, Resource, SharedString, + SharedUri, StyleRefinement, Styled, Task, Window, decode_gif_image, decode_static_image, + decode_webp_image, px, }; use anyhow::Result; @@ -518,14 +518,6 @@ impl InteractiveElement for Img { } } -impl IntoElement for Img { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl StatefulInteractiveElement for Img {} impl ImageSource { @@ -736,7 +728,7 @@ impl From for ImageCacheError { #[cfg(test)] mod tests { use super::*; - use crate::{ParentElement as _, TestAppContext, canvas, div, point, px, size}; + use crate::{IntoElement, ParentElement as _, TestAppContext, canvas, div, point, px, size}; use image::{Frame, ImageBuffer, Rgba}; use smallvec::SmallVec; diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs index 4268774881f..070d4b081ea 100644 --- a/crates/gpui/src/elements/list.rs +++ b/crates/gpui/src/elements/list.rs @@ -10,8 +10,8 @@ use crate::{ Along as _, AnyElement, App, AvailableSpace, Axis, Bounds, ContentMask, DispatchPhase, Edges, Element, EntityId, FocusHandle, GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId, - IntoElement, Overflow, Pixels, Point, ScrollDelta, ScrollEvent, Size, Style, StyleRefinement, - Styled, Window, point, px, size, + Overflow, Pixels, Point, ScrollDelta, ScrollEvent, Size, Style, StyleRefinement, Styled, + Window, point, px, size, }; use collections::VecDeque; use refineable::Refineable as _; @@ -1658,14 +1658,6 @@ fn content_insets(style: &Style, size: Size, rem_size: Pixels) -> Edges< padding + border } -impl IntoElement for List { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Styled for List { fn style(&mut self) -> &mut StyleRefinement { &mut self.style diff --git a/crates/gpui/src/elements/surface.rs b/crates/gpui/src/elements/surface.rs index acd29329109..043315f90d5 100644 --- a/crates/gpui/src/elements/surface.rs +++ b/crates/gpui/src/elements/surface.rs @@ -1,6 +1,6 @@ use crate::{ - App, Bounds, Element, ElementId, GlobalElementId, InspectorElementId, IntoElement, LayoutId, - ObjectFit, Pixels, Style, StyleRefinement, Styled, Window, + App, Bounds, Element, ElementId, GlobalElementId, InspectorElementId, LayoutId, ObjectFit, + Pixels, Style, StyleRefinement, Styled, Window, }; #[cfg(any(target_os = "macos", target_os = "ios"))] use objc2_core_foundation::CFRetained; @@ -119,14 +119,6 @@ impl Element for Surface { } } -impl IntoElement for Surface { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Styled for Surface { fn style(&mut self) -> &mut StyleRefinement { &mut self.style diff --git a/crates/gpui/src/elements/svg.rs b/crates/gpui/src/elements/svg.rs index 176072f1c88..e87f0da63ca 100644 --- a/crates/gpui/src/elements/svg.rs +++ b/crates/gpui/src/elements/svg.rs @@ -7,8 +7,8 @@ use std::{ use crate::{ App, Asset, Bounds, Element, GlobalElementId, Hitbox, InspectorElementId, InteractiveElement, - Interactivity, IntoElement, LayoutId, Pixels, Point, Radians, SharedString, Size, - StyleRefinement, Styled, TransformationMatrix, Window, point, px, radians, size, + Interactivity, LayoutId, Pixels, Point, Radians, SharedString, Size, StyleRefinement, Styled, + TransformationMatrix, Window, point, px, radians, size, }; use gpui_util::ResultExt; @@ -189,14 +189,6 @@ impl Element for Svg { } } -impl IntoElement for Svg { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Styled for Svg { fn style(&mut self) -> &mut StyleRefinement { &mut self.interactivity.base_style diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index e2463ac0150..4e095fbc232 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -166,14 +166,6 @@ macro_rules! text { }}; } -impl IntoElement for Text { - type Element = Self; - #[inline] - fn into_element(self) -> Self::Element { - self - } -} - impl Element for Text { type RequestLayoutState = TextLayout; type PrepaintState = (); @@ -301,14 +293,6 @@ impl Element for &'static str { } } -impl IntoElement for &'static str { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl IntoElement for String { type Element = SharedString; @@ -375,14 +359,6 @@ impl Element for SharedString { } } -impl IntoElement for SharedString { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - /// Renders text with runs of different styles. /// /// Callers are responsible for setting the correct style for each run. @@ -601,14 +577,6 @@ impl Element for StyledText { } } -impl IntoElement for StyledText { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - /// The Layout for TextElement. This can be used to map indices to pixels and vice versa. #[derive(Default, Clone)] pub struct TextLayout(Rc>>); @@ -1308,14 +1276,6 @@ impl Element for InteractiveText { } } -impl IntoElement for InteractiveText { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/gpui/src/elements/uniform_list.rs b/crates/gpui/src/elements/uniform_list.rs index 561292d4a30..ad31cda493d 100644 --- a/crates/gpui/src/elements/uniform_list.rs +++ b/crates/gpui/src/elements/uniform_list.rs @@ -570,14 +570,6 @@ impl Element for UniformList { } } -impl IntoElement for UniformList { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - /// A decoration for a [`UniformList`]. This can be used for various things, /// such as rendering indent guides, or other visual effects. pub trait UniformListDecoration { diff --git a/crates/gpui/src/key_dispatch.rs b/crates/gpui/src/key_dispatch.rs index e4bce617277..764f31f7d4f 100644 --- a/crates/gpui/src/key_dispatch.rs +++ b/crates/gpui/src/key_dispatch.rs @@ -736,14 +736,6 @@ mod tests { } } - impl IntoElement for PendingTextInputTestView { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - } - impl InputHandler for PendingTextInputTestView { fn accepts_text_input(&mut self, _: &mut Window, _: &mut App) -> bool { self.accepts_text_input.get() @@ -1214,14 +1206,6 @@ mod tests { } } - impl IntoElement for CustomElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - } - impl InputHandler for CustomElement { fn selected_text_range( &mut self, diff --git a/crates/gpui/src/view.rs b/crates/gpui/src/view.rs index 37418510d9c..733373aac18 100644 --- a/crates/gpui/src/view.rs +++ b/crates/gpui/src/view.rs @@ -312,14 +312,6 @@ impl ViewElement { } } -impl IntoElement for ViewElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - struct ViewElementState { prepaint_range: Range, paint_range: Range, diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs index 95109499db3..b757c46aa10 100644 --- a/crates/image_viewer/src/image_viewer.rs +++ b/crates/image_viewer/src/image_viewer.rs @@ -367,14 +367,6 @@ impl ImageContentElement { } } -impl IntoElement for ImageContentElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for ImageContentElement { type RequestLayoutState = (); type PrepaintState = Option<(AnyElement, bool)>; diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 1cecbdc0fdd..6aa6b63e712 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -3671,14 +3671,6 @@ fn render_copy_code_block_button( }) } -impl IntoElement for MarkdownElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - pub enum AnyDiv { Div(Div), Stateful(Stateful
), @@ -4468,14 +4460,6 @@ impl Element for RenderedLineElement { } } -impl IntoElement for RenderedLineElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - struct RenderedLine { layout: TextLayout, visible_bounds: Cell>>, @@ -8637,14 +8621,6 @@ mod tests { rendered_text: Rc>>, } - impl IntoElement for CapturingMarkdownElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - } - impl Element for CapturingMarkdownElement { type RequestLayoutState = RenderedMarkdown; type PrepaintState = Hitbox; diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index 6db4b3b079f..27469eeac2a 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -1753,14 +1753,6 @@ impl Element for TerminalElement { } } -impl IntoElement for TerminalElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - struct TerminalInputHandler { terminal_view: Entity, workspace: WeakEntity, diff --git a/crates/ui/src/components/indent_guides.rs b/crates/ui/src/components/indent_guides.rs index f83dda592f6..6ad29a294ce 100644 --- a/crates/ui/src/components/indent_guides.rs +++ b/crates/ui/src/components/indent_guides.rs @@ -432,14 +432,6 @@ impl Element for IndentGuidesElement { } } -impl IntoElement for IndentGuidesElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - fn compute_indent_guides( indents: &[usize], offset: usize, diff --git a/crates/ui/src/components/popover_menu.rs b/crates/ui/src/components/popover_menu.rs index 44a381ccd11..c1c078d6dba 100644 --- a/crates/ui/src/components/popover_menu.rs +++ b/crates/ui/src/components/popover_menu.rs @@ -503,14 +503,6 @@ impl Element for PopoverMenu { } } -impl IntoElement for PopoverMenu { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - #[cfg(test)] mod tests { use gpui::{EventEmitter, FocusHandle, Focusable, TestAppContext, VisualTestContext}; diff --git a/crates/ui/src/components/right_click_menu.rs b/crates/ui/src/components/right_click_menu.rs index 9cc792326b1..b7c29bf6bc6 100644 --- a/crates/ui/src/components/right_click_menu.rs +++ b/crates/ui/src/components/right_click_menu.rs @@ -299,11 +299,3 @@ impl Element for RightClickMenu { ) } } - -impl IntoElement for RightClickMenu { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} diff --git a/crates/ui/src/components/scrollbar.rs b/crates/ui/src/components/scrollbar.rs index 679b6bc17f0..de9df116bca 100644 --- a/crates/ui/src/components/scrollbar.rs +++ b/crates/ui/src/components/scrollbar.rs @@ -2,12 +2,12 @@ use std::{any::Any, fmt::Debug, ops::Not, time::Duration}; use web_time::Instant; use gpui::{ - Along, Anchor, AnyElement, App, AppContext as _, Axis as ScrollbarAxis, BorderStyle, Bounds, - ContentMask, Context, Corners, CursorStyle, DispatchPhase, Div, Edges, Element, ElementId, - Entity, EntityId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, InteractiveElement, - IntoElement, IsZero, LayoutId, ListState, MouseButton, MouseDownEvent, MouseMoveEvent, - MouseUpEvent, ParentElement, Pixels, Point, Position, Render, ScrollEvent, ScrollHandle, Size, - Stateful, StatefulInteractiveElement, Style, StyleRefinement, Styled, Subscription, Task, + Along, Anchor, App, AppContext as _, Axis as ScrollbarAxis, BorderStyle, Bounds, ContentMask, + Context, Corners, CursorStyle, DispatchPhase, Div, Edges, Element, ElementId, Entity, EntityId, + GlobalElementId, Hitbox, HitboxBehavior, Hsla, InteractiveElement, IntoElement, IsZero, + LayoutId, ListState, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, + Pixels, Point, Position, Render, ScrollEvent, ScrollHandle, Size, Stateful, + StatefulInteractiveElement, Style, StyleRefinement, Styled, Subscription, Task, UniformListDecoration, UniformListScrollHandle, Window, ease_in_out, fill, prelude::FluentBuilder as _, px, quad, relative, size, }; @@ -1011,11 +1011,6 @@ impl ThumbState { } impl ScrollableHandle for UniformListScrollHandle { - #[inline(never)] - fn into_scrollbar_element(element: ScrollbarElement) -> AnyElement { - element.into_any() - } - fn max_offset(&self) -> Point { self.0.borrow().base_handle.max_offset() } @@ -1034,11 +1029,6 @@ impl ScrollableHandle for UniformListScrollHandle { } impl ScrollableHandle for ListState { - #[inline(never)] - fn into_scrollbar_element(element: ScrollbarElement) -> AnyElement { - element.into_any() - } - fn max_offset(&self) -> Point { self.max_offset_for_scrollbar() } @@ -1065,11 +1055,6 @@ impl ScrollableHandle for ListState { } impl ScrollableHandle for ScrollHandle { - #[inline(never)] - fn into_scrollbar_element(element: ScrollbarElement) -> AnyElement { - element.into_any() - } - fn max_offset(&self) -> Point { self.max_offset() } @@ -1088,10 +1073,6 @@ impl ScrollableHandle for ScrollHandle { } pub trait ScrollableHandle: 'static + Any + Sized + Clone { - fn into_scrollbar_element(element: ScrollbarElement) -> AnyElement { - element.into_any() - } - fn max_offset(&self) -> Point; fn set_offset(&self, point: Point); fn offset(&self) -> Point; @@ -1751,18 +1732,6 @@ impl Element for ScrollbarElement { } } -impl IntoElement for ScrollbarElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - - fn into_any_element(self) -> AnyElement { - T::into_scrollbar_element(self) - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/crates/ui/src/components/sticky_items.rs b/crates/ui/src/components/sticky_items.rs index bf64622b29a..be233b3e65d 100644 --- a/crates/ui/src/components/sticky_items.rs +++ b/crates/ui/src/components/sticky_items.rs @@ -66,14 +66,6 @@ struct StickyItemsElement { rest_decorations: SmallVec<[AnyElement; 1]>, } -impl IntoElement for StickyItemsElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} - impl Element for StickyItemsElement { type RequestLayoutState = (); type PrepaintState = (); diff --git a/crates/ui/src/utils/with_rem_size.rs b/crates/ui/src/utils/with_rem_size.rs index b9770b086ca..d8e6c633a1a 100644 --- a/crates/ui/src/utils/with_rem_size.rs +++ b/crates/ui/src/utils/with_rem_size.rs @@ -1,7 +1,6 @@ use gpui::{ AnyElement, App, Bounds, Div, DivFrameState, Element, ElementId, GlobalElementId, Hitbox, - InteractiveElement as _, IntoElement, LayoutId, ParentElement, Pixels, StyleRefinement, Styled, - Window, div, + InteractiveElement as _, LayoutId, ParentElement, Pixels, StyleRefinement, Styled, Window, div, }; /// An element that sets a particular rem size for its children. @@ -104,11 +103,3 @@ impl Element for WithRemSize { }) } } - -impl IntoElement for WithRemSize { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } -} diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index 672190aff60..41721c6c553 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -1142,8 +1142,8 @@ mod element { use gpui::{ Along, AnyElement, App, Axis, BorderStyle, Bounds, Element, GlobalElementId, - HitboxBehavior, IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, - Pixels, Point, Size, Style, WeakEntity, Window, px, relative, size, + HitboxBehavior, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, + Size, Style, WeakEntity, Window, px, relative, size, }; use gpui::{CursorStyle, Hitbox}; use parking_lot::Mutex; @@ -1347,14 +1347,6 @@ mod element { } } - impl IntoElement for PaneAxisElement { - type Element = Self; - - fn into_element(self) -> Self::Element { - self - } - } - impl Element for PaneAxisElement { type RequestLayoutState = (); type PrepaintState = PaneAxisLayout;