yoda: cargo clippy --fix on libcosmic-yoda (115→33 warnings)

Auto-applied clippy lint suggestions across 23 files: collapse
`else { if … }` ladders, drop unneeded `return` statements, remove
needless borrows that were immediately auto-dereffed, swap `iter().next()`
for `first()`, drop redundant `.into()` to the same type, and similar
mechanical cleanups. Behavior is unchanged; the diff is -67 lines net.

The 33 remaining warnings are architectural and need manual attention
(very-complex-type aliases, too-many-arguments on internal helpers,
redundant must_use, needs-is_empty, etc.).

Leyoda 2026 – GPLv3
This commit is contained in:
Lionel DARNIS 2026-05-05 19:10:03 +02:00
parent 999db0a4bd
commit 4743bb8ec9
23 changed files with 91 additions and 159 deletions

View file

@ -670,18 +670,15 @@ where
let old_value = Value::new(&old_value);
if state.is_focused()
&& let cursor::State::Index(index) = state.cursor.state(&old_value)
{
if index == old_value.len() {
&& index == old_value.len() {
state.cursor.move_to(self.value.len());
}
}
if let Some(f) = state.is_focused.as_ref().filter(|f| f.focused) {
if f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
if let Some(f) = state.is_focused.as_ref().filter(|f| f.focused)
&& f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
state.unfocus();
state.emit_unfocus = true;
}
}
if self.is_editable_variant {
if !state.is_focused() {
@ -895,8 +892,8 @@ where
let line_height = self.line_height;
// Disables editing of the editable variant when clicking outside of, or for tab focus changes.
if self.is_editable_variant {
if let Some(ref on_edit) = self.on_toggle_edit {
if self.is_editable_variant
&& let Some(ref on_edit) = self.on_toggle_edit {
let state = tree.state.downcast_mut::<State>();
if !state.is_read_only && state.is_focused.is_some_and(|f| !f.focused) {
state.is_read_only = true;
@ -908,7 +905,6 @@ where
shell.publish((on_edit)(f.focused));
}
}
}
// Calculates the layout of the trailing icon button element.
if !tree.children.is_empty() {
@ -919,9 +915,9 @@ where
trailing_icon_layout = Some(text_layout.children().last().unwrap());
// Enable custom buttons defined on the trailing icon position to be handled.
if !self.is_editable_variant {
if let Some(trailing_layout) = trailing_icon_layout {
let _res = trailing_icon.as_widget_mut().update(
if !self.is_editable_variant
&& let Some(trailing_layout) = trailing_icon_layout {
trailing_icon.as_widget_mut().update(
tree,
event,
trailing_layout,
@ -936,18 +932,16 @@ where
return;
}
}
}
}
}
let state = tree.state.downcast_mut::<State>();
if let Some(on_unfocus) = self.on_unfocus.as_ref() {
if state.emit_unfocus {
if let Some(on_unfocus) = self.on_unfocus.as_ref()
&& state.emit_unfocus {
state.emit_unfocus = false;
shell.publish(on_unfocus.clone());
}
}
let dnd_id = self.dnd_id();
let id = Widget::id(self);
@ -1656,11 +1650,10 @@ pub fn update<'a, Message: Clone + 'static>(
if matches!(state.dragging_state, None | Some(DraggingState::Selection))
&& (!state.is_focused() || (is_editable_variant && state.is_read_only))
{
if !state.is_focused() {
if let Some(on_focus) = on_focus {
if !state.is_focused()
&& let Some(on_focus) = on_focus {
shell.publish(on_focus.clone());
}
}
if state.is_read_only {
state.is_read_only = false;
@ -1685,7 +1678,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.last_click = Some(click);
shell.capture_event();
return;
} else {
state.unfocus();
@ -1721,7 +1713,6 @@ pub fn update<'a, Message: Clone + 'static>(
if cursor.is_over(layout.bounds()) {
shell.capture_event();
}
return;
}
Event::Mouse(mouse::Event::CursorMoved { position })
| Event::Touch(touch::Event::FingerMoved { position, .. }) => {
@ -1804,7 +1795,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
shell.capture_event();
return;
}
}
Event::Keyboard(keyboard::Event::KeyPressed {
@ -1829,14 +1819,13 @@ pub fn update<'a, Message: Clone + 'static>(
if state.keyboard_modifiers.command() {
match key.to_latin(*physical_key) {
Some('c') => {
if !is_secure {
if let Some((start, end)) = state.cursor.selection(value) {
if !is_secure
&& let Some((start, end)) = state.cursor.selection(value) {
clipboard.write(
iced_core::clipboard::Kind::Standard,
value.select(start, end).to_string(),
);
}
}
}
// XXX if we want to allow cutting of secure text, we need to
// update the cache and decide which value to cut
@ -2091,7 +2080,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
shell.capture_event();
return;
}
}
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
@ -2111,7 +2099,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
shell.capture_event();
return;
}
}
Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
@ -2127,7 +2114,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.preedit = matches!(event, input_method::Event::Opened)
.then(input_method::Preedit::new);
shell.capture_event();
return;
}
input_method::Event::Preedit(content, selection) => {
if state.is_focused() {
@ -2137,7 +2123,6 @@ pub fn update<'a, Message: Clone + 'static>(
text_size: Some(size.into()),
});
shell.capture_event();
return;
}
}
input_method::Event::Commit(text) => {
@ -2155,7 +2140,7 @@ pub fn update<'a, Message: Clone + 'static>(
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
let mut editor = Editor::new(unsecured_value, &mut state.cursor);
editor.paste(Value::new(&text));
editor.paste(Value::new(text));
let contents = editor.contents();
let unsecured_value = Value::new(&contents);
@ -2175,7 +2160,6 @@ pub fn update<'a, Message: Clone + 'static>(
update_cache(state, &value);
shell.capture_event();
return;
}
}
}
@ -2205,7 +2189,6 @@ pub fn update<'a, Message: Clone + 'static>(
// TODO: restore value in text input
state.dragging_state = None;
shell.capture_event();
return;
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
@ -2255,7 +2238,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.cursor.set_affinity(affinity);
state.cursor.move_to(position);
shell.capture_event();
return;
}
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
@ -2284,7 +2266,6 @@ pub fn update<'a, Message: Clone + 'static>(
state.cursor.set_affinity(affinity);
state.cursor.move_to(position);
shell.capture_event();
return;
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Drop)) if *rectangle == Some(dnd_id) => {
@ -2301,8 +2282,6 @@ pub fn update<'a, Message: Clone + 'static>(
};
state.dnd_offer = DndOfferState::Dropped;
}
return;
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != *id => {}
@ -2322,7 +2301,6 @@ pub fn update<'a, Message: Clone + 'static>(
}
};
shell.capture_event();
return;
}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Data { data, mime_type }))
@ -2359,9 +2337,7 @@ pub fn update<'a, Message: Clone + 'static>(
};
update_cache(state, &value);
shell.capture_event();
return;
}
return;
}
_ => {}
}