Rust 1.78 (#11314)

Piotr Osiewicz created

Notable things I've had to fix due to 1.78:
- Better detection of unused items
- New clippy lint (`assigning_clones`) that points out places where assignment operations with clone rhs could be replaced with more performant `clone_into`
Release Notes:

- N/A

Change summary

Dockerfile                                                       |  2 
crates/assistant2/src/ui/composer.rs                             |  2 
crates/client/src/client.rs                                      |  2 
crates/client/src/telemetry.rs                                   |  2 
crates/collab/src/api.rs                                         |  7 
crates/collab_ui/src/notifications/incoming_call_notification.rs |  5 
crates/editor/src/display_map/fold_map.rs                        | 23 
crates/editor/src/editor.rs                                      | 24 
crates/editor/src/selections_collection.rs                       |  2 
crates/git/src/blame.rs                                          | 20 
crates/gpui/src/app/async_context.rs                             |  5 
crates/gpui/src/app/test_context.rs                              |  5 
crates/gpui/src/elements/div.rs                                  |  5 
crates/gpui/src/platform.rs                                      | 16 
crates/gpui/src/platform/cosmic_text/text_system.rs              | 11 
crates/gpui/src/platform/linux/platform.rs                       | 22 
crates/gpui/src/platform/linux/wayland/window.rs                 | 13 
crates/gpui/src/platform/linux/x11/window.rs                     | 13 
crates/gpui/src/platform/mac/platform.rs                         | 24 
crates/gpui/src/platform/mac/text_system.rs                      | 85 -
crates/gpui/src/platform/mac/window.rs                           | 44 -
crates/gpui/src/platform/test/platform.rs                        | 20 
crates/gpui/src/platform/test/text_system.rs                     |  9 
crates/gpui/src/platform/test/window.rs                          | 12 
crates/gpui/src/platform/windows/direct_write.rs                 | 10 
crates/gpui/src/platform/windows/platform.rs                     | 20 
crates/gpui/src/platform/windows/window.rs                       | 15 
crates/gpui/src/window.rs                                        | 12 
crates/language/src/buffer.rs                                    |  2 
crates/language/src/language.rs                                  |  2 
crates/language/src/outline.rs                                   |  2 
crates/live_kit_server/build.rs                                  |  1 
crates/search/src/buffer_search.rs                               |  4 
crates/search/src/project_search.rs                              |  9 
crates/theme/src/settings.rs                                     |  2 
crates/theme_importer/src/main.rs                                |  1 
crates/theme_importer/src/util.rs                                | 11 
crates/workspace/src/toolbar.rs                                  | 12 
crates/workspace/src/workspace.rs                                |  2 
crates/zed/src/reliability.rs                                    |  2 
rust-toolchain.toml                                              |  2 
41 files changed, 49 insertions(+), 433 deletions(-)

Detailed changes

Dockerfile 🔗

@@ -1,6 +1,6 @@
 # syntax = docker/dockerfile:1.2
 
-FROM rust:1.77-bookworm as builder
+FROM rust:1.78-bookworm as builder
 WORKDIR app
 COPY . .
 

crates/assistant2/src/ui/composer.rs 🔗

@@ -144,7 +144,7 @@ impl RenderOnce for ModelSelector {
                                 let assistant_chat = self.assistant_chat.clone();
                                 move |cx| {
                                     _ = assistant_chat.update(cx, |assistant_chat, cx| {
-                                        assistant_chat.model = model.clone();
+                                        assistant_chat.model.clone_from(&model);
                                         cx.notify();
                                     });
                                 }

crates/client/src/client.rs 🔗

@@ -100,7 +100,7 @@ impl Settings for ClientSettings {
     fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
         let mut result = sources.json_merge::<Self>()?;
         if let Some(server_url) = &*ZED_SERVER_URL {
-            result.server_url = server_url.clone()
+            result.server_url.clone_from(&server_url)
         }
         Ok(result)
     }

crates/client/src/telemetry.rs 🔗

@@ -217,7 +217,7 @@ impl Telemetry {
         }
 
         let metrics_id: Option<Arc<str>> = metrics_id.map(|id| id.into());
-        state.metrics_id = metrics_id.clone();
+        state.metrics_id.clone_from(&metrics_id);
         state.is_staff = Some(is_staff);
         drop(state);
     }

crates/collab/src/api.rs 🔗

@@ -116,13 +116,6 @@ struct CreateUserParams {
     invite_count: i32,
 }
 
-#[derive(Serialize, Debug)]
-struct CreateUserResponse {
-    user: User,
-    signup_device_id: Option<String>,
-    metrics_id: String,
-}
-
 async fn get_rpc_server_snapshot(
     Extension(rpc_server): Extension<Option<Arc<rpc::Server>>>,
 ) -> Result<ErasedJson> {

crates/editor/src/display_map/fold_map.rs 🔗

@@ -6,7 +6,6 @@ use gpui::{ElementId, HighlightStyle, Hsla};
 use language::{Chunk, Edit, Point, TextSummary};
 use multi_buffer::{Anchor, AnchorRangeExt, MultiBufferSnapshot, ToOffset};
 use std::{
-    any::TypeId,
     cmp::{self, Ordering},
     iter,
     ops::{Add, AddAssign, Deref, DerefMut, Range, Sub},
@@ -1066,28 +1065,6 @@ impl<'a> Iterator for FoldChunks<'a> {
     }
 }
 
-#[derive(Copy, Clone, Eq, PartialEq)]
-struct HighlightEndpoint {
-    offset: InlayOffset,
-    is_start: bool,
-    tag: Option<TypeId>,
-    style: HighlightStyle,
-}
-
-impl PartialOrd for HighlightEndpoint {
-    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
-        Some(self.cmp(other))
-    }
-}
-
-impl Ord for HighlightEndpoint {
-    fn cmp(&self, other: &Self) -> Ordering {
-        self.offset
-            .cmp(&other.offset)
-            .then_with(|| other.is_start.cmp(&self.is_start))
-    }
-}
-
 #[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
 pub struct FoldOffset(pub usize);
 

crates/editor/src/editor.rs 🔗

@@ -1167,7 +1167,7 @@ impl CompletionsMenu {
 
         for mat in &mut matches {
             let completion = &completions[mat.candidate_id];
-            mat.string = completion.label.text.clone();
+            mat.string.clone_from(&completion.label.text);
             for position in &mut mat.positions {
                 *position += completion.label.filter_range.start;
             }
@@ -10837,34 +10837,12 @@ impl ViewInputHandler for Editor {
 }
 
 trait SelectionExt {
-    fn offset_range(&self, buffer: &MultiBufferSnapshot) -> Range<usize>;
-    fn point_range(&self, buffer: &MultiBufferSnapshot) -> Range<Point>;
     fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint>;
     fn spanned_rows(&self, include_end_if_at_line_start: bool, map: &DisplaySnapshot)
         -> Range<u32>;
 }
 
 impl<T: ToPoint + ToOffset> SelectionExt for Selection<T> {
-    fn point_range(&self, buffer: &MultiBufferSnapshot) -> Range<Point> {
-        let start = self.start.to_point(buffer);
-        let end = self.end.to_point(buffer);
-        if self.reversed {
-            end..start
-        } else {
-            start..end
-        }
-    }
-
-    fn offset_range(&self, buffer: &MultiBufferSnapshot) -> Range<usize> {
-        let start = self.start.to_offset(buffer);
-        let end = self.end.to_offset(buffer);
-        if self.reversed {
-            end..start
-        } else {
-            start..end
-        }
-    }
-
     fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint> {
         let start = self
             .start

crates/editor/src/selections_collection.rs 🔗

@@ -69,7 +69,7 @@ impl SelectionsCollection {
         self.next_selection_id = other.next_selection_id;
         self.line_mode = other.line_mode;
         self.disjoint = other.disjoint.clone();
-        self.pending = other.pending.clone();
+        self.pending.clone_from(&other.pending);
     }
 
     pub fn count(&self) -> usize {

crates/git/src/blame.rs 🔗

@@ -255,15 +255,21 @@ fn parse_git_blame(output: &str) -> Result<Vec<BlameEntry>> {
                     .get(&new_entry.sha)
                     .and_then(|slot| entries.get(*slot))
                 {
-                    new_entry.author = existing_entry.author.clone();
-                    new_entry.author_mail = existing_entry.author_mail.clone();
+                    new_entry.author.clone_from(&existing_entry.author);
+                    new_entry
+                        .author_mail
+                        .clone_from(&existing_entry.author_mail);
                     new_entry.author_time = existing_entry.author_time;
-                    new_entry.author_tz = existing_entry.author_tz.clone();
-                    new_entry.committer = existing_entry.committer.clone();
-                    new_entry.committer_mail = existing_entry.committer_mail.clone();
+                    new_entry.author_tz.clone_from(&existing_entry.author_tz);
+                    new_entry.committer.clone_from(&existing_entry.committer);
+                    new_entry
+                        .committer_mail
+                        .clone_from(&existing_entry.committer_mail);
                     new_entry.committer_time = existing_entry.committer_time;
-                    new_entry.committer_tz = existing_entry.committer_tz.clone();
-                    new_entry.summary = existing_entry.summary.clone();
+                    new_entry
+                        .committer_tz
+                        .clone_from(&existing_entry.committer_tz);
+                    new_entry.summary.clone_from(&existing_entry.summary);
                 }
 
                 current_entry.replace(new_entry);

crates/gpui/src/app/async_context.rs 🔗

@@ -25,10 +25,7 @@ impl Context for AsyncAppContext {
     fn new_model<T: 'static>(
         &mut self,
         build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
-    ) -> Self::Result<Model<T>>
-    where
-        T: 'static,
-    {
+    ) -> Self::Result<Model<T>> {
         let app = self
             .app
             .upgrade()

crates/gpui/src/app/test_context.rs 🔗

@@ -35,10 +35,7 @@ impl Context for TestAppContext {
     fn new_model<T: 'static>(
         &mut self,
         build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
-    ) -> Self::Result<Model<T>>
-    where
-        T: 'static,
-    {
+    ) -> Self::Result<Model<T>> {
         let mut app = self.app.borrow_mut();
         app.new_model(build_model)
     }

crates/gpui/src/elements/div.rs 🔗

@@ -708,10 +708,7 @@ pub trait InteractiveElement: Sized {
     fn on_drag_move<T: 'static>(
         mut self,
         listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
-    ) -> Self
-    where
-        T: 'static,
-    {
+    ) -> Self {
         self.interactivity().on_drag_move(listener);
         self
     }

crates/gpui/src/platform.rs 🔗

@@ -41,7 +41,6 @@ use std::borrow::Cow;
 use std::hash::{Hash, Hasher};
 use std::time::Duration;
 use std::{
-    any::Any,
     fmt::{self, Debug},
     ops::Range,
     path::{Path, PathBuf},
@@ -107,7 +106,6 @@ pub(crate) trait Platform: 'static {
 
     fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>>;
     fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>>;
-    fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>>;
     fn active_window(&self) -> Option<AnyWindowHandle>;
     fn open_window(
         &self,
@@ -129,11 +127,8 @@ pub(crate) trait Platform: 'static {
     fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Option<PathBuf>>;
     fn reveal_path(&self, path: &Path);
 
-    fn on_become_active(&self, callback: Box<dyn FnMut()>);
-    fn on_resign_active(&self, callback: Box<dyn FnMut()>);
     fn on_quit(&self, callback: Box<dyn FnMut()>);
     fn on_reopen(&self, callback: Box<dyn FnMut()>);
-    fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>);
 
     fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap);
     fn add_recent_document(&self, _path: &Path) {}
@@ -196,7 +191,6 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
     fn display(&self) -> Rc<dyn PlatformDisplay>;
     fn mouse_position(&self) -> Point<Pixels>;
     fn modifiers(&self) -> Modifiers;
-    fn as_any_mut(&mut self) -> &mut dyn Any;
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler);
     fn take_input_handler(&mut self) -> Option<PlatformInputHandler>;
     fn prompt(
@@ -221,12 +215,10 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
     fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>);
     fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>);
     fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>);
-    fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>);
     fn on_moved(&self, callback: Box<dyn FnMut()>);
     fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>);
     fn on_close(&self, callback: Box<dyn FnOnce()>);
     fn on_appearance_changed(&self, callback: Box<dyn FnMut()>);
-    fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool;
     fn draw(&self, scene: &Scene);
     fn completed_frame(&self) {}
     fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas>;
@@ -274,13 +266,6 @@ pub(crate) trait PlatformTextSystem: Send + Sync {
         raster_bounds: Bounds<DevicePixels>,
     ) -> Result<(Size<DevicePixels>, Vec<u8>)>;
     fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
-    fn wrap_line(
-        &self,
-        text: &str,
-        font_id: FontId,
-        font_size: Pixels,
-        width: Pixels,
-    ) -> Vec<usize>;
 }
 
 /// Basic metadata about the current application and operating system.
@@ -566,7 +551,6 @@ pub struct WindowOptions {
 /// The variables that can be configured when creating a new window
 #[derive(Debug)]
 pub(crate) struct WindowParams {
-    ///
     pub bounds: Bounds<DevicePixels>,
 
     /// The titlebar configuration of the window

crates/gpui/src/platform/cosmic_text/text_system.rs 🔗

@@ -176,17 +176,6 @@ impl PlatformTextSystem for CosmicTextSystem {
     fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
         self.0.write().layout_line(text, font_size, runs)
     }
-
-    // todo(linux) Confirm that this has been superseded by the LineWrapper
-    fn wrap_line(
-        &self,
-        _text: &str,
-        _font_id: FontId,
-        _font_size: Pixels,
-        _width: Pixels,
-    ) -> Vec<usize> {
-        unimplemented!()
-    }
 }
 
 impl CosmicTextSystemState {

crates/gpui/src/platform/linux/platform.rs 🔗

@@ -199,10 +199,6 @@ impl<P: LinuxClient + 'static> Platform for P {
         self.displays()
     }
 
-    fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
-        self.display(id)
-    }
-
     // todo(linux)
     fn active_window(&self) -> Option<AnyWindowHandle> {
         None
@@ -306,18 +302,6 @@ impl<P: LinuxClient + 'static> Platform for P {
         open::that(dir);
     }
 
-    fn on_become_active(&self, callback: Box<dyn FnMut()>) {
-        self.with_common(|common| {
-            common.callbacks.become_active = Some(callback);
-        });
-    }
-
-    fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
-        self.with_common(|common| {
-            common.callbacks.resign_active = Some(callback);
-        });
-    }
-
     fn on_quit(&self, callback: Box<dyn FnMut()>) {
         self.with_common(|common| {
             common.callbacks.quit = Some(callback);
@@ -330,12 +314,6 @@ impl<P: LinuxClient + 'static> Platform for P {
         });
     }
 
-    fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
-        self.with_common(|common| {
-            common.callbacks.event = Some(callback);
-        });
-    }
-
     fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
         self.with_common(|common| {
             common.callbacks.app_menu_action = Some(callback);

crates/gpui/src/platform/linux/wayland/window.rs 🔗

@@ -580,10 +580,6 @@ impl PlatformWindow for WaylandWindow {
         crate::Modifiers::default()
     }
 
-    fn as_any_mut(&mut self) -> &mut dyn Any {
-        self
-    }
-
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
         self.borrow_mut().input_handler = Some(input_handler);
     }
@@ -668,10 +664,6 @@ impl PlatformWindow for WaylandWindow {
         self.0.callbacks.borrow_mut().resize = Some(callback);
     }
 
-    fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
-        self.0.callbacks.borrow_mut().fullscreen = Some(callback);
-    }
-
     fn on_moved(&self, callback: Box<dyn FnMut()>) {
         self.0.callbacks.borrow_mut().moved = Some(callback);
     }
@@ -688,11 +680,6 @@ impl PlatformWindow for WaylandWindow {
         // todo(linux)
     }
 
-    // todo(linux)
-    fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool {
-        false
-    }
-
     fn draw(&self, scene: &Scene) {
         let mut state = self.borrow_mut();
         state.renderer.draw(scene);

crates/gpui/src/platform/linux/x11/window.rs 🔗

@@ -460,10 +460,6 @@ impl PlatformWindow for X11Window {
         Modifiers::default()
     }
 
-    fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
-        self
-    }
-
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
         self.0.state.borrow_mut().input_handler = Some(input_handler);
     }
@@ -587,10 +583,6 @@ impl PlatformWindow for X11Window {
         self.0.callbacks.borrow_mut().resize = Some(callback);
     }
 
-    fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
-        self.0.callbacks.borrow_mut().fullscreen = Some(callback);
-    }
-
     fn on_moved(&self, callback: Box<dyn FnMut()>) {
         self.0.callbacks.borrow_mut().moved = Some(callback);
     }
@@ -607,11 +599,6 @@ impl PlatformWindow for X11Window {
         self.0.callbacks.borrow_mut().appearance_changed = Some(callback);
     }
 
-    // todo(linux)
-    fn is_topmost_for_position(&self, _position: Point<Pixels>) -> bool {
-        unimplemented!()
-    }
-
     fn draw(&self, scene: &Scene) {
         let mut inner = self.0.state.borrow_mut();
         inner.renderer.draw(scene);

crates/gpui/src/platform/mac/platform.rs 🔗

@@ -1,9 +1,9 @@
 use super::{events::key_to_native, BoolExt};
 use crate::{
-    Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId,
-    ForegroundExecutor, Keymap, MacDispatcher, MacDisplay, MacTextSystem, MacWindow, Menu,
-    MenuItem, PathPromptOptions, Platform, PlatformDisplay, PlatformInput, PlatformTextSystem,
-    PlatformWindow, Result, SemanticVersion, Task, WindowAppearance, WindowParams,
+    Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor,
+    Keymap, MacDispatcher, MacDisplay, MacTextSystem, MacWindow, Menu, MenuItem, PathPromptOptions,
+    Platform, PlatformDisplay, PlatformInput, PlatformTextSystem, PlatformWindow, Result,
+    SemanticVersion, Task, WindowAppearance, WindowParams,
 };
 use anyhow::{anyhow, bail};
 use block::ConcreteBlock;
@@ -487,10 +487,6 @@ impl Platform for MacPlatform {
             .collect()
     }
 
-    fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
-        MacDisplay::find_by_id(id).map(|screen| Rc::new(screen) as Rc<_>)
-    }
-
     fn active_window(&self) -> Option<AnyWindowHandle> {
         MacWindow::active_window()
     }
@@ -679,14 +675,6 @@ impl Platform for MacPlatform {
         }
     }
 
-    fn on_become_active(&self, callback: Box<dyn FnMut()>) {
-        self.0.lock().become_active = Some(callback);
-    }
-
-    fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
-        self.0.lock().resign_active = Some(callback);
-    }
-
     fn on_quit(&self, callback: Box<dyn FnMut()>) {
         self.0.lock().quit = Some(callback);
     }
@@ -695,10 +683,6 @@ impl Platform for MacPlatform {
         self.0.lock().reopen = Some(callback);
     }
 
-    fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
-        self.0.lock().event = Some(callback);
-    }
-
     fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
         self.0.lock().menu_command = Some(callback);
     }

crates/gpui/src/platform/mac/text_system.rs 🔗

@@ -7,8 +7,7 @@ use anyhow::anyhow;
 use cocoa::appkit::{CGFloat, CGPoint};
 use collections::{BTreeSet, HashMap};
 use core_foundation::{
-    array::CFIndex,
-    attributed_string::{CFAttributedStringRef, CFMutableAttributedString},
+    attributed_string::CFMutableAttributedString,
     base::{CFRange, TCFType},
     number::CFNumber,
     string::CFString,
@@ -42,7 +41,7 @@ use pathfinder_geometry::{
     vector::{Vector2F, Vector2I},
 };
 use smallvec::SmallVec;
-use std::{borrow::Cow, char, cmp, convert::TryFrom, ffi::c_void, sync::Arc};
+use std::{borrow::Cow, char, cmp, convert::TryFrom, sync::Arc};
 
 use super::open_type;
 
@@ -186,16 +185,6 @@ impl PlatformTextSystem for MacTextSystem {
     fn layout_line(&self, text: &str, font_size: Pixels, font_runs: &[FontRun]) -> LineLayout {
         self.0.write().layout_line(text, font_size, font_runs)
     }
-
-    fn wrap_line(
-        &self,
-        text: &str,
-        font_id: FontId,
-        font_size: Pixels,
-        width: Pixels,
-    ) -> Vec<usize> {
-        self.0.read().wrap_line(text, font_id, font_size, width)
-    }
 }
 
 impl MacTextSystemState {
@@ -527,43 +516,6 @@ impl MacTextSystemState {
             len: text.len(),
         }
     }
-
-    fn wrap_line(
-        &self,
-        text: &str,
-        font_id: FontId,
-        font_size: Pixels,
-        width: Pixels,
-    ) -> Vec<usize> {
-        let mut string = CFMutableAttributedString::new();
-        string.replace_str(&CFString::new(text), CFRange::init(0, 0));
-        let cf_range = CFRange::init(0, text.encode_utf16().count() as isize);
-        let font = &self.fonts[font_id.0];
-        unsafe {
-            string.set_attribute(
-                cf_range,
-                kCTFontAttributeName,
-                &font.native_font().clone_with_font_size(font_size.into()),
-            );
-
-            let typesetter = CTTypesetterCreateWithAttributedString(string.as_concrete_TypeRef());
-            let mut ix_converter = StringIndexConverter::new(text);
-            let mut break_indices = Vec::new();
-            while ix_converter.utf8_ix < text.len() {
-                let utf16_len = CTTypesetterSuggestLineBreak(
-                    typesetter,
-                    ix_converter.utf16_ix as isize,
-                    width.into(),
-                ) as usize;
-                ix_converter.advance_to_utf16_ix(ix_converter.utf16_ix + utf16_len);
-                if ix_converter.utf8_ix >= text.len() {
-                    break;
-                }
-                break_indices.push(ix_converter.utf8_ix);
-            }
-            break_indices
-        }
-    }
 }
 
 #[derive(Clone)]
@@ -605,22 +557,6 @@ impl<'a> StringIndexConverter<'a> {
     }
 }
 
-#[repr(C)]
-pub(crate) struct __CFTypesetter(c_void);
-
-type CTTypesetterRef = *const __CFTypesetter;
-
-#[link(name = "CoreText", kind = "framework")]
-extern "C" {
-    fn CTTypesetterCreateWithAttributedString(string: CFAttributedStringRef) -> CTTypesetterRef;
-
-    fn CTTypesetterSuggestLineBreak(
-        typesetter: CTTypesetterRef,
-        start_index: CFIndex,
-        width: f64,
-    ) -> CFIndex;
-}
-
 impl From<Metrics> for FontMetrics {
     fn from(metrics: Metrics) -> Self {
         FontMetrics {
@@ -741,23 +677,6 @@ mod lenient_font_attributes {
 mod tests {
     use crate::{font, px, FontRun, GlyphId, MacTextSystem, PlatformTextSystem};
 
-    #[test]
-    fn test_wrap_line() {
-        let fonts = MacTextSystem::new();
-        let font_id = fonts.font_id(&font("Helvetica")).unwrap();
-
-        let line = "one two three four five\n";
-        let wrap_boundaries = fonts.wrap_line(line, font_id, px(16.), px(64.0));
-        assert_eq!(wrap_boundaries, &["one two ".len(), "one two three ".len()]);
-
-        let line = "aaa ααα ✋✋✋ 🎉🎉🎉\n";
-        let wrap_boundaries = fonts.wrap_line(line, font_id, px(16.), px(64.0));
-        assert_eq!(
-            wrap_boundaries,
-            &["aaa ααα ".len(), "aaa ααα ✋✋✋ ".len(),]
-        );
-    }
-
     #[test]
     fn test_layout_line_bom_char() {
         let fonts = MacTextSystem::new();

crates/gpui/src/platform/mac/window.rs 🔗

@@ -34,7 +34,6 @@ use parking_lot::Mutex;
 use raw_window_handle as rwh;
 use smallvec::SmallVec;
 use std::{
-    any::Any,
     cell::Cell,
     ffi::{c_void, CStr},
     mem,
@@ -504,16 +503,6 @@ impl MacWindowState {
             px((frame.size.height - content_layout_rect.size.height) as f32)
         }
     }
-
-    fn to_screen_ns_point(&self, point: Point<Pixels>) -> NSPoint {
-        unsafe {
-            let point = NSPoint::new(
-                point.x.into(),
-                (self.content_size().height - point.y).into(),
-            );
-            msg_send![self.native_window, convertPointToScreen: point]
-        }
-    }
 }
 
 unsafe impl Send for MacWindowState {}
@@ -863,10 +852,6 @@ impl PlatformWindow for MacWindow {
         }
     }
 
-    fn as_any_mut(&mut self) -> &mut dyn Any {
-        self
-    }
-
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
         self.0.as_ref().lock().input_handler = Some(input_handler);
     }
@@ -1102,10 +1087,6 @@ impl PlatformWindow for MacWindow {
         self.0.as_ref().lock().resize_callback = Some(callback);
     }
 
-    fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
-        self.0.as_ref().lock().fullscreen_callback = Some(callback);
-    }
-
     fn on_moved(&self, callback: Box<dyn FnMut()>) {
         self.0.as_ref().lock().moved_callback = Some(callback);
     }
@@ -1122,31 +1103,6 @@ impl PlatformWindow for MacWindow {
         self.0.lock().appearance_changed_callback = Some(callback);
     }
 
-    fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool {
-        let self_borrow = self.0.lock();
-        let self_handle = self_borrow.handle;
-
-        unsafe {
-            let app = NSApplication::sharedApplication(nil);
-
-            // Convert back to screen coordinates
-            let screen_point = self_borrow.to_screen_ns_point(position);
-
-            let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:screen_point belowWindowWithWindowNumber:0];
-            let top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];
-
-            let is_panel: BOOL = msg_send![top_most_window, isKindOfClass: PANEL_CLASS];
-            let is_window: BOOL = msg_send![top_most_window, isKindOfClass: WINDOW_CLASS];
-            if is_panel == YES || is_window == YES {
-                let topmost_window = get_window_state(&*top_most_window).lock().handle;
-                topmost_window == self_handle
-            } else {
-                // Someone else's window is on top
-                false
-            }
-        }
-    }
-
     fn draw(&self, scene: &crate::Scene) {
         let mut this = self.0.lock();
         this.renderer.draw(scene);

crates/gpui/src/platform/test/platform.rs 🔗

@@ -1,7 +1,7 @@
 use crate::{
-    AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId, ForegroundExecutor,
-    Keymap, Platform, PlatformDisplay, PlatformTextSystem, Task, TestDisplay, TestWindow,
-    WindowAppearance, WindowParams,
+    AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor, Keymap,
+    Platform, PlatformDisplay, PlatformTextSystem, Task, TestDisplay, TestWindow, WindowAppearance,
+    WindowParams,
 };
 use anyhow::{anyhow, Result};
 use collections::VecDeque;
@@ -90,7 +90,7 @@ impl TestPlatform {
     pub(crate) fn set_active_window(&self, window: Option<TestWindow>) {
         let executor = self.foreground_executor().clone();
         let previous_window = self.active_window.borrow_mut().take();
-        *self.active_window.borrow_mut() = window.clone();
+        self.active_window.borrow_mut().clone_from(&window);
 
         executor
             .spawn(async move {
@@ -168,10 +168,6 @@ impl Platform for TestPlatform {
         Some(self.active_display.clone())
     }
 
-    fn display(&self, id: DisplayId) -> Option<std::rc::Rc<dyn crate::PlatformDisplay>> {
-        self.displays().iter().find(|d| d.id() == id).cloned()
-    }
-
     fn active_window(&self) -> Option<crate::AnyWindowHandle> {
         self.active_window
             .borrow()
@@ -228,20 +224,12 @@ impl Platform for TestPlatform {
         unimplemented!()
     }
 
-    fn on_become_active(&self, _callback: Box<dyn FnMut()>) {}
-
-    fn on_resign_active(&self, _callback: Box<dyn FnMut()>) {}
-
     fn on_quit(&self, _callback: Box<dyn FnMut()>) {}
 
     fn on_reopen(&self, _callback: Box<dyn FnMut()>) {
         unimplemented!()
     }
 
-    fn on_event(&self, _callback: Box<dyn FnMut(crate::PlatformInput) -> bool>) {
-        unimplemented!()
-    }
-
     fn set_menus(&self, _menus: Vec<crate::Menu>, _keymap: &Keymap) {}
 
     fn add_recent_document(&self, _paths: &Path) {}

crates/gpui/src/platform/test/text_system.rs 🔗

@@ -47,13 +47,4 @@ impl PlatformTextSystem for TestTextSystem {
     fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
         unimplemented!()
     }
-    fn wrap_line(
-        &self,
-        text: &str,
-        font_id: FontId,
-        font_size: Pixels,
-        width: Pixels,
-    ) -> Vec<usize> {
-        unimplemented!()
-    }
 }

crates/gpui/src/platform/test/window.rs 🔗

@@ -144,10 +144,6 @@ impl PlatformWindow for TestWindow {
         crate::Modifiers::default()
     }
 
-    fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
-        self
-    }
-
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
         self.0.lock().input_handler = Some(input_handler);
     }
@@ -235,10 +231,6 @@ impl PlatformWindow for TestWindow {
         self.0.lock().resize_callback = Some(callback)
     }
 
-    fn on_fullscreen(&self, _callback: Box<dyn FnMut(bool)>) {
-        unimplemented!()
-    }
-
     fn on_moved(&self, callback: Box<dyn FnMut()>) {
         self.0.lock().moved_callback = Some(callback)
     }
@@ -251,10 +243,6 @@ impl PlatformWindow for TestWindow {
 
     fn on_appearance_changed(&self, _callback: Box<dyn FnMut()>) {}
 
-    fn is_topmost_for_position(&self, _position: crate::Point<Pixels>) -> bool {
-        unimplemented!()
-    }
-
     fn draw(&self, _scene: &crate::Scene) {}
 
     fn sprite_atlas(&self) -> sync::Arc<dyn crate::PlatformAtlas> {

crates/gpui/src/platform/windows/direct_write.rs 🔗

@@ -182,16 +182,6 @@ impl PlatformTextSystem for DirectWriteTextSystem {
     fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
         self.0.write().layout_line(text, font_size, runs)
     }
-
-    fn wrap_line(
-        &self,
-        _text: &str,
-        _font_id: FontId,
-        _font_size: Pixels,
-        _width: Pixels,
-    ) -> Vec<usize> {
-        unimplemented!()
-    }
 }
 
 impl DirectWriteState {

crates/gpui/src/platform/windows/platform.rs 🔗

@@ -342,14 +342,6 @@ impl Platform for WindowsPlatform {
         WindowsDisplay::displays()
     }
 
-    fn display(&self, id: crate::DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
-        if let Some(display) = WindowsDisplay::new(id) {
-            Some(Rc::new(display) as Rc<dyn PlatformDisplay>)
-        } else {
-            None
-        }
-    }
-
     fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>> {
         if let Some(display) = WindowsDisplay::primary_monitor() {
             Some(Rc::new(display) as Rc<dyn PlatformDisplay>)
@@ -511,14 +503,6 @@ impl Platform for WindowsPlatform {
             .detach();
     }
 
-    fn on_become_active(&self, callback: Box<dyn FnMut()>) {
-        self.inner.callbacks.lock().become_active = Some(callback);
-    }
-
-    fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
-        self.inner.callbacks.lock().resign_active = Some(callback);
-    }
-
     fn on_quit(&self, callback: Box<dyn FnMut()>) {
         self.inner.callbacks.lock().quit = Some(callback);
     }
@@ -527,10 +511,6 @@ impl Platform for WindowsPlatform {
         self.inner.callbacks.lock().reopen = Some(callback);
     }
 
-    fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
-        self.inner.callbacks.lock().event = Some(callback);
-    }
-
     // todo(windows)
     fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {}
 

crates/gpui/src/platform/windows/window.rs 🔗

@@ -1,7 +1,6 @@
 #![deny(unsafe_op_in_unsafe_fn)]
 
 use std::{
-    any::Any,
     cell::{Cell, RefCell},
     iter::once,
     num::NonZeroIsize,
@@ -1408,10 +1407,6 @@ impl PlatformWindow for WindowsWindow {
         Modifiers::none()
     }
 
-    fn as_any_mut(&mut self) -> &mut dyn Any {
-        self
-    }
-
     // todo(windows)
     fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
         self.inner.input_handler.set(Some(input_handler));
@@ -1566,11 +1561,6 @@ impl PlatformWindow for WindowsWindow {
         self.inner.callbacks.borrow_mut().resize = Some(callback);
     }
 
-    // todo(windows)
-    fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
-        self.inner.callbacks.borrow_mut().fullscreen = Some(callback);
-    }
-
     // todo(windows)
     fn on_moved(&self, callback: Box<dyn FnMut()>) {
         self.inner.callbacks.borrow_mut().moved = Some(callback);
@@ -1591,11 +1581,6 @@ impl PlatformWindow for WindowsWindow {
         self.inner.callbacks.borrow_mut().appearance_changed = Some(callback);
     }
 
-    // todo(windows)
-    fn is_topmost_for_position(&self, _position: Point<Pixels>) -> bool {
-        true
-    }
-
     // todo(windows)
     fn draw(&self, scene: &Scene) {
         self.inner.renderer.borrow_mut().draw(scene)

crates/gpui/src/window.rs 🔗

@@ -1430,8 +1430,12 @@ impl<'a> WindowContext<'a> {
         let mut deferred_draws = mem::take(&mut self.window.next_frame.deferred_draws);
         for deferred_draw_ix in deferred_draw_indices {
             let deferred_draw = &mut deferred_draws[*deferred_draw_ix];
-            self.window.element_id_stack = deferred_draw.element_id_stack.clone();
-            self.window.text_style_stack = deferred_draw.text_style_stack.clone();
+            self.window
+                .element_id_stack
+                .clone_from(&deferred_draw.element_id_stack);
+            self.window
+                .text_style_stack
+                .clone_from(&deferred_draw.text_style_stack);
             self.window
                 .next_frame
                 .dispatch_tree
@@ -1464,7 +1468,9 @@ impl<'a> WindowContext<'a> {
         let mut deferred_draws = mem::take(&mut self.window.next_frame.deferred_draws);
         for deferred_draw_ix in deferred_draw_indices {
             let mut deferred_draw = &mut deferred_draws[*deferred_draw_ix];
-            self.window.element_id_stack = deferred_draw.element_id_stack.clone();
+            self.window
+                .element_id_stack
+                .clone_from(&deferred_draw.element_id_stack);
             self.window
                 .next_frame
                 .dispatch_tree

crates/language/src/buffer.rs 🔗

@@ -2072,7 +2072,7 @@ impl Buffer {
 
     /// Override current completion triggers with the user-provided completion triggers.
     pub fn set_completion_triggers(&mut self, triggers: Vec<String>, cx: &mut ModelContext<Self>) {
-        self.completion_triggers = triggers.clone();
+        self.completion_triggers.clone_from(&triggers);
         self.completion_triggers_timestamp = self.text.lamport_clock.tick();
         self.send_operation(
             Operation::UpdateCompletionTriggers {

crates/language/src/language.rs 🔗

@@ -1126,7 +1126,7 @@ impl Language {
                 for setting in query.property_settings(ix) {
                     match setting.key.as_ref() {
                         "language" => {
-                            config.language = setting.value.clone();
+                            config.language.clone_from(&setting.value);
                         }
                         "combined" => {
                             config.combined = true;

crates/language/src/outline.rs 🔗

@@ -82,7 +82,7 @@ impl<T> Outline<T> {
         let mut prev_item_ix = 0;
         for mut string_match in matches {
             let outline_match = &self.items[string_match.candidate_id];
-            string_match.string = outline_match.text.clone();
+            string_match.string.clone_from(&outline_match.text);
 
             if is_path_query {
                 let prefix_len = self.path_candidate_prefixes[string_match.candidate_id];

crates/live_kit_server/build.rs 🔗

@@ -1,5 +1,6 @@
 fn main() {
     prost_build::Config::new()
+        .type_attribute("SendDataResponse", "#[allow(clippy::empty_docs)]")
         .compile_protos(&["protocol/livekit_room.proto"], &["protocol"])
         .unwrap();
 }

crates/search/src/buffer_search.rs 🔗

@@ -426,10 +426,6 @@ impl ToolbarItemView for BufferSearchBar {
         }
         ToolbarItemLocation::Hidden
     }
-
-    fn row_count(&self, _: &WindowContext<'_>) -> usize {
-        1
-    }
 }
 
 impl BufferSearchBar {

crates/search/src/project_search.rs 🔗

@@ -1629,15 +1629,6 @@ impl ToolbarItemView for ProjectSearchBar {
             ToolbarItemLocation::Hidden
         }
     }
-
-    fn row_count(&self, cx: &WindowContext<'_>) -> usize {
-        if let Some(search) = self.active_project_search.as_ref() {
-            if search.read(cx).filters_enabled {
-                return 2;
-            }
-        }
-        1
-    }
 }
 
 fn register_workspace_action<A: Action>(

crates/theme/src/settings.rs 🔗

@@ -441,7 +441,7 @@ impl settings::Settings for ThemeSettings {
                 }
             }
 
-            this.theme_overrides = value.theme_overrides.clone();
+            this.theme_overrides.clone_from(&value.theme_overrides);
             this.apply_theme_overrides();
 
             merge(&mut this.ui_font_size, value.ui_font_size.map(Into::into));

crates/theme_importer/src/util.rs 🔗

@@ -1,11 +0,0 @@
-use anyhow::Result;
-
-pub trait Traverse<T, U> {
-    fn traverse(self, f: impl FnOnce(T) -> Result<U>) -> Result<Option<U>>;
-}
-
-impl<T, U> Traverse<T, U> for Option<T> {
-    fn traverse(self, f: impl FnOnce(T) -> Result<U>) -> Result<Option<U>> {
-        self.map_or(Ok(None), |value| f(value).map(Some))
-    }
-}

crates/workspace/src/toolbar.rs 🔗

@@ -18,13 +18,6 @@ pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {
     ) -> ToolbarItemLocation;
 
     fn pane_focus_update(&mut self, _pane_focused: bool, _cx: &mut ViewContext<Self>) {}
-
-    /// Number of times toolbar's height will be repeated to get the effective height.
-    /// Useful when multiple rows one under each other are needed.
-    /// The rows have the same width and act as a whole when reacting to resizes and similar events.
-    fn row_count(&self, _cx: &WindowContext) -> usize {
-        1
-    }
 }
 
 trait ToolbarItemViewHandle: Send {
@@ -36,7 +29,6 @@ trait ToolbarItemViewHandle: Send {
         cx: &mut WindowContext,
     ) -> ToolbarItemLocation;
     fn focus_changed(&mut self, pane_focused: bool, cx: &mut WindowContext);
-    fn row_count(&self, cx: &WindowContext) -> usize;
 }
 
 #[derive(Copy, Clone, Debug, PartialEq)]
@@ -239,8 +231,4 @@ impl<T: ToolbarItemView> ToolbarItemViewHandle for View<T> {
             cx.notify();
         });
     }
-
-    fn row_count(&self, cx: &WindowContext) -> usize {
-        self.read(cx).row_count(cx)
-    }
 }

crates/workspace/src/workspace.rs 🔗

@@ -3322,7 +3322,7 @@ impl Workspace {
         }
 
         if &update.id != &self.last_active_view_id {
-            self.last_active_view_id = update.id.clone();
+            self.last_active_view_id.clone_from(&update.id);
             self.update_followers(
                 is_project_item,
                 proto::update_followers::Variant::UpdateActiveView(update),

crates/zed/src/reliability.rs 🔗

@@ -524,7 +524,7 @@ async fn upload_previous_crashes(
             }
 
             if uploaded < filename {
-                uploaded = filename.clone();
+                uploaded.clone_from(&filename);
                 KEY_VALUE_STORE
                     .write_kvp(LAST_CRASH_UPLOADED.to_string(), filename)
                     .await?;

rust-toolchain.toml 🔗

@@ -1,5 +1,5 @@
 [toolchain]
-channel = "1.77"
+channel = "1.78"
 profile = "minimal"
 components = [ "rustfmt", "clippy" ]
 targets = [ "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "wasm32-wasi" ]