Enable clippy::clone_on_copy (#8728)

This PR enables the
[`clippy::clone_on_copy`](https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_copy)
rule and fixes the outstanding violations.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-02 17:37:48 -05:00 committed by GitHub
parent 5935681c5c
commit 9735912965
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
42 changed files with 144 additions and 160 deletions

View File

@ -65,7 +65,7 @@ impl PromptTemplate for RepositoryContext {
let template = "You are working inside a large repository, here are a few code snippets that may be useful."; let template = "You are working inside a large repository, here are a few code snippets that may be useful.";
let mut prompt = String::new(); let mut prompt = String::new();
let mut remaining_tokens = max_token_length.clone(); let mut remaining_tokens = max_token_length;
let separator_token_length = args.model.count_tokens("\n")?; let separator_token_length = args.model.count_tokens("\n")?;
for snippet in &args.snippets { for snippet in &args.snippets {
let mut snippet_prompt = template.to_string(); let mut snippet_prompt = template.to_string();

View File

@ -1483,7 +1483,7 @@ impl Conversation {
max_token_count: tiktoken_rs::model::get_context_size(&model.full_name()), max_token_count: tiktoken_rs::model::get_context_size(&model.full_name()),
pending_token_count: Task::ready(None), pending_token_count: Task::ready(None),
api_url: Some(api_url), api_url: Some(api_url),
model: model.clone(), model,
_subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)], _subscriptions: vec![cx.subscribe(&buffer, Self::handle_buffer_event)],
pending_save: Task::ready(Ok(())), pending_save: Task::ready(Ok(())),
path: None, path: None,
@ -1527,7 +1527,7 @@ impl Conversation {
.as_ref() .as_ref()
.map(|summary| summary.text.clone()) .map(|summary| summary.text.clone())
.unwrap_or_default(), .unwrap_or_default(),
model: self.model.clone(), model: self.model,
api_url: self.api_url.clone(), api_url: self.api_url.clone(),
} }
} }
@ -1652,7 +1652,7 @@ impl Conversation {
}) })
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let model = self.model.clone(); let model = self.model;
self.pending_token_count = cx.spawn(|this, mut cx| { self.pending_token_count = cx.spawn(|this, mut cx| {
async move { async move {
cx.background_executor() cx.background_executor()

View File

@ -302,7 +302,7 @@ impl ActiveCall {
return Task::ready(Ok(())); return Task::ready(Ok(()));
} }
let room_id = call.room_id.clone(); let room_id = call.room_id;
let client = self.client.clone(); let client = self.client.clone();
let user_store = self.user_store.clone(); let user_store = self.user_store.clone();
let join = self let join = self

View File

@ -1437,14 +1437,13 @@ async fn test_following_across_workspaces(cx_a: &mut TestAppContext, cx_b: &mut
}); });
executor.run_until_parked(); executor.run_until_parked();
let window_b_project_a = cx_b let window_b_project_a = *cx_b
.windows() .windows()
.iter() .iter()
.max_by_key(|window| window.window_id()) .max_by_key(|window| window.window_id())
.unwrap() .unwrap();
.clone();
let mut cx_b2 = VisualTestContext::from_window(window_b_project_a.clone(), cx_b); let mut cx_b2 = VisualTestContext::from_window(window_b_project_a, cx_b);
let workspace_b_project_a = window_b_project_a let workspace_b_project_a = window_b_project_a
.downcast::<Workspace>() .downcast::<Workspace>()
@ -1548,13 +1547,12 @@ async fn test_following_across_workspaces(cx_a: &mut TestAppContext, cx_b: &mut
executor.run_until_parked(); executor.run_until_parked();
assert_eq!(visible_push_notifications(cx_a).len(), 0); assert_eq!(visible_push_notifications(cx_a).len(), 0);
let window_a_project_b = cx_a let window_a_project_b = *cx_a
.windows() .windows()
.iter() .iter()
.max_by_key(|window| window.window_id()) .max_by_key(|window| window.window_id())
.unwrap() .unwrap();
.clone(); let cx_a2 = &mut VisualTestContext::from_window(window_a_project_b, cx_a);
let cx_a2 = &mut VisualTestContext::from_window(window_a_project_b.clone(), cx_a);
let workspace_a_project_b = window_a_project_b let workspace_a_project_b = window_a_project_b
.downcast::<Workspace>() .downcast::<Workspace>()
.unwrap() .unwrap()

View File

@ -996,7 +996,7 @@ impl RandomizedTest for ProjectCollaborationTest {
let statuses = statuses let statuses = statuses
.iter() .iter()
.map(|(path, val)| (path.as_path(), val.clone())) .map(|(path, val)| (path.as_path(), *val))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if client.fs().metadata(&dot_git_dir).await?.is_none() { if client.fs().metadata(&dot_git_dir).await?.is_none() {

View File

@ -171,10 +171,8 @@ impl ChannelView {
let this = this.clone(); let this = this.clone();
Some(ui::ContextMenu::build(cx, move |menu, _| { Some(ui::ContextMenu::build(cx, move |menu, _| {
menu.entry("Copy link to section", None, move |cx| { menu.entry("Copy link to section", None, move |cx| {
this.update(cx, |this, cx| { this.update(cx, |this, cx| this.copy_link_for_position(position, cx))
this.copy_link_for_position(position.clone(), cx) .ok();
})
.ok();
}) })
})) }))
}); });

View File

@ -403,7 +403,7 @@ impl CollabTitlebarItem {
) )
}) })
.on_click({ .on_click({
let host_peer_id = host.peer_id.clone(); let host_peer_id = host.peer_id;
cx.listener(move |this, _, cx| { cx.listener(move |this, _, cx| {
this.workspace this.workspace
.update(cx, |workspace, cx| { .update(cx, |workspace, cx| {

View File

@ -119,7 +119,7 @@ impl Render for IncomingCallNotification {
let theme_settings = ThemeSettings::get_global(cx); let theme_settings = ThemeSettings::get_global(cx);
( (
theme_settings.ui_font.family.clone(), theme_settings.ui_font.family.clone(),
theme_settings.ui_font_size.clone(), theme_settings.ui_font_size,
) )
}; };

View File

@ -123,7 +123,7 @@ impl Render for ProjectSharedNotification {
let theme_settings = ThemeSettings::get_global(cx); let theme_settings = ThemeSettings::get_global(cx);
( (
theme_settings.ui_font.family.clone(), theme_settings.ui_font.family.clone(),
theme_settings.ui_font_size.clone(), theme_settings.ui_font_size,
) )
}; };

View File

@ -347,7 +347,7 @@ impl ProjectDiagnosticsEditor {
.diagnostic_groups .diagnostic_groups
.last() .last()
.unwrap(); .unwrap();
prev_path_last_group.excerpts.last().unwrap().clone() *prev_path_last_group.excerpts.last().unwrap()
} else { } else {
ExcerptId::min() ExcerptId::min()
}; };
@ -451,10 +451,10 @@ impl ProjectDiagnosticsEditor {
.pop() .pop()
.unwrap(); .unwrap();
prev_excerpt_id = excerpt_id.clone(); prev_excerpt_id = excerpt_id;
first_excerpt_id.get_or_insert_with(|| prev_excerpt_id.clone()); first_excerpt_id.get_or_insert_with(|| prev_excerpt_id);
group_state.excerpts.push(excerpt_id.clone()); group_state.excerpts.push(excerpt_id);
let header_position = (excerpt_id.clone(), language::Anchor::MIN); let header_position = (excerpt_id, language::Anchor::MIN);
if is_first_excerpt_for_group { if is_first_excerpt_for_group {
is_first_excerpt_for_group = false; is_first_excerpt_for_group = false;
@ -483,7 +483,7 @@ impl ProjectDiagnosticsEditor {
if !diagnostic.message.is_empty() { if !diagnostic.message.is_empty() {
group_state.block_count += 1; group_state.block_count += 1;
blocks_to_add.push(BlockProperties { blocks_to_add.push(BlockProperties {
position: (excerpt_id.clone(), entry.range.start), position: (excerpt_id, entry.range.start),
height: diagnostic.message.matches('\n').count() as u8 + 1, height: diagnostic.message.matches('\n').count() as u8 + 1,
style: BlockStyle::Fixed, style: BlockStyle::Fixed,
render: diagnostic_block_renderer(diagnostic, true), render: diagnostic_block_renderer(diagnostic, true),
@ -506,8 +506,8 @@ impl ProjectDiagnosticsEditor {
group_ixs_to_remove.push(group_ix); group_ixs_to_remove.push(group_ix);
blocks_to_remove.extend(group_state.blocks.iter().copied()); blocks_to_remove.extend(group_state.blocks.iter().copied());
} else if let Some((_, group)) = to_keep { } else if let Some((_, group)) = to_keep {
prev_excerpt_id = group.excerpts.last().unwrap().clone(); prev_excerpt_id = *group.excerpts.last().unwrap();
first_excerpt_id.get_or_insert_with(|| prev_excerpt_id.clone()); first_excerpt_id.get_or_insert_with(|| prev_excerpt_id);
} }
} }
@ -591,7 +591,7 @@ impl ProjectDiagnosticsEditor {
if let Some(group) = groups.get(group_ix) { if let Some(group) = groups.get(group_ix) {
let offset = excerpts_snapshot let offset = excerpts_snapshot
.anchor_in_excerpt( .anchor_in_excerpt(
group.excerpts[group.primary_excerpt_ix].clone(), group.excerpts[group.primary_excerpt_ix],
group.primary_diagnostic.range.start, group.primary_diagnostic.range.start,
) )
.to_offset(&excerpts_snapshot); .to_offset(&excerpts_snapshot);

View File

@ -1291,7 +1291,7 @@ pub mod tests {
let mut cx = EditorTestContext::new(cx).await; let mut cx = EditorTestContext::new(cx).await;
let editor = cx.editor.clone(); let editor = cx.editor.clone();
let window = cx.window.clone(); let window = cx.window;
_ = cx.update_window(window, |_, cx| { _ = cx.update_window(window, |_, cx| {
let text_layout_details = let text_layout_details =

View File

@ -884,10 +884,10 @@ impl sum_tree::Item for Fold {
fn summary(&self) -> Self::Summary { fn summary(&self) -> Self::Summary {
FoldSummary { FoldSummary {
start: self.range.start.clone(), start: self.range.start,
end: self.range.end.clone(), end: self.range.end,
min_start: self.range.start.clone(), min_start: self.range.start,
max_end: self.range.end.clone(), max_end: self.range.end,
count: 1, count: 1,
} }
} }
@ -919,10 +919,10 @@ impl sum_tree::Summary for FoldSummary {
fn add_summary(&mut self, other: &Self, buffer: &Self::Context) { fn add_summary(&mut self, other: &Self, buffer: &Self::Context) {
if other.min_start.cmp(&self.min_start, buffer) == Ordering::Less { if other.min_start.cmp(&self.min_start, buffer) == Ordering::Less {
self.min_start = other.min_start.clone(); self.min_start = other.min_start;
} }
if other.max_end.cmp(&self.max_end, buffer) == Ordering::Greater { if other.max_end.cmp(&self.max_end, buffer) == Ordering::Greater {
self.max_end = other.max_end.clone(); self.max_end = other.max_end;
} }
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
@ -934,16 +934,16 @@ impl sum_tree::Summary for FoldSummary {
} }
} }
self.start = other.start.clone(); self.start = other.start;
self.end = other.end.clone(); self.end = other.end;
self.count += other.count; self.count += other.count;
} }
} }
impl<'a> sum_tree::Dimension<'a, FoldSummary> for FoldRange { impl<'a> sum_tree::Dimension<'a, FoldSummary> for FoldRange {
fn add_summary(&mut self, summary: &'a FoldSummary, _: &MultiBufferSnapshot) { fn add_summary(&mut self, summary: &'a FoldSummary, _: &MultiBufferSnapshot) {
self.0.start = summary.start.clone(); self.0.start = summary.start;
self.0.end = summary.end.clone(); self.0.end = summary.end;
} }
} }

View File

@ -283,7 +283,7 @@ impl<'a> Iterator for InlayChunks<'a> {
self.output_offset.0 += prefix.len(); self.output_offset.0 += prefix.len();
let mut prefix = Chunk { let mut prefix = Chunk {
text: prefix, text: prefix,
..chunk.clone() ..*chunk
}; };
if !self.active_highlights.is_empty() { if !self.active_highlights.is_empty() {
let mut highlight_style = HighlightStyle::default(); let mut highlight_style = HighlightStyle::default();
@ -322,7 +322,7 @@ impl<'a> Iterator for InlayChunks<'a> {
next_inlay_highlight_endpoint = range.end - offset_in_inlay.0; next_inlay_highlight_endpoint = range.end - offset_in_inlay.0;
highlight_style highlight_style
.get_or_insert_with(|| Default::default()) .get_or_insert_with(|| Default::default())
.highlight(style.clone()); .highlight(*style);
} }
} else { } else {
next_inlay_highlight_endpoint = usize::MAX; next_inlay_highlight_endpoint = usize::MAX;

View File

@ -1873,7 +1873,7 @@ impl Editor {
let new_cursor_position = self.selections.newest_anchor().head(); let new_cursor_position = self.selections.newest_anchor().head();
self.push_to_nav_history( self.push_to_nav_history(
old_cursor_position.clone(), *old_cursor_position,
Some(new_cursor_position.to_point(buffer)), Some(new_cursor_position.to_point(buffer)),
cx, cx,
); );
@ -1892,8 +1892,7 @@ impl Editor {
if let Some(completion_menu) = completion_menu { if let Some(completion_menu) = completion_menu {
let cursor_position = new_cursor_position.to_offset(buffer); let cursor_position = new_cursor_position.to_offset(buffer);
let (word_range, kind) = let (word_range, kind) = buffer.surrounding_word(completion_menu.initial_position);
buffer.surrounding_word(completion_menu.initial_position.clone());
if kind == Some(CharKind::Word) if kind == Some(CharKind::Word)
&& word_range.to_inclusive().contains(&cursor_position) && word_range.to_inclusive().contains(&cursor_position)
{ {
@ -2114,7 +2113,7 @@ impl Editor {
match click_count { match click_count {
1 => { 1 => {
start = buffer.anchor_before(position.to_point(&display_map)); start = buffer.anchor_before(position.to_point(&display_map));
end = start.clone(); end = start;
mode = SelectMode::Character; mode = SelectMode::Character;
auto_scroll = true; auto_scroll = true;
} }
@ -2122,7 +2121,7 @@ impl Editor {
let range = movement::surrounding_word(&display_map, position); let range = movement::surrounding_word(&display_map, position);
start = buffer.anchor_before(range.start.to_point(&display_map)); start = buffer.anchor_before(range.start.to_point(&display_map));
end = buffer.anchor_before(range.end.to_point(&display_map)); end = buffer.anchor_before(range.end.to_point(&display_map));
mode = SelectMode::Word(start.clone()..end.clone()); mode = SelectMode::Word(start..end);
auto_scroll = true; auto_scroll = true;
} }
3 => { 3 => {
@ -2136,7 +2135,7 @@ impl Editor {
); );
start = buffer.anchor_before(line_start); start = buffer.anchor_before(line_start);
end = buffer.anchor_before(next_line_start); end = buffer.anchor_before(next_line_start);
mode = SelectMode::Line(start.clone()..end.clone()); mode = SelectMode::Line(start..end);
auto_scroll = true; auto_scroll = true;
} }
_ => { _ => {
@ -3208,7 +3207,7 @@ impl Editor {
let (buffer, buffer_position) = self let (buffer, buffer_position) = self
.buffer .buffer
.read(cx) .read(cx)
.text_anchor_for_position(position.clone(), cx)?; .text_anchor_for_position(position, cx)?;
// OnTypeFormatting returns a list of edits, no need to pass them between Zed instances, // OnTypeFormatting returns a list of edits, no need to pass them between Zed instances,
// hence we do LSP request & edit on host side only — add formats to host's history. // hence we do LSP request & edit on host side only — add formats to host's history.
@ -3252,17 +3251,14 @@ impl Editor {
}; };
let position = self.selections.newest_anchor().head(); let position = self.selections.newest_anchor().head();
let (buffer, buffer_position) = if let Some(output) = self let (buffer, buffer_position) =
.buffer if let Some(output) = self.buffer.read(cx).text_anchor_for_position(position, cx) {
.read(cx) output
.text_anchor_for_position(position.clone(), cx) } else {
{ return;
output };
} else {
return;
};
let query = Self::completion_query(&self.buffer.read(cx).read(cx), position.clone()); let query = Self::completion_query(&self.buffer.read(cx).read(cx), position);
let completions = provider.completions(&buffer, buffer_position, cx); let completions = provider.completions(&buffer, buffer_position, cx);
let id = post_inc(&mut self.next_completion_id); let id = post_inc(&mut self.next_completion_id);
@ -3700,7 +3696,7 @@ impl Editor {
let newest_selection = self.selections.newest_anchor().clone(); let newest_selection = self.selections.newest_anchor().clone();
let cursor_position = newest_selection.head(); let cursor_position = newest_selection.head();
let (cursor_buffer, cursor_buffer_position) = let (cursor_buffer, cursor_buffer_position) =
buffer.text_anchor_for_position(cursor_position.clone(), cx)?; buffer.text_anchor_for_position(cursor_position, cx)?;
let (tail_buffer, _) = buffer.text_anchor_for_position(newest_selection.tail(), cx)?; let (tail_buffer, _) = buffer.text_anchor_for_position(newest_selection.tail(), cx)?;
if cursor_buffer != tail_buffer { if cursor_buffer != tail_buffer {
return None; return None;
@ -3758,7 +3754,7 @@ impl Editor {
let range = Anchor { let range = Anchor {
buffer_id, buffer_id,
excerpt_id: excerpt_id.clone(), excerpt_id: excerpt_id,
text_anchor: start, text_anchor: start,
}..Anchor { }..Anchor {
buffer_id, buffer_id,
@ -4741,7 +4737,7 @@ impl Editor {
row_range.end - 1, row_range.end - 1,
snapshot.line_len(row_range.end - 1), snapshot.line_len(row_range.end - 1),
)); ));
cursor_positions.push(anchor.clone()..anchor); cursor_positions.push(anchor..anchor);
} }
self.transact(cx, |this, cx| { self.transact(cx, |this, cx| {
@ -7447,10 +7443,8 @@ impl Editor {
pub fn open_url(&mut self, _: &OpenUrl, cx: &mut ViewContext<Self>) { pub fn open_url(&mut self, _: &OpenUrl, cx: &mut ViewContext<Self>) {
let position = self.selections.newest_anchor().head(); let position = self.selections.newest_anchor().head();
let Some((buffer, buffer_position)) = self let Some((buffer, buffer_position)) =
.buffer self.buffer.read(cx).text_anchor_for_position(position, cx)
.read(cx)
.text_anchor_for_position(position.clone(), cx)
else { else {
return; return;
}; };
@ -7912,7 +7906,7 @@ impl Editor {
let block_id = this.insert_blocks( let block_id = this.insert_blocks(
[BlockProperties { [BlockProperties {
style: BlockStyle::Flex, style: BlockStyle::Flex,
position: range.start.clone(), position: range.start,
height: 1, height: 1,
render: Arc::new({ render: Arc::new({
let rename_editor = rename_editor.clone(); let rename_editor = rename_editor.clone();
@ -7976,11 +7970,11 @@ impl Editor {
let (start_buffer, start) = self let (start_buffer, start) = self
.buffer .buffer
.read(cx) .read(cx)
.text_anchor_for_position(rename.range.start.clone(), cx)?; .text_anchor_for_position(rename.range.start, cx)?;
let (end_buffer, end) = self let (end_buffer, end) = self
.buffer .buffer
.read(cx) .read(cx)
.text_anchor_for_position(rename.range.end.clone(), cx)?; .text_anchor_for_position(rename.range.end, cx)?;
if start_buffer != end_buffer { if start_buffer != end_buffer {
return None; return None;
} }
@ -8817,7 +8811,7 @@ impl Editor {
Ok(i) | Err(i) => i, Ok(i) | Err(i) => i,
}; };
let right_position = right_position.clone(); let right_position = right_position;
ranges[start_ix..] ranges[start_ix..]
.iter() .iter()
.take_while(move |range| range.start.cmp(&right_position, buffer).is_le()) .take_while(move |range| range.start.cmp(&right_position, buffer).is_le())

View File

@ -381,7 +381,7 @@ pub fn show_link_definition(
let Some((buffer, buffer_position)) = editor let Some((buffer, buffer_position)) = editor
.buffer .buffer
.read(cx) .read(cx)
.text_anchor_for_position(trigger_anchor.clone(), cx) .text_anchor_for_position(*trigger_anchor, cx)
else { else {
return; return;
}; };
@ -389,7 +389,7 @@ pub fn show_link_definition(
let Some((excerpt_id, _, _)) = editor let Some((excerpt_id, _, _)) = editor
.buffer() .buffer()
.read(cx) .read(cx)
.excerpt_containing(trigger_anchor.clone(), cx) .excerpt_containing(*trigger_anchor, cx)
else { else {
return; return;
}; };
@ -424,9 +424,8 @@ pub fn show_link_definition(
TriggerPoint::Text(_) => { TriggerPoint::Text(_) => {
if let Some((url_range, url)) = find_url(&buffer, buffer_position, cx.clone()) { if let Some((url_range, url)) = find_url(&buffer, buffer_position, cx.clone()) {
this.update(&mut cx, |_, _| { this.update(&mut cx, |_, _| {
let start = let start = snapshot.anchor_in_excerpt(excerpt_id, url_range.start);
snapshot.anchor_in_excerpt(excerpt_id.clone(), url_range.start); let end = snapshot.anchor_in_excerpt(excerpt_id, url_range.end);
let end = snapshot.anchor_in_excerpt(excerpt_id.clone(), url_range.end);
( (
Some(RangeInEditor::Text(start..end)), Some(RangeInEditor::Text(start..end)),
vec![HoverLink::Url(url)], vec![HoverLink::Url(url)],
@ -451,14 +450,10 @@ pub fn show_link_definition(
( (
definition_result.iter().find_map(|link| { definition_result.iter().find_map(|link| {
link.origin.as_ref().map(|origin| { link.origin.as_ref().map(|origin| {
let start = snapshot.anchor_in_excerpt( let start = snapshot
excerpt_id.clone(), .anchor_in_excerpt(excerpt_id, origin.range.start);
origin.range.start, let end = snapshot
); .anchor_in_excerpt(excerpt_id, origin.range.end);
let end = snapshot.anchor_in_excerpt(
excerpt_id.clone(),
origin.range.end,
);
RangeInEditor::Text(start..end) RangeInEditor::Text(start..end)
}) })
}), }),

View File

@ -297,10 +297,10 @@ fn show_hover(
let range = if let Some(range) = hover_result.range { let range = if let Some(range) = hover_result.range {
let start = snapshot let start = snapshot
.buffer_snapshot .buffer_snapshot
.anchor_in_excerpt(excerpt_id.clone(), range.start); .anchor_in_excerpt(excerpt_id, range.start);
let end = snapshot let end = snapshot
.buffer_snapshot .buffer_snapshot
.anchor_in_excerpt(excerpt_id.clone(), range.end); .anchor_in_excerpt(excerpt_id, range.end);
start..end start..end
} else { } else {
@ -597,7 +597,7 @@ impl DiagnosticPopover {
.as_ref() .as_ref()
.unwrap_or(&self.local_diagnostic); .unwrap_or(&self.local_diagnostic);
(entry.diagnostic.group_id, entry.range.start.clone()) (entry.diagnostic.group_id, entry.range.start)
} }
} }

View File

@ -2197,7 +2197,7 @@ pub mod tests {
"another change #3", "another change #3",
] { ] {
expected_changes.push(async_later_change); expected_changes.push(async_later_change);
let task_editor = editor.clone(); let task_editor = editor;
edits.push(cx.spawn(|mut cx| async move { edits.push(cx.spawn(|mut cx| async move {
task_editor task_editor
.update(&mut cx, |editor, cx| { .update(&mut cx, |editor, cx| {

View File

@ -1147,8 +1147,8 @@ impl SearchableItem for Editor {
let end = excerpt let end = excerpt
.buffer .buffer
.anchor_before(excerpt_range.start + range.end); .anchor_before(excerpt_range.start + range.end);
buffer.anchor_in_excerpt(excerpt.id.clone(), start) buffer.anchor_in_excerpt(excerpt.id, start)
..buffer.anchor_in_excerpt(excerpt.id.clone(), end) ..buffer.anchor_in_excerpt(excerpt.id, end)
}), }),
); );
} }

View File

@ -863,7 +863,7 @@ mod tests {
let mut cx = EditorTestContext::new(cx).await; let mut cx = EditorTestContext::new(cx).await;
let editor = cx.editor.clone(); let editor = cx.editor.clone();
let window = cx.window.clone(); let window = cx.window;
_ = cx.update_window(window, |_, cx| { _ = cx.update_window(window, |_, cx| {
let text_layout_details = let text_layout_details =
editor.update(cx, |editor, cx| editor.text_layout_details(cx)); editor.update(cx, |editor, cx| editor.text_layout_details(cx));

View File

@ -478,7 +478,7 @@ impl<'a> MutableSelectionsCollection<'a> {
if !oldest.start.cmp(&oldest.end, &self.buffer()).is_eq() { if !oldest.start.cmp(&oldest.end, &self.buffer()).is_eq() {
let head = oldest.head(); let head = oldest.head();
oldest.start = head.clone(); oldest.start = head;
oldest.end = head; oldest.end = head;
self.collection.disjoint = Arc::from([oldest]); self.collection.disjoint = Arc::from([oldest]);
self.selections_changed = true; self.selections_changed = true;
@ -794,8 +794,8 @@ impl<'a> MutableSelectionsCollection<'a> {
let adjusted_disjoint: Vec<_> = anchors_with_status let adjusted_disjoint: Vec<_> = anchors_with_status
.chunks(2) .chunks(2)
.map(|selection_anchors| { .map(|selection_anchors| {
let (anchor_ix, start, kept_start) = selection_anchors[0].clone(); let (anchor_ix, start, kept_start) = selection_anchors[0];
let (_, end, kept_end) = selection_anchors[1].clone(); let (_, end, kept_end) = selection_anchors[1];
let selection = &self.disjoint[anchor_ix / 2]; let selection = &self.disjoint[anchor_ix / 2];
let kept_head = if selection.reversed { let kept_head = if selection.reversed {
kept_start kept_start
@ -826,8 +826,8 @@ impl<'a> MutableSelectionsCollection<'a> {
let buffer = self.buffer(); let buffer = self.buffer();
let anchors = let anchors =
buffer.refresh_anchors([&pending.selection.start, &pending.selection.end]); buffer.refresh_anchors([&pending.selection.start, &pending.selection.end]);
let (_, start, kept_start) = anchors[0].clone(); let (_, start, kept_start) = anchors[0];
let (_, end, kept_end) = anchors[1].clone(); let (_, end, kept_end) = anchors[1];
let kept_head = if pending.selection.reversed { let kept_head = if pending.selection.reversed {
kept_start kept_start
} else { } else {

View File

@ -496,11 +496,14 @@ impl Platform for MacPlatform {
handle: AnyWindowHandle, handle: AnyWindowHandle,
options: WindowOptions, options: WindowOptions,
) -> Box<dyn PlatformWindow> { ) -> Box<dyn PlatformWindow> {
// Clippy thinks that this evaluates to `()`, for some reason.
#[allow(clippy::clone_on_copy)]
let renderer_context = self.0.lock().renderer_context.clone();
Box::new(MacWindow::open( Box::new(MacWindow::open(
handle, handle,
options, options,
self.foreground_executor(), self.foreground_executor(),
self.0.lock().renderer_context.clone(), renderer_context,
)) ))
} }

View File

@ -1412,7 +1412,7 @@ fn insert_newlines_between_ranges(
continue; continue;
} }
let range_b = ranges[ix].clone(); let range_b = ranges[ix];
let range_a = &mut ranges[ix - 1]; let range_a = &mut ranges[ix - 1];
if range_a.end_point.column == 0 { if range_a.end_point.column == 0 {
continue; continue;

View File

@ -229,7 +229,7 @@ impl LanguageServer {
let stdout = server.stdout.take().unwrap(); let stdout = server.stdout.take().unwrap();
let stderr = server.stderr.take().unwrap(); let stderr = server.stderr.take().unwrap();
let mut server = Self::new_internal( let mut server = Self::new_internal(
server_id.clone(), server_id,
stdin, stdin,
stdout, stdout,
Some(stderr), Some(stderr),

View File

@ -105,7 +105,7 @@ impl<'a> MarkdownParser<'a> {
classes: _, classes: _,
attrs: _, attrs: _,
} => { } => {
let level = level.clone(); let level = *level;
self.cursor += 1; self.cursor += 1;
let heading = self.parse_heading(level); let heading = self.parse_heading(level);
Some(ParsedMarkdownElement::Heading(heading)) Some(ParsedMarkdownElement::Heading(heading))
@ -117,7 +117,7 @@ impl<'a> MarkdownParser<'a> {
Some(ParsedMarkdownElement::Table(table)) Some(ParsedMarkdownElement::Table(table))
} }
Tag::List(order) => { Tag::List(order) => {
let order = order.clone(); let order = *order;
self.cursor += 1; self.cursor += 1;
let list = self.parse_list(1, order); let list = self.parse_list(1, order);
Some(ParsedMarkdownElement::List(list)) Some(ParsedMarkdownElement::List(list))
@ -421,7 +421,7 @@ impl<'a> MarkdownParser<'a> {
let (current, _source_range) = self.current().unwrap(); let (current, _source_range) = self.current().unwrap();
match current { match current {
Event::Start(Tag::List(order)) => { Event::Start(Tag::List(order)) => {
let order = order.clone(); let order = *order;
self.cursor += 1; self.cursor += 1;
let inner_list = self.parse_list(depth + 1, order); let inner_list = self.parse_list(depth + 1, order);
@ -467,7 +467,7 @@ impl<'a> MarkdownParser<'a> {
let item_type = if let Some(checked) = task_item { let item_type = if let Some(checked) = task_item {
ParsedMarkdownListItemType::Task(checked) ParsedMarkdownListItemType::Task(checked)
} else if let Some(order) = order.clone() { } else if let Some(order) = order {
ParsedMarkdownListItemType::Ordered(order) ParsedMarkdownListItemType::Ordered(order)
} else { } else {
ParsedMarkdownListItemType::Unordered ParsedMarkdownListItemType::Unordered

View File

@ -55,12 +55,12 @@ impl Anchor {
if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) { if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) {
return Self { return Self {
buffer_id: self.buffer_id, buffer_id: self.buffer_id,
excerpt_id: self.excerpt_id.clone(), excerpt_id: self.excerpt_id,
text_anchor: self.text_anchor.bias_left(&excerpt.buffer), text_anchor: self.text_anchor.bias_left(&excerpt.buffer),
}; };
} }
} }
self.clone() *self
} }
pub fn bias_right(&self, snapshot: &MultiBufferSnapshot) -> Anchor { pub fn bias_right(&self, snapshot: &MultiBufferSnapshot) -> Anchor {
@ -68,12 +68,12 @@ impl Anchor {
if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) { if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) {
return Self { return Self {
buffer_id: self.buffer_id, buffer_id: self.buffer_id,
excerpt_id: self.excerpt_id.clone(), excerpt_id: self.excerpt_id,
text_anchor: self.text_anchor.bias_right(&excerpt.buffer), text_anchor: self.text_anchor.bias_right(&excerpt.buffer),
}; };
} }
} }
self.clone() *self
} }
pub fn summary<D>(&self, snapshot: &MultiBufferSnapshot) -> D pub fn summary<D>(&self, snapshot: &MultiBufferSnapshot) -> D

View File

@ -950,12 +950,12 @@ impl MultiBuffer {
for range in ranges.by_ref().take(range_count) { for range in ranges.by_ref().take(range_count) {
let start = Anchor { let start = Anchor {
buffer_id: Some(buffer_id), buffer_id: Some(buffer_id),
excerpt_id: excerpt_id.clone(), excerpt_id: excerpt_id,
text_anchor: range.start, text_anchor: range.start,
}; };
let end = Anchor { let end = Anchor {
buffer_id: Some(buffer_id), buffer_id: Some(buffer_id),
excerpt_id: excerpt_id.clone(), excerpt_id: excerpt_id,
text_anchor: range.end, text_anchor: range.end,
}; };
if tx.send(start..end).await.is_err() { if tx.send(start..end).await.is_err() {
@ -1005,12 +1005,12 @@ impl MultiBuffer {
anchor_ranges.extend(ranges.by_ref().take(range_count).map(|range| { anchor_ranges.extend(ranges.by_ref().take(range_count).map(|range| {
let start = Anchor { let start = Anchor {
buffer_id: Some(buffer_id), buffer_id: Some(buffer_id),
excerpt_id: excerpt_id.clone(), excerpt_id: excerpt_id,
text_anchor: buffer_snapshot.anchor_after(range.start), text_anchor: buffer_snapshot.anchor_after(range.start),
}; };
let end = Anchor { let end = Anchor {
buffer_id: Some(buffer_id), buffer_id: Some(buffer_id),
excerpt_id: excerpt_id.clone(), excerpt_id: excerpt_id,
text_anchor: buffer_snapshot.anchor_after(range.end), text_anchor: buffer_snapshot.anchor_after(range.end),
}; };
start..end start..end
@ -1206,7 +1206,7 @@ impl MultiBuffer {
cursor.seek_forward(&Some(locator), Bias::Left, &()); cursor.seek_forward(&Some(locator), Bias::Left, &());
if let Some(excerpt) = cursor.item() { if let Some(excerpt) = cursor.item() {
if excerpt.locator == *locator { if excerpt.locator == *locator {
excerpts.push((excerpt.id.clone(), excerpt.range.clone())); excerpts.push((excerpt.id, excerpt.range.clone()));
} }
} }
} }
@ -1238,7 +1238,7 @@ impl MultiBuffer {
.or_else(|| snapshot.excerpts.last()) .or_else(|| snapshot.excerpts.last())
.map(|excerpt| { .map(|excerpt| {
( (
excerpt.id.clone(), excerpt.id,
self.buffers self.buffers
.borrow() .borrow()
.get(&excerpt.buffer_id) .get(&excerpt.buffer_id)
@ -2689,7 +2689,7 @@ impl MultiBufferSnapshot {
if !kept_position { if !kept_position {
for excerpt in [next_excerpt, prev_excerpt].iter().filter_map(|e| *e) { for excerpt in [next_excerpt, prev_excerpt].iter().filter_map(|e| *e) {
if excerpt.contains(&anchor) { if excerpt.contains(&anchor) {
anchor.excerpt_id = excerpt.id.clone(); anchor.excerpt_id = excerpt.id;
kept_position = true; kept_position = true;
break; break;
} }
@ -2713,7 +2713,7 @@ impl MultiBufferSnapshot {
} }
Anchor { Anchor {
buffer_id: Some(excerpt.buffer_id), buffer_id: Some(excerpt.buffer_id),
excerpt_id: excerpt.id.clone(), excerpt_id: excerpt.id,
text_anchor, text_anchor,
} }
} else if let Some(excerpt) = prev_excerpt { } else if let Some(excerpt) = prev_excerpt {
@ -2730,7 +2730,7 @@ impl MultiBufferSnapshot {
} }
Anchor { Anchor {
buffer_id: Some(excerpt.buffer_id), buffer_id: Some(excerpt.buffer_id),
excerpt_id: excerpt.id.clone(), excerpt_id: excerpt.id,
text_anchor, text_anchor,
} }
} else if anchor.text_anchor.bias == Bias::Left { } else if anchor.text_anchor.bias == Bias::Left {
@ -2760,7 +2760,7 @@ impl MultiBufferSnapshot {
if let Some((excerpt_id, buffer_id, buffer)) = self.as_singleton() { if let Some((excerpt_id, buffer_id, buffer)) = self.as_singleton() {
return Anchor { return Anchor {
buffer_id: Some(buffer_id), buffer_id: Some(buffer_id),
excerpt_id: excerpt_id.clone(), excerpt_id: *excerpt_id,
text_anchor: buffer.anchor_at(offset, bias), text_anchor: buffer.anchor_at(offset, bias),
}; };
} }
@ -2782,7 +2782,7 @@ impl MultiBufferSnapshot {
excerpt.clip_anchor(excerpt.buffer.anchor_at(buffer_start + overshoot, bias)); excerpt.clip_anchor(excerpt.buffer.anchor_at(buffer_start + overshoot, bias));
Anchor { Anchor {
buffer_id: Some(excerpt.buffer_id), buffer_id: Some(excerpt.buffer_id),
excerpt_id: excerpt.id.clone(), excerpt_id: excerpt.id,
text_anchor, text_anchor,
} }
} else if offset == 0 && bias == Bias::Left { } else if offset == 0 && bias == Bias::Left {
@ -2895,7 +2895,7 @@ impl MultiBufferSnapshot {
let excerpt = cursor.item()?; let excerpt = cursor.item()?;
let starts_new_buffer = Some(excerpt.buffer_id) != prev_buffer_id; let starts_new_buffer = Some(excerpt.buffer_id) != prev_buffer_id;
let boundary = ExcerptBoundary { let boundary = ExcerptBoundary {
id: excerpt.id.clone(), id: excerpt.id,
row: cursor.start().1.row, row: cursor.start().1.row,
buffer: excerpt.buffer.clone(), buffer: excerpt.buffer.clone(),
range: excerpt.range.clone(), range: excerpt.range.clone(),
@ -3280,8 +3280,8 @@ impl MultiBufferSnapshot {
.into_iter() .into_iter()
.map(|item| OutlineItem { .map(|item| OutlineItem {
depth: item.depth, depth: item.depth,
range: self.anchor_in_excerpt(excerpt_id.clone(), item.range.start) range: self.anchor_in_excerpt(*excerpt_id, item.range.start)
..self.anchor_in_excerpt(excerpt_id.clone(), item.range.end), ..self.anchor_in_excerpt(*excerpt_id, item.range.end),
text: item.text, text: item.text,
highlight_ranges: item.highlight_ranges, highlight_ranges: item.highlight_ranges,
name_ranges: item.name_ranges, name_ranges: item.name_ranges,
@ -3402,19 +3402,19 @@ impl MultiBufferSnapshot {
selections.map(move |selection| { selections.map(move |selection| {
let mut start = Anchor { let mut start = Anchor {
buffer_id: Some(excerpt.buffer_id), buffer_id: Some(excerpt.buffer_id),
excerpt_id: excerpt.id.clone(), excerpt_id: excerpt.id,
text_anchor: selection.start, text_anchor: selection.start,
}; };
let mut end = Anchor { let mut end = Anchor {
buffer_id: Some(excerpt.buffer_id), buffer_id: Some(excerpt.buffer_id),
excerpt_id: excerpt.id.clone(), excerpt_id: excerpt.id,
text_anchor: selection.end, text_anchor: selection.end,
}; };
if range.start.cmp(&start, self).is_gt() { if range.start.cmp(&start, self).is_gt() {
start = range.start.clone(); start = range.start;
} }
if range.end.cmp(&end, self).is_lt() { if range.end.cmp(&end, self).is_lt() {
end = range.end.clone(); end = range.end;
} }
( (

View File

@ -1408,7 +1408,7 @@ impl LspCommand for GetHover {
if let Some(range) = range.as_ref() { if let Some(range) = range.as_ref() {
buffer buffer
.update(&mut cx, |buffer, _| { .update(&mut cx, |buffer, _| {
buffer.wait_for_anchors([range.start.clone(), range.end.clone()]) buffer.wait_for_anchors([range.start, range.end])
})? })?
.await?; .await?;
} }
@ -1523,7 +1523,7 @@ impl LspCommand for GetCompletions {
}); });
let range = if let Some(range) = default_edit_range { let range = if let Some(range) = default_edit_range {
let range = range_from_lsp(range.clone()); let range = range_from_lsp(*range);
let start = snapshot.clip_point_utf16(range.start, Bias::Left); let start = snapshot.clip_point_utf16(range.start, Bias::Left);
let end = snapshot.clip_point_utf16(range.end, Bias::Left); let end = snapshot.clip_point_utf16(range.end, Bias::Left);
if start != range.start.0 || end != range.end.0 { if start != range.start.0 || end != range.end.0 {

View File

@ -991,7 +991,7 @@ impl LocalWorktree {
pub fn scan_complete(&self) -> impl Future<Output = ()> { pub fn scan_complete(&self) -> impl Future<Output = ()> {
let mut is_scanning_rx = self.is_scanning.1.clone(); let mut is_scanning_rx = self.is_scanning.1.clone();
async move { async move {
let mut is_scanning = is_scanning_rx.borrow().clone(); let mut is_scanning = *is_scanning_rx.borrow();
while is_scanning { while is_scanning {
if let Some(value) = is_scanning_rx.recv().await { if let Some(value) = is_scanning_rx.recv().await {
is_scanning = value; is_scanning = value;

View File

@ -219,7 +219,7 @@ impl ProjectSearch {
active_query: self.active_query.clone(), active_query: self.active_query.clone(),
search_id: self.search_id, search_id: self.search_id,
search_history: self.search_history.clone(), search_history: self.search_history.clone(),
no_results: self.no_results.clone(), no_results: self.no_results,
}) })
} }
@ -1279,7 +1279,7 @@ impl ProjectSearchView {
fn focus_results_editor(&mut self, cx: &mut ViewContext<Self>) { fn focus_results_editor(&mut self, cx: &mut ViewContext<Self>) {
self.query_editor.update(cx, |query_editor, cx| { self.query_editor.update(cx, |query_editor, cx| {
let cursor = query_editor.selections.newest_anchor().head(); let cursor = query_editor.selections.newest_anchor().head();
query_editor.change_selections(None, cx, |s| s.select_ranges([cursor.clone()..cursor])); query_editor.change_selections(None, cx, |s| s.select_ranges([cursor..cursor]));
}); });
self.query_editor_was_focused = false; self.query_editor_was_focused = false;
let results_handle = self.results_editor.focus_handle(cx); let results_handle = self.results_editor.focus_handle(cx);
@ -1299,7 +1299,6 @@ impl ProjectSearchView {
if is_new_search { if is_new_search {
let range_to_select = match_ranges let range_to_select = match_ranges
.first() .first()
.clone()
.map(|range| editor.range_for_match(range)); .map(|range| editor.range_for_match(range));
editor.change_selections(Some(Autoscroll::fit()), cx, |s| { editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
s.select_ranges(range_to_select) s.select_ranges(range_to_select)
@ -2245,7 +2244,7 @@ pub mod tests {
.await; .await;
let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await; let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx)); let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.clone(); let workspace = window;
let search_bar = window.build_view(cx, |_| ProjectSearchBar::new()); let search_bar = window.build_view(cx, |_| ProjectSearchBar::new());
let active_item = cx.read(|cx| { let active_item = cx.read(|cx| {
@ -2475,7 +2474,7 @@ pub mod tests {
.await; .await;
let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await; let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await;
let window = cx.add_window(|cx| Workspace::test_new(project, cx)); let window = cx.add_window(|cx| Workspace::test_new(project, cx));
let workspace = window.clone(); let workspace = window;
let search_bar = window.build_view(cx, |_| ProjectSearchBar::new()); let search_bar = window.build_view(cx, |_| ProjectSearchBar::new());
let active_item = cx.read(|cx| { let active_item = cx.read(|cx| {
@ -3410,7 +3409,7 @@ pub mod tests {
let search_view = cx.add_window(|cx| ProjectSearchView::new(search.clone(), cx, None)); let search_view = cx.add_window(|cx| ProjectSearchView::new(search.clone(), cx, None));
// First search // First search
perform_search(search_view.clone(), "A", cx); perform_search(search_view, "A", cx);
search_view search_view
.update(cx, |search_view, cx| { .update(cx, |search_view, cx| {
search_view.results_editor.update(cx, |results_editor, cx| { search_view.results_editor.update(cx, |results_editor, cx| {
@ -3428,7 +3427,7 @@ pub mod tests {
.expect("unable to update search view"); .expect("unable to update search view");
// Second search // Second search
perform_search(search_view.clone(), "B", cx); perform_search(search_view, "B", cx);
search_view search_view
.update(cx, |search_view, cx| { .update(cx, |search_view, cx| {
search_view.results_editor.update(cx, |results_editor, cx| { search_view.results_editor.update(cx, |results_editor, cx| {

View File

@ -456,8 +456,7 @@ impl VectorDatabase {
if batch_ids.len() == batch_n { if batch_ids.len() == batch_n {
let embeddings = std::mem::take(&mut batch_embeddings); let embeddings = std::mem::take(&mut batch_embeddings);
let ids = std::mem::take(&mut batch_ids); let ids = std::mem::take(&mut batch_ids);
let array = let array = Array2::from_shape_vec((ids.len(), embedding_len), embeddings);
Array2::from_shape_vec((ids.len(), embedding_len.clone()), embeddings);
match array { match array {
Ok(array) => { Ok(array) => {
batches.push((ids, array)); batches.push((ids, array));

View File

@ -329,7 +329,7 @@ impl SemanticIndex {
SemanticIndexStatus::Indexed SemanticIndexStatus::Indexed
} else { } else {
SemanticIndexStatus::Indexing { SemanticIndexStatus::Indexing {
remaining_files: project_state.pending_file_count_rx.borrow().clone(), remaining_files: *project_state.pending_file_count_rx.borrow(),
rate_limit_expiry: self.embedding_provider.rate_limit_expiration(), rate_limit_expiry: self.embedding_provider.rate_limit_expiration(),
} }
} }
@ -497,7 +497,7 @@ impl SemanticIndex {
changes: Arc<[(Arc<Path>, ProjectEntryId, PathChange)]>, changes: Arc<[(Arc<Path>, ProjectEntryId, PathChange)]>,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) { ) {
let Some(worktree) = project.read(cx).worktree_for_id(worktree_id.clone(), cx) else { let Some(worktree) = project.read(cx).worktree_for_id(worktree_id, cx) else {
return; return;
}; };
let project = project.downgrade(); let project = project.downgrade();
@ -840,7 +840,7 @@ impl SemanticIndex {
let mut batch_results = Vec::new(); let mut batch_results = Vec::new();
for batch in file_ids.chunks(batch_size) { for batch in file_ids.chunks(batch_size) {
let batch = batch.into_iter().map(|v| *v).collect::<Vec<i64>>(); let batch = batch.into_iter().map(|v| *v).collect::<Vec<i64>>();
let limit = limit.clone(); let limit = limit;
let fs = fs.clone(); let fs = fs.clone();
let db_path = db_path.clone(); let db_path = db_path.clone();
let query = query.clone(); let query = query.clone();

View File

@ -42,7 +42,7 @@ fn main() {
menu::init(); menu::init();
let args = Args::parse(); let args = Args::parse();
let story_selector = args.story.clone().unwrap_or_else(|| { let story_selector = args.story.unwrap_or_else(|| {
let stories = ComponentStory::iter().collect::<Vec<_>>(); let stories = ComponentStory::iter().collect::<Vec<_>>();
ctrlc::set_handler(move || {}).unwrap(); ctrlc::set_handler(move || {}).unwrap();

View File

@ -715,7 +715,7 @@ impl Terminal {
new_size.size.height = cmp::max(new_size.line_height, new_size.height()); new_size.size.height = cmp::max(new_size.line_height, new_size.height());
new_size.size.width = cmp::max(new_size.cell_width, new_size.width()); new_size.size.width = cmp::max(new_size.cell_width, new_size.width());
self.last_content.size = new_size.clone(); self.last_content.size = new_size;
self.pty_tx.0.send(Msg::Resize(new_size.into())).ok(); self.pty_tx.0.send(Msg::Resize(new_size.into())).ok();

View File

@ -406,11 +406,10 @@ impl TerminalElement {
let font_features = terminal_settings let font_features = terminal_settings
.font_features .font_features
.clone() .unwrap_or(settings.buffer_font.features);
.unwrap_or(settings.buffer_font.features.clone());
let line_height = terminal_settings.line_height.value(); let line_height = terminal_settings.line_height.value();
let font_size = terminal_settings.font_size.clone(); let font_size = terminal_settings.font_size;
let font_size = let font_size =
font_size.map_or(buffer_font_size, |size| theme::adjusted_font_size(size, cx)); font_size.map_or(buffer_font_size, |size| theme::adjusted_font_size(size, cx));
@ -462,7 +461,7 @@ impl TerminalElement {
.width; .width;
gutter = cell_width; gutter = cell_width;
let mut size = bounds.size.clone(); let mut size = bounds.size;
size.width -= gutter; size.width -= gutter;
// https://github.com/zed-industries/zed/issues/2750 // https://github.com/zed-industries/zed/issues/2750
@ -646,7 +645,7 @@ impl TerminalElement {
}); });
cx.on_mouse_event({ cx.on_mouse_event({
let bounds = bounds.clone(); let bounds = bounds;
let focus = self.focus.clone(); let focus = self.focus.clone();
let terminal = self.terminal.clone(); let terminal = self.terminal.clone();
move |e: &MouseMoveEvent, phase, cx| { move |e: &MouseMoveEvent, phase, cx| {
@ -828,7 +827,7 @@ impl Element for TerminalElement {
start_y, //Need to change this start_y, //Need to change this
line_height: layout.dimensions.line_height, line_height: layout.dimensions.line_height,
lines: highlighted_range_lines, lines: highlighted_range_lines,
color: color.clone(), color: *color,
//Copied from editor. TODO: move to theme or something //Copied from editor. TODO: move to theme or something
corner_radius: 0.15 * layout.dimensions.line_height, corner_radius: 0.15 * layout.dimensions.line_height,
}; };

View File

@ -132,8 +132,8 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
}; };
let menu = element_state.menu.clone(); let menu = element_state.menu.clone();
let position = element_state.position.clone(); let position = element_state.position.clone();
let attach = self.attach.clone(); let attach = self.attach;
let child_layout_id = element_state.child_layout_id.clone(); let child_layout_id = element_state.child_layout_id;
let child_bounds = cx.layout_bounds(child_layout_id.unwrap()); let child_bounds = cx.layout_bounds(child_layout_id.unwrap());
let interactive_bounds = InteractiveBounds { let interactive_bounds = InteractiveBounds {

View File

@ -294,7 +294,7 @@ mod test {
lsp::CompletionItem { lsp::CompletionItem {
label: "first".to_string(), label: "first".to_string(),
text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
range: lsp::Range::new(position.clone(), position.clone()), range: lsp::Range::new(position, position),
new_text: "first".to_string(), new_text: "first".to_string(),
})), })),
..Default::default() ..Default::default()
@ -302,7 +302,7 @@ mod test {
lsp::CompletionItem { lsp::CompletionItem {
label: "second".to_string(), label: "second".to_string(),
text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
range: lsp::Range::new(position.clone(), position.clone()), range: lsp::Range::new(position, position),
new_text: "second".to_string(), new_text: "second".to_string(),
})), })),
..Default::default() ..Default::default()

View File

@ -90,7 +90,7 @@ impl VimTestContext {
T: 'static, T: 'static,
F: FnOnce(&mut T, &mut ViewContext<T>) -> R + 'static, F: FnOnce(&mut T, &mut ViewContext<T>) -> R + 'static,
{ {
let window = self.window.clone(); let window = self.window;
self.update_window(window, move |_, cx| view.update(cx, update)) self.update_window(window, move |_, cx| view.update(cx, update))
.unwrap() .unwrap()
} }

View File

@ -222,7 +222,7 @@ pub fn visual_block_motion(
start: start.to_point(map), start: start.to_point(map),
end: end.to_point(map), end: end.to_point(map),
reversed: is_reversed, reversed: is_reversed,
goal: goal.clone(), goal,
}; };
selections.push(selection); selections.push(selection);

View File

@ -367,7 +367,7 @@ impl WorkspaceDb {
conn.exec_bound(sql!( conn.exec_bound(sql!(
DELETE FROM workspaces WHERE workspace_location = ? AND workspace_id != ? DELETE FROM workspaces WHERE workspace_location = ? AND workspace_id != ?
))?((&workspace.location, workspace.id.clone())) ))?((&workspace.location, workspace.id))
.context("clearing out old locations")?; .context("clearing out old locations")?;
// Upsert // Upsert

View File

@ -871,7 +871,7 @@ impl Workspace {
cx.open_window(options, { cx.open_window(options, {
let app_state = app_state.clone(); let app_state = app_state.clone();
let workspace_id = workspace_id.clone(); let workspace_id = workspace_id;
let project_handle = project_handle.clone(); let project_handle = project_handle.clone();
move |cx| { move |cx| {
cx.new_view(|cx| { cx.new_view(|cx| {
@ -3790,7 +3790,7 @@ impl Render for Workspace {
let theme_settings = ThemeSettings::get_global(cx); let theme_settings = ThemeSettings::get_global(cx);
( (
theme_settings.ui_font.family.clone(), theme_settings.ui_font.family.clone(),
theme_settings.ui_font_size.clone(), theme_settings.ui_font_size,
) )
}; };
@ -4393,7 +4393,7 @@ pub fn open_paths(
cx.spawn(move |mut cx| async move { cx.spawn(move |mut cx| async move {
if let Some(existing) = existing { if let Some(existing) = existing {
Ok(( Ok((
existing.clone(), existing,
existing existing
.update(&mut cx, |workspace, cx| { .update(&mut cx, |workspace, cx| {
workspace.open_paths(abs_paths, OpenVisible::All, None, cx) workspace.open_paths(abs_paths, OpenVisible::All, None, cx)

View File

@ -561,7 +561,7 @@ pub fn handle_keymap_file_changes(
let new_base_keymap = *BaseKeymap::get_global(cx); let new_base_keymap = *BaseKeymap::get_global(cx);
let new_vim_enabled = VimModeSetting::get_global(cx).0; let new_vim_enabled = VimModeSetting::get_global(cx).0;
if new_base_keymap != old_base_keymap || new_vim_enabled != old_vim_enabled { if new_base_keymap != old_base_keymap || new_vim_enabled != old_vim_enabled {
old_base_keymap = new_base_keymap.clone(); old_base_keymap = new_base_keymap;
old_vim_enabled = new_vim_enabled; old_vim_enabled = new_vim_enabled;
base_keymap_tx.unbounded_send(()).unwrap(); base_keymap_tx.unbounded_send(()).unwrap();
} }

View File

@ -84,7 +84,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
"clippy::borrow_deref_ref", "clippy::borrow_deref_ref",
"clippy::borrowed_box", "clippy::borrowed_box",
"clippy::cast_abs_to_unsigned", "clippy::cast_abs_to_unsigned",
"clippy::clone_on_copy",
"clippy::cmp_owned", "clippy::cmp_owned",
"clippy::crate_in_macro_def", "clippy::crate_in_macro_def",
"clippy::default_constructed_unit_structs", "clippy::default_constructed_unit_structs",