Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Enable `clippy::useless_conversion` (#8767)
Marshall Bowersfe04f69caff9
diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rsindex fcc033ef965..97f0bca0830 100644--- a/crates/assistant/src/assistant_panel.rs+++ b/crates/assistant/src/assistant_panel.rs@@ -979,7 +979,7 @@ impl AssistantPanel {font_size: rems(0.875).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,@@ -1633,7 +1633,6 @@ impl Conversation {fn count_remaining_tokens(&mut self, cx: &mut ModelContext<Self>) {let messages = self.messages(cx)- .into_iter().map(|message| tiktoken_rs::ChatCompletionRequestMessage {role: match message.role {Role::User => "user".into(),@@ -3199,7 +3198,7 @@ impl InlineAssistant {font_size: rems(0.875).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,diff --git a/crates/collab/src/api/ips_file.rs b/crates/collab/src/api/ips_file.rsindex 6f1b4cd8f40..cbbf042abf9 100644--- a/crates/collab/src/api/ips_file.rs+++ b/crates/collab/src/api/ips_file.rs@@ -45,7 +45,7 @@ impl IpsFile {pub fn description(&self, panic: Option<&str>) -> String {let mut desc = if self.body.termination.indicator == "Abort trap: 6" {match panic {- Some(panic_message) => format!("Panic `{}`", panic_message).into(),+ Some(panic_message) => format!("Panic `{}`", panic_message),None => "Crash `Abort trap: 6` (possible panic)".into(),}} else if let Some(msg) = &self.body.exception.message {diff --git a/crates/collab/src/db/queries/rooms.rs b/crates/collab/src/db/queries/rooms.rsindex c3a0735a379..cd960ec5a7e 100644--- a/crates/collab/src/db/queries/rooms.rs+++ b/crates/collab/src/db/queries/rooms.rs@@ -1021,7 +1021,7 @@ impl Database {.add(room_participant::Column::UserId.eq(user_id)),).set(room_participant::ActiveModel {- role: ActiveValue::set(Some(ChannelRole::from(role))),+ role: ActiveValue::set(Some(role)),..Default::default()}).exec(&*tx)diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex 28f16e17638..60388928c69 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -2883,7 +2883,7 @@ async fn update_channel_buffer(.flat_map(|user_id| pool.user_connection_ids(*user_id)),|peer_id| {session.peer.send(- peer_id.into(),+ peer_id,proto::UpdateChannels {latest_channel_buffer_versions: vec![proto::ChannelBufferVersion {channel_id: channel_id.to_proto(),@@ -2968,8 +2968,8 @@ fn channel_buffer_updated<T: EnvelopedMessage>(message: &T,peer: &Peer,) {- broadcast(Some(sender_id), collaborators.into_iter(), |peer_id| {- peer.send(peer_id.into(), message.clone())+ broadcast(Some(sender_id), collaborators, |peer_id| {+ peer.send(peer_id, message.clone())});}@@ -3074,7 +3074,7 @@ async fn send_channel_message(.flat_map(|user_id| pool.user_connection_ids(*user_id)),|peer_id| {session.peer.send(- peer_id.into(),+ peer_id,proto::UpdateChannels {latest_channel_message_ids: vec![proto::ChannelMessageId {channel_id: channel_id.to_proto(),@@ -3447,7 +3447,7 @@ fn room_updated(room: &proto::Room, peer: &Peer) {.filter_map(|participant| Some(participant.peer_id?.into())),|peer_id| {peer.send(- peer_id.into(),+ peer_id,proto::RoomUpdated {room: Some(room.clone()),},@@ -3476,7 +3476,7 @@ fn channel_updated(.flat_map(|user_id| pool.user_connection_ids(*user_id)),|peer_id| {peer.send(- peer_id.into(),+ peer_id,proto::UpdateChannels {channel_participants: vec![proto::ChannelParticipants {channel_id: channel_id.to_proto(),diff --git a/crates/collab/src/tests/channel_tests.rs b/crates/collab/src/tests/channel_tests.rsindex 9d2f3333041..14b0a874857 100644--- a/crates/collab/src/tests/channel_tests.rs+++ b/crates/collab/src/tests/channel_tests.rs@@ -1431,7 +1431,7 @@ fn assert_channels(.ordered_channels().map(|(depth, channel)| ExpectedChannel {depth,- name: channel.name.clone().into(),+ name: channel.name.clone(),id: channel.id,}).collect::<Vec<_>>()diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rsindex 9bf92e87f28..50a798b5a65 100644--- a/crates/collab/src/tests/editor_tests.rs+++ b/crates/collab/src/tests/editor_tests.rs@@ -833,7 +833,7 @@ async fn test_language_server_statuses(cx_a: &mut TestAppContext, cx_b: &mut Teslet mut fake_language_servers = client_a.language_registry().register_fake_lsp_adapter("Rust",FakeLspAdapter {- name: "the-language-server".into(),+ name: "the-language-server",..Default::default()},);diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rsindex 0f0717326af..21c49c97ddf 100644--- a/crates/collab_ui/src/chat_panel/message_editor.rs+++ b/crates/collab_ui/src/chat_panel/message_editor.rs@@ -357,7 +357,7 @@ impl Render for MessageEditor {font_size: UiTextSize::Small.rems().into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex 54591bd5dea..1df8e7e73bd 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -2171,7 +2171,7 @@ impl CollabPanel {font_size: rems(0.875).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,diff --git a/crates/copilot_ui/src/copilot_button.rs b/crates/copilot_ui/src/copilot_button.rsindex 818053b09e6..dca74113885 100644--- a/crates/copilot_ui/src/copilot_button.rs+++ b/crates/copilot_ui/src/copilot_button.rs@@ -311,7 +311,7 @@ async fn configure_disabled_globs(fn toggle_copilot_globally(fs: Arc<dyn Fs>, cx: &mut AppContext) {let show_copilot_suggestions = all_language_settings(None, cx).copilot_enabled(None, None);update_settings_file::<AllLanguageSettings>(fs, cx, move |file| {- file.defaults.show_copilot_suggestions = Some((!show_copilot_suggestions).into())+ file.defaults.show_copilot_suggestions = Some(!show_copilot_suggestions)});}diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rsindex 793d5aa269c..94e78390d69 100644--- a/crates/diagnostics/src/diagnostics.rs+++ b/crates/diagnostics/src/diagnostics.rs@@ -797,7 +797,7 @@ impl Item for ProjectDiagnosticsEditor {fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {let (message, code_ranges) = highlight_diagnostic_message(&diagnostic);- let message: SharedString = message.into();+ let message: SharedString = message;Arc::new(move |cx| {let highlight_style: HighlightStyle = cx.theme().colors().text_accent.into();h_flex()diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rsindex 67eea85bdc6..e55df06d7f9 100644--- a/crates/editor/src/display_map.rs+++ b/crates/editor/src/display_map.rs@@ -502,7 +502,7 @@ impl DisplaySnapshot {/// Returns text chunks starting at the end of the given display row in reverse until the start of the filepub fn reverse_text_chunks(&self, display_row: u32) -> impl Iterator<Item = &str> {- (0..=display_row).into_iter().rev().flat_map(|row| {+ (0..=display_row).rev().flat_map(|row| {self.block_snapshot.chunks(row..row + 1, false, Highlights::default()).map(|h| h.text)@@ -1455,10 +1455,8 @@ pub mod tests {}"#.unindent();- let theme = SyntaxTheme::new_test(vec![- ("mod.body", Hsla::red().into()),- ("fn.name", Hsla::blue().into()),- ]);+ let theme =+ SyntaxTheme::new_test(vec![("mod.body", Hsla::red()), ("fn.name", Hsla::blue())]);let language = Arc::new(Language::new(LanguageConfig {@@ -1545,10 +1543,8 @@ pub mod tests {}"#.unindent();- let theme = SyntaxTheme::new_test(vec![- ("mod.body", Hsla::red().into()),- ("fn.name", Hsla::blue().into()),- ]);+ let theme =+ SyntaxTheme::new_test(vec![("mod.body", Hsla::red()), ("fn.name", Hsla::blue())]);let language = Arc::new(Language::new(LanguageConfig {@@ -1616,10 +1612,8 @@ pub mod tests {async fn test_chunks_with_text_highlights(cx: &mut gpui::TestAppContext) {cx.update(|cx| init_test(cx, |_| {}));- let theme = SyntaxTheme::new_test(vec![- ("operator", Hsla::red().into()),- ("string", Hsla::green().into()),- ]);+ let theme =+ SyntaxTheme::new_test(vec![("operator", Hsla::red()), ("string", Hsla::green())]);let language = Arc::new(Language::new(LanguageConfig {diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 49d6c4d44c3..7823140a12c 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -2004,7 +2004,7 @@ impl EditorElement {let text_width = bounds.size.width - gutter_dimensions.width;let overscroll = size(em_width, px(0.));let _snapshot = {- editor.set_visible_line_count((bounds.size.height / line_height).into(), cx);+ editor.set_visible_line_count(bounds.size.height / line_height, cx);let editor_width = text_width - gutter_dimensions.margin - overscroll.width - em_width;let wrap_width = match editor.soft_wrap_mode(cx) {@@ -2037,7 +2037,7 @@ impl EditorElement {// The scroll position is a fractional point, the whole number of which represents// the top of the window in terms of display rows.let start_row = scroll_position.y as u32;- let height_in_lines = f32::from(bounds.size.height / line_height);+ let height_in_lines = bounds.size.height / line_height;let max_row = snapshot.max_point().row();// Add 1 to ensure selections bleed off screen@@ -2262,7 +2262,7 @@ impl EditorElement {});let scroll_max = point(- f32::from((scroll_width - text_size.width) / em_width).max(0.0),+ ((scroll_width - text_size.width) / em_width).max(0.0),max_row as f32,);@@ -2722,11 +2722,8 @@ impl EditorElement {};let scroll_position = position_map.snapshot.scroll_position();- let x = f32::from(- (scroll_position.x * max_glyph_width - delta.x) / max_glyph_width,- );- let y =- f32::from((scroll_position.y * line_height - delta.y) / line_height);+ let x = (scroll_position.x * max_glyph_width - delta.x) / max_glyph_width;+ let y = (scroll_position.y * line_height - delta.y) / line_height;let scroll_position =point(x, y).clamp(&point(0., 0.), &position_map.scroll_max);editor.scroll(scroll_position, axis, cx);@@ -3268,7 +3265,7 @@ impl PositionMap {let position = position - text_bounds.origin;let y = position.y.max(px(0.)).min(self.size.height);let x = position.x + (scroll_position.x * self.em_width);- let row = (f32::from(y / self.line_height) + scroll_position.y) as u32;+ let row = ((y / self.line_height) + scroll_position.y) as u32;let (column, x_overshoot_after_line_end) = if let Some(line) = self.line_layoutsdiff --git a/crates/editor/src/rust_analyzer_ext.rs b/crates/editor/src/rust_analyzer_ext.rsindex 31622a8c5e1..1a950e0ea46 100644--- a/crates/editor/src/rust_analyzer_ext.rs+++ b/crates/editor/src/rust_analyzer_ext.rs@@ -62,7 +62,6 @@ pub fn expand_macro_recursively(project.read(cx).language_servers_for_buffer(buffer.read(cx), cx)- .into_iter().find_map(|(adapter, server)| {if adapter.name.0.as_ref() == "rust-analyzer" {Some((diff --git a/crates/editor/src/scroll/autoscroll.rs b/crates/editor/src/scroll/autoscroll.rsindex 191dbd04dcc..3dfe2d250aa 100644--- a/crates/editor/src/scroll/autoscroll.rs+++ b/crates/editor/src/scroll/autoscroll.rs@@ -62,7 +62,7 @@ impl Editor {line_height: Pixels,cx: &mut ViewContext<Editor>,) -> bool {- let visible_lines = f32::from(viewport_height / line_height);+ let visible_lines = viewport_height / line_height;let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));let mut scroll_position = self.scroll_manager.scroll_position(&display_map);let max_scroll_top = if matches!(self.mode, EditorMode::AutoHeight { .. }) {@@ -241,11 +241,10 @@ impl Editor {let scroll_right = scroll_left + viewport_width;if target_left < scroll_left {- self.scroll_manager.anchor.offset.x = (target_left / max_glyph_width).into();+ self.scroll_manager.anchor.offset.x = target_left / max_glyph_width;true} else if target_right > scroll_right {- self.scroll_manager.anchor.offset.x =- ((target_right - viewport_width) / max_glyph_width).into();+ self.scroll_manager.anchor.offset.x = (target_right - viewport_width) / max_glyph_width;true} else {falsediff --git a/crates/extension/src/extension_lsp_adapter.rs b/crates/extension/src/extension_lsp_adapter.rsindex 7e3cc9cdc5c..a981facef08 100644--- a/crates/extension/src/extension_lsp_adapter.rs+++ b/crates/extension/src/extension_lsp_adapter.rs@@ -52,7 +52,7 @@ impl LspAdapter for ExtensionLspAdapter {.map_err(|e| anyhow!("{}", e))?;Ok(LanguageServerBinary {- path: self.work_dir.join(&command.command).into(),+ path: self.work_dir.join(&command.command),arguments: command.args.into_iter().map(|arg| arg.into()).collect(),env: Some(command.env.into_iter().collect()),})diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rsindex 45778c85d69..cd07f8244e3 100644--- a/crates/extensions_ui/src/extensions_ui.rs+++ b/crates/extensions_ui/src/extensions_ui.rs@@ -368,7 +368,7 @@ impl ExtensionsPage {font_size: rems(0.875).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rsindex 6ceff76c381..2b7d170e046 100644--- a/crates/gpui/src/app/test_context.rs+++ b/crates/gpui/src/app/test_context.rs@@ -335,7 +335,7 @@ impl TestAppContext {.map(Keystroke::parse).map(Result::unwrap){- self.dispatch_keystroke(window, keystroke.into());+ self.dispatch_keystroke(window, keystroke);}self.background_executor.run_until_parked()@@ -347,7 +347,7 @@ impl TestAppContext {/// This will also run the background executor until it's parked.pub fn simulate_input(&mut self, window: AnyWindowHandle, input: &str) {for keystroke in input.split("").map(Keystroke::parse).map(Result::unwrap) {- self.dispatch_keystroke(window, keystroke.into());+ self.dispatch_keystroke(window, keystroke);}self.background_executor.run_until_parked()diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rsindex 9c38fe8611d..e517a9f092d 100644--- a/crates/language/src/syntax_map.rs+++ b/crates/language/src/syntax_map.rs@@ -766,7 +766,7 @@ impl SyntaxSnapshot {SyntaxMapCaptures::new(range.clone(),buffer.as_rope(),- self.layers_for_range(range, buffer).into_iter(),+ self.layers_for_range(range, buffer),query,)}@@ -780,7 +780,7 @@ impl SyntaxSnapshot {SyntaxMapMatches::new(range.clone(),buffer.as_rope(),- self.layers_for_range(range, buffer).into_iter(),+ self.layers_for_range(range, buffer),query,)}diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rsindex 2b0296fc305..50eb958987d 100644--- a/crates/markdown_preview/src/markdown_preview_view.rs+++ b/crates/markdown_preview/src/markdown_preview_view.rs@@ -132,7 +132,7 @@ impl MarkdownPreviewView {workspace,contents,list_state,- tab_description: tab_description.into(),+ tab_description: tab_description,}})}diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rsindex 627c4a0de24..0a8b9a08ec5 100644--- a/crates/outline/src/outline.rs+++ b/crates/outline/src/outline.rs@@ -279,7 +279,7 @@ impl PickerDelegate for OutlineViewDelegate {font_size: settings.buffer_font_size(cx).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.).into(),+ line_height: relative(1.),background_color: None,underline: None,strikethrough: None,diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rsindex c2cfd9713a3..14a8ae7e9c9 100644--- a/crates/recent_projects/src/recent_projects.rs+++ b/crates/recent_projects/src/recent_projects.rs@@ -536,7 +536,7 @@ mod tests {!cx.has_pending_prompt(),"Should have no pending prompt on dirty project before opening the new recent project");- cx.dispatch_action((*workspace).into(), menu::Confirm);+ cx.dispatch_action(*workspace, menu::Confirm);workspace.update(cx, |workspace, cx| {assert!(diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex 1cb5af4b7ed..7d7626dd2f5 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -98,7 +98,7 @@ impl BufferSearchBar {font_size: rems(0.875).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex c2c3a9734de..b26e4193d2f 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -1631,7 +1631,7 @@ impl ProjectSearchBar {font_size: rems(0.875).into(),font_weight: FontWeight::NORMAL,font_style: FontStyle::Normal,- line_height: relative(1.3).into(),+ line_height: relative(1.3),background_color: None,underline: None,strikethrough: None,diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rsindex ec3503d2282..bb388a35107 100644--- a/crates/terminal/src/terminal.rs+++ b/crates/terminal/src/terminal.rs@@ -158,11 +158,11 @@ impl TerminalSize {}pub fn num_lines(&self) -> usize {- f32::from((self.size.height / self.line_height).floor()) as usize+ (self.size.height / self.line_height).floor() as usize}pub fn num_columns(&self) -> usize {- f32::from((self.size.width / self.cell_width).floor()) as usize+ (self.size.width / self.cell_width).floor() as usize}pub fn height(&self) -> Pixels {@@ -1663,9 +1663,9 @@ mod tests {fn get_cells(size: TerminalSize, rng: &mut ThreadRng) -> Vec<Vec<char>> {let mut cells = Vec::new();- for _ in 0..(f32::from(size.height() / size.line_height()) as usize) {+ for _ in 0..((size.height() / size.line_height()) as usize) {let mut row_vec = Vec::new();- for _ in 0..(f32::from(size.width() / size.cell_width()) as usize) {+ for _ in 0..((size.width() / size.cell_width()) as usize) {let cell_char = rng.sample(Alphanumeric) as char;row_vec.push(cell_char)}diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rsindex 0b138129c94..d8623d9c750 100644--- a/crates/vim/src/command.rs+++ b/crates/vim/src/command.rs@@ -358,7 +358,7 @@ pub fn command_interceptor(mut query: &str, cx: &AppContext) -> Option<CommandInfn generate_positions(string: &str, query: &str) -> Vec<usize> {let mut positions = Vec::new();- let mut chars = query.chars().into_iter();+ let mut chars = query.chars();let Some(mut current) = chars.next() else {return positions;diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rsindex 70059e47b61..278ccded119 100644--- a/crates/workspace/src/dock.rs+++ b/crates/workspace/src/dock.rs@@ -221,7 +221,7 @@ impl Dock {return;};if panel.is_zoomed(cx) {- workspace.zoomed = Some(panel.to_any().downgrade().into());+ workspace.zoomed = Some(panel.to_any().downgrade());workspace.zoomed_position = Some(position);} else {workspace.zoomed = None;diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 5e90f864864..58a2ee62418 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -899,7 +899,7 @@ impl Pane {if not_shown_files == 1 {file_names.push(".. 1 file not shown".into());} else {- file_names.push(format!(".. {} files not shown", not_shown_files).into());+ file_names.push(format!(".. {} files not shown", not_shown_files));}}(diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex f469538472a..f1b93b19b59 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -2961,7 +2961,7 @@ impl Workspace {})?;let Some(id) = view.id.clone() else {- return Err(anyhow!("no id for view")).into();+ return Err(anyhow!("no id for view"));};let id = ViewId::from_proto(id)?;@@ -3744,7 +3744,7 @@ fn open_items(let tasks = tasks.collect::<Vec<_>>();- let tasks = futures::future::join_all(tasks.into_iter());+ let tasks = futures::future::join_all(tasks);for (ix, path_open_result) in tasks.await.into_iter().flatten() {opened_items[ix] = Some(path_open_result);}diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex dc9f43519db..c7356216a1b 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -662,7 +662,7 @@ fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: Strinlet panic_data = Panic {thread: thread_name.into(),- payload: payload.into(),+ payload,location_data: info.location().map(|location| LocationData {file: location.file().into(),line: location.line(),diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rsindex 9881eb4c662..73acaacf34f 100644--- a/tooling/xtask/src/main.rs+++ b/tooling/xtask/src/main.rs@@ -111,7 +111,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {"clippy::suspicious_to_owned","clippy::type_complexity","clippy::unnecessary_to_owned",- "clippy::useless_conversion","clippy::vec_init_then_push",];