Fix clippy::redundant_clone
lint violations (#36558)
This removes around 900 unnecessary clones, ranging from cloning a few ints all the way to large data structures and images. A lot of these were fixed using `cargo clippy --fix --workspace --all-targets`, however it often breaks other lints and needs to be run again. This was then followed up with some manual fixing. I understand this is a large diff, but all the changes are pretty trivial. Rust is doing some heavy lifting here for us. Once I get it up to speed with main, I'd appreciate this getting merged rather sooner than later. Release Notes: - N/A
This commit is contained in:
parent
cf7c64d77f
commit
7bdc99abc1
306 changed files with 805 additions and 1102 deletions
|
@ -96,7 +96,7 @@ impl RenderOnce for DropdownMenu {
|
|||
.style(self.style),
|
||||
)
|
||||
.attach(Corner::BottomLeft)
|
||||
.when_some(self.handle.clone(), |el, handle| el.with_handle(handle))
|
||||
.when_some(self.handle, |el, handle| el.with_handle(handle))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl Component for DropdownMenu {
|
|||
"States",
|
||||
vec![single_example(
|
||||
"Disabled",
|
||||
DropdownMenu::new("disabled", "Disabled Dropdown", menu.clone())
|
||||
DropdownMenu::new("disabled", "Disabled Dropdown", menu)
|
||||
.disabled(true)
|
||||
.into_any_element(),
|
||||
)],
|
||||
|
|
|
@ -195,7 +195,7 @@ mod uniform_list {
|
|||
impl UniformListDecoration for IndentGuides {
|
||||
fn compute(
|
||||
&self,
|
||||
visible_range: Range<usize>,
|
||||
mut visible_range: Range<usize>,
|
||||
bounds: Bounds<Pixels>,
|
||||
_scroll_offset: Point<Pixels>,
|
||||
item_height: Pixels,
|
||||
|
@ -203,7 +203,6 @@ mod uniform_list {
|
|||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> AnyElement {
|
||||
let mut visible_range = visible_range.clone();
|
||||
let includes_trailing_indent = visible_range.end < item_count;
|
||||
// Check if we have entries after the visible range,
|
||||
// if so extend the visible range so we can fetch a trailing indent,
|
||||
|
|
|
@ -325,7 +325,7 @@ impl RenderOnce for Key {
|
|||
.text_size(size)
|
||||
.line_height(relative(1.))
|
||||
.text_color(self.color.unwrap_or(Color::Muted).color(cx))
|
||||
.child(self.key.clone())
|
||||
.child(self.key)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ impl Component for KeybindingHint {
|
|||
),
|
||||
single_example(
|
||||
"Large",
|
||||
KeybindingHint::new(enter.clone(), bg_color)
|
||||
KeybindingHint::new(enter, bg_color)
|
||||
.size(Pixels::from(20.0))
|
||||
.prefix("Large:")
|
||||
.suffix("Size")
|
||||
|
|
|
@ -64,7 +64,7 @@ impl RenderOnce for AlertModal {
|
|||
)
|
||||
.child(Button::new(
|
||||
self.primary_action.clone(),
|
||||
self.primary_action.clone(),
|
||||
self.primary_action,
|
||||
)),
|
||||
),
|
||||
)
|
||||
|
|
|
@ -28,7 +28,7 @@ where
|
|||
T: StickyCandidate + Clone + 'static,
|
||||
{
|
||||
let entity_compute = entity.clone();
|
||||
let entity_render = entity.clone();
|
||||
let entity_render = entity;
|
||||
|
||||
let compute_fn = Rc::new(
|
||||
move |range: Range<usize>, window: &mut Window, cx: &mut App| -> SmallVec<[T; 8]> {
|
||||
|
|
|
@ -159,7 +159,6 @@ fn distance_string(
|
|||
} else {
|
||||
format!("about {} hours", hours)
|
||||
}
|
||||
.to_string()
|
||||
} else if distance < 172_800 {
|
||||
"1 day".to_string()
|
||||
} else if distance < 2_592_000 {
|
||||
|
@ -206,21 +205,16 @@ fn distance_string(
|
|||
} else {
|
||||
format!("about {} years", years)
|
||||
}
|
||||
.to_string()
|
||||
} else if remaining_months < 9 {
|
||||
if hide_prefix {
|
||||
format!("{} years", years)
|
||||
} else {
|
||||
format!("over {} years", years)
|
||||
}
|
||||
.to_string()
|
||||
} else if hide_prefix {
|
||||
format!("{} years", years + 1)
|
||||
} else {
|
||||
if hide_prefix {
|
||||
format!("{} years", years + 1)
|
||||
} else {
|
||||
format!("almost {} years", years + 1)
|
||||
}
|
||||
.to_string()
|
||||
format!("almost {} years", years + 1)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue