Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix most of the warnings
Antonio Scandurra7394bf1cdc8f
diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rsindex 465880cef58..e7a91e0efc1 100644--- a/crates/context_menu/src/context_menu.rs+++ b/crates/context_menu/src/context_menu.rs@@ -332,7 +332,6 @@ impl ContextMenu {&self,cx: &mut ViewContext<Self>,) -> impl Drawable<ContextMenu> {- let window_id = cx.window_id();let style = cx.global::<Settings>().theme.context_menu.clone();Flex::row().with_child(@@ -390,7 +389,6 @@ impl ContextMenu {};KeystrokeLabel::new(- window_id,view_id,action.boxed_clone(),style.keystroke.container,@@ -424,7 +422,6 @@ impl ContextMenu {let style = cx.global::<Settings>().theme.context_menu.clone();- let window_id = cx.window_id();MouseEventHandler::<Menu, ContextMenu>::new(0, cx, |_, cx| {Flex::column().with_children(self.items.iter().enumerate().map(|(ix, item)| {@@ -456,7 +453,6 @@ impl ContextMenu {}).with_child({KeystrokeLabel::new(- window_id,view_id,action.boxed_clone(),style.keystroke.container,diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 5f9cd38d6ac..f3f985720e9 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -1901,8 +1901,8 @@ impl Drawable<Editor> for EditorElement {let mut context_menu = None;let mut code_actions_indicator = None;- let mut hover = None;- let mut mode = EditorMode::Full;+ let mut hover;+ let mode;let mut fold_indicators = {let newest_selection_head = editor.selections@@ -2560,7 +2560,7 @@ mod tests {fn test_layout_line_numbers(cx: &mut gpui::AppContext) {cx.set_global(Settings::test(cx));let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);- let (window_id, editor) = cx.add_window(Default::default(), |cx| {+ let (_, editor) = cx.add_window(Default::default(), |cx| {Editor::new(EditorMode::Full, buffer, None, None, cx)});let element = EditorElement::new(editor.downgrade(), editor.read(cx).style(cx));@@ -2578,7 +2578,7 @@ mod tests {fn test_layout_with_placeholder_text_and_blocks(cx: &mut gpui::AppContext) {cx.set_global(Settings::test(cx));let buffer = MultiBuffer::build_simple("", cx);- let (window_id, editor) = cx.add_window(Default::default(), |cx| {+ let (_, editor) = cx.add_window(Default::default(), |cx| {Editor::new(EditorMode::Full, buffer, None, None, cx)});diff --git a/crates/gpui/src/elements.rs b/crates/gpui/src/elements.rsindex a13c7ccf075..e5aa225fe33 100644--- a/crates/gpui/src/elements.rs+++ b/crates/gpui/src/elements.rs@@ -586,9 +586,9 @@ impl<V: View, R: View> Drawable<V> for RootElement<R> {fn layout(&mut self,constraint: SizeConstraint,- view: &mut V,+ _view: &mut V,cx: &mut ViewContext<V>,- ) -> (Vector2F, Self::LayoutState) {+ ) -> (Vector2F, ()) {let size = AnyRootElement::layout(self, constraint, cx).log_err().unwrap_or_else(|| Vector2F::zero());@@ -600,35 +600,39 @@ impl<V: View, R: View> Drawable<V> for RootElement<R> {scene: &mut SceneBuilder,bounds: RectF,visible_bounds: RectF,- layout: &mut Self::LayoutState,- view: &mut V,+ _layout: &mut Self::LayoutState,+ _view: &mut V,cx: &mut ViewContext<V>,- ) -> Self::PaintState {- todo!()+ ) {+ AnyRootElement::paint(self, scene, bounds.origin(), visible_bounds, cx).log_err();}fn rect_for_text_range(&self,range_utf16: Range<usize>,- bounds: RectF,- visible_bounds: RectF,- layout: &Self::LayoutState,- paint: &Self::PaintState,- view: &V,+ _bounds: RectF,+ _visible_bounds: RectF,+ _layout: &Self::LayoutState,+ _paint: &Self::PaintState,+ _view: &V,cx: &ViewContext<V>,) -> Option<RectF> {- todo!()+ AnyRootElement::rect_for_text_range(self, range_utf16, cx)+ .log_err()+ .flatten()}fn debug(&self,- bounds: RectF,- layout: &Self::LayoutState,- paint: &Self::PaintState,- view: &V,+ _bounds: RectF,+ _layout: &Self::LayoutState,+ _paint: &Self::PaintState,+ _view: &V,cx: &ViewContext<V>,) -> serde_json::Value {- todo!()+ AnyRootElement::debug(self, cx)+ .log_err()+ .unwrap_or_default()}}diff --git a/crates/gpui/src/elements/keystroke_label.rs b/crates/gpui/src/elements/keystroke_label.rsindex d5fd8c6d56a..78d111e29a8 100644--- a/crates/gpui/src/elements/keystroke_label.rs+++ b/crates/gpui/src/elements/keystroke_label.rs@@ -12,20 +12,17 @@ pub struct KeystrokeLabel {action: Box<dyn Action>,container_style: ContainerStyle,text_style: TextStyle,- window_id: usize,view_id: usize,}impl KeystrokeLabel {pub fn new(- window_id: usize,view_id: usize,action: Box<dyn Action>,container_style: ContainerStyle,text_style: TextStyle,) -> Self {Self {- window_id,view_id,action,container_style,diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rsindex fc99907aaf7..2dde00ea0c8 100644--- a/crates/gpui/src/elements/text.rs+++ b/crates/gpui/src/elements/text.rs@@ -280,7 +280,7 @@ mod tests {#[crate::test(self)]fn test_soft_wrapping_with_carriage_returns(cx: &mut AppContext) {- let (window_id, root_view) = cx.add_window(Default::default(), |_| TestView);+ let (_, root_view) = cx.add_window(Default::default(), |_| TestView);fonts::with_font_cache(cx.font_cache().clone(), || {root_view.update(cx, |view, cx| {let mut text = Text::new("Hello\r\n", Default::default()).with_soft_wrap(true);diff --git a/crates/gpui/src/elements/tooltip.rs b/crates/gpui/src/elements/tooltip.rsindex 6647281b974..1d17b62ba77 100644--- a/crates/gpui/src/elements/tooltip.rs+++ b/crates/gpui/src/elements/tooltip.rs@@ -65,7 +65,6 @@ impl<V: View> Tooltip<V> {let state = state_handle.read(cx).clone();let tooltip = if state.visible.get() {let mut collapsed_tooltip = Self::render_tooltip(- cx.window_id,focused_view_id,text.clone(),style.clone(),@@ -75,7 +74,7 @@ impl<V: View> Tooltip<V> {.boxed();Some(Overlay::new(- Self::render_tooltip(cx.window_id, focused_view_id, text, style, action, false)+ Self::render_tooltip(focused_view_id, text, style, action, false).constrained().dynamically(move |constraint, view, cx| {SizeConstraint::strict_along(@@ -128,7 +127,6 @@ impl<V: View> Tooltip<V> {}pub fn render_tooltip(- window_id: usize,focused_view_id: Option<usize>,text: String,style: TooltipStyle,@@ -148,7 +146,6 @@ impl<V: View> Tooltip<V> {}).with_children(action.and_then(|action| {let keystroke_label = KeystrokeLabel::new(- window_id,focused_view_id?,action,style.keystroke.container,diff --git a/crates/journal/src/journal.rs b/crates/journal/src/journal.rsindex bdc6f5893ff..b74eab4f77a 100644--- a/crates/journal/src/journal.rs+++ b/crates/journal/src/journal.rs@@ -48,7 +48,7 @@ pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut AppContext) {async move {let (journal_dir, entry_path) = create_entry.await?;let (workspace, _) = cx- .update(|cx| workspace::open_paths(&[journal_dir], &app_state, None, cx))+ .update(|cx| workspace::open_paths(&[journal_dir], &app_state, cx)).await;let opened = workspacediff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rsindex 5fe22f6e274..06f5cc9227a 100644--- a/crates/terminal_view/src/terminal_element.rs+++ b/crates/terminal_view/src/terminal_element.rs@@ -88,7 +88,7 @@ impl LayoutCell {origin: Vector2F,layout: &LayoutState,visible_bounds: RectF,- view: &mut TerminalView,+ _view: &mut TerminalView,cx: &mut ViewContext<TerminalView>,) {let pos = {@@ -133,8 +133,8 @@ impl LayoutRect {scene: &mut SceneBuilder,origin: Vector2F,layout: &LayoutState,- view: &mut TerminalView,- cx: &mut ViewContext<TerminalView>,+ _view: &mut TerminalView,+ _cx: &mut ViewContext<TerminalView>,) {let position = {let point = self.point;@@ -390,7 +390,7 @@ impl TerminalElement {view_id: usize,visible_bounds: RectF,mode: TermMode,- cx: &mut ViewContext<TerminalView>,+ _cx: &mut ViewContext<TerminalView>,) {let connection = self.terminal;@@ -597,7 +597,6 @@ impl Drawable<TerminalView> for TerminalElement {terminal.last_content.last_hovered_hyperlink.clone()});- let view_handle = self.view.clone();let hyperlink_tooltip = last_hovered_hyperlink.map(|(uri, _, id)| {let mut tooltip = Overlay::new(Empty::new()diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex eef6859c80b..3358fdc8d66 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -12,7 +12,7 @@ use context_menu::{ContextMenu, ContextMenuItem};use dirs::home_dir;use gpui::{actions,- elements::{AnchorCorner, ChildView, Flex, Label, ParentElement, Stack, Text},+ elements::{AnchorCorner, ChildView, Flex, Label, ParentElement, Stack},geometry::vector::Vector2F,impl_actions, impl_internal_actions,keymap_matcher::{KeymapContext, Keystroke},diff --git a/crates/theme/src/ui.rs b/crates/theme/src/ui.rsindex e6a762808ff..fe31d1f1415 100644--- a/crates/theme/src/ui.rs+++ b/crates/theme/src/ui.rs@@ -135,7 +135,6 @@ pub fn keystroke_label<V: View>(// FIXME: Put the theme in it's own global so we can// query the keystroke style on our ownkeystroke_label_for(- cx.window_id(),cx.handle().id(),label_text,label_style,@@ -145,7 +144,6 @@ pub fn keystroke_label<V: View>(}pub fn keystroke_label_for<V: View>(- window_id: usize,view_id: usize,label_text: &'static str,label_style: &ContainedText,@@ -160,7 +158,6 @@ pub fn keystroke_label_for<V: View>().with_child({KeystrokeLabel::new(- window_id,view_id,action,keystroke_style.container,diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex ba687f19dd3..56087a661dc 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -286,7 +286,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {let app_state = Arc::downgrade(&app_state);move |action: &OpenPaths, cx: &mut AppContext| {if let Some(app_state) = app_state.upgrade() {- open_paths(&action.paths, &app_state, None, cx).detach();+ open_paths(&action.paths, &app_state, cx).detach();}}});@@ -299,14 +299,13 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {}let app_state = app_state.upgrade()?;- let window_id = cx.window_id();let action = action.clone();let close = workspace.prepare_to_close(false, cx);Some(cx.spawn_weak(|_, mut cx| async move {let can_close = close.await?;if can_close {- cx.update(|cx| open_paths(&action.paths, &app_state, Some(window_id), cx))+ cx.update(|cx| open_paths(&action.paths, &app_state, cx)).await;}Ok(())@@ -857,7 +856,6 @@ impl Workspace {fn new_local(abs_paths: Vec<PathBuf>,app_state: Arc<AppState>,- requesting_window_id: Option<usize>,cx: &mut AppContext,) -> Task<(ViewHandle<Workspace>,@@ -1059,7 +1057,7 @@ impl Workspace {if self.project.read(cx).is_local() {Task::Ready(Some(callback(self, cx)))} else {- let task = Self::new_local(Vec::new(), app_state.clone(), None, cx);+ let task = Self::new_local(Vec::new(), app_state.clone(), cx);cx.spawn(|_vh, mut cx| async move {let (workspace, _) = task.await;workspace.update(&mut cx, callback)@@ -3027,7 +3025,6 @@ pub async fn last_opened_workspace_paths() -> Option<WorkspaceLocation> {pub fn open_paths(abs_paths: &[PathBuf],app_state: &Arc<AppState>,- requesting_window_id: Option<usize>,cx: &mut AppContext,) -> Task<(ViewHandle<Workspace>,@@ -3058,8 +3055,7 @@ pub fn open_paths(.contains(&false);cx.update(|cx| {- let task =- Workspace::new_local(abs_paths, app_state.clone(), requesting_window_id, cx);+ let task = Workspace::new_local(abs_paths, app_state.clone(), cx);cx.spawn(|mut cx| async move {let (workspace, items) = task.await;@@ -3083,7 +3079,7 @@ pub fn open_new(cx: &mut AppContext,init: impl FnOnce(&mut Workspace, &mut ViewContext<Workspace>) + 'static,) -> Task<()> {- let task = Workspace::new_local(Vec::new(), app_state.clone(), None, cx);+ let task = Workspace::new_local(Vec::new(), app_state.clone(), cx);cx.spawn(|mut cx| async move {let (workspace, opened_paths) = task.await;diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex 0e4f15261f9..4f453ec32e2 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -219,7 +219,7 @@ fn main() {cx.spawn(|cx| handle_cli_connection(connection, app_state.clone(), cx)).detach();} else if let Ok(Some(paths)) = open_paths_rx.try_next() {- cx.update(|cx| workspace::open_paths(&paths, &app_state, None, cx))+ cx.update(|cx| workspace::open_paths(&paths, &app_state, cx)).detach();} else {cx.spawn({@@ -243,7 +243,7 @@ fn main() {let app_state = app_state.clone();async move {while let Some(paths) = open_paths_rx.next().await {- cx.update(|cx| workspace::open_paths(&paths, &app_state, None, cx))+ cx.update(|cx| workspace::open_paths(&paths, &app_state, cx)).detach();}}@@ -607,7 +607,7 @@ async fn handle_cli_connection(paths};let (workspace, items) = cx- .update(|cx| workspace::open_paths(&paths, &app_state, None, cx))+ .update(|cx| workspace::open_paths(&paths, &app_state, cx)).await;let mut errored = false;diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex 49404d6ebcd..19401d53127 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -703,14 +703,13 @@ mod tests {open_paths(&[PathBuf::from("/root/a"), PathBuf::from("/root/b")],&app_state,- None,cx,)}).await;assert_eq!(cx.window_ids().len(), 1);- cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))+ cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, cx)).await;assert_eq!(cx.window_ids().len(), 1);let workspace_1 = cx@@ -728,7 +727,6 @@ mod tests {open_paths(&[PathBuf::from("/root/b"), PathBuf::from("/root/c")],&app_state,- None,cx,)})@@ -741,7 +739,6 @@ mod tests {open_paths(&[PathBuf::from("/root/c"), PathBuf::from("/root/d")],&app_state,- Some(window_id),cx,)})@@ -771,7 +768,7 @@ mod tests {.insert_tree("/root", json!({"a": "hey"})).await;- cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))+ cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, cx)).await;assert_eq!(cx.window_ids().len(), 1);@@ -813,7 +810,7 @@ mod tests {assert!(!cx.is_window_edited(workspace.window_id()));// Opening the buffer again doesn't impact the window's edited state.- cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, None, cx))+ cx.update(|cx| open_paths(&[PathBuf::from("/root/a")], &app_state, cx)).await;let editor = workspace.read_with(cx, |workspace, cx| {workspace