yoda: cargo fix --lib (libcosmic-yoda) — drop 99 trivial warnings

Auto-applied suggestions on libcosmic-yoda lib only: unused imports,
unused-by-name params (prefixed with _), redundant mutability. From 113
warnings down to 14 (the 14 remaining are real signals: never-read
fields, unreachable patterns, etc., to be reviewed manually).

Leyoda 2026 – GPLv3
This commit is contained in:
Lionel DARNIS 2026-05-05 16:27:29 +02:00
parent 282813c80e
commit cdf349385b
35 changed files with 85 additions and 104 deletions

View file

@ -9,7 +9,7 @@
use iced_runtime::core::widget::Id;
use iced_runtime::{Action, Task, keyboard, task};
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::renderer::{self, Quad, Renderer};
use iced_core::touch;
use iced_core::widget::Operation;
@ -667,7 +667,7 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
height,
} = layout.bounds();
let bounds = Rect::new(x as f64, y as f64, (x + width) as f64, (y + height) as f64);
let is_hovered = state.state.downcast_ref::<State>().is_hovered;
let _is_hovered = state.state.downcast_ref::<State>().is_hovered;
let mut node = Node::new(Role::Button);
node.add_action(Action::Focus);
@ -827,7 +827,7 @@ pub fn update<'a, Message: Clone>(
}
}
#[cfg(feature = "a11y")]
Event::A11y(event_id, iced_accessibility::accesskit::ActionRequest { action, .. }) => {
Event::A11y(_event_id, iced_accessibility::accesskit::ActionRequest { action, .. }) => {
let state = state();
if let Some(on_press) = matches!(action, iced_accessibility::accesskit::Action::Click)
.then_some(on_press)
@ -870,7 +870,7 @@ pub fn draw<Renderer: iced_core::Renderer, Theme>(
viewport_bounds: Rectangle,
styling: &super::style::Style,
draw_contents: impl FnOnce(&mut Renderer, &Style),
is_image: bool,
_is_image: bool,
) where
Theme: super::style::Catalog,
{

View file

@ -98,7 +98,7 @@ where
/// Get an expandable stack of cards
#[allow(clippy::too_many_arguments)]
pub fn new<F, G>(
id: widget::Id,
_id: widget::Id,
card_inner_elements: Vec<Element<'a, Message, crate::Theme, crate::Renderer>>,
on_clear_all: Message,
on_show_more: Option<F>,

View file

@ -15,7 +15,7 @@ use crate::theme::{Button, THEME};
use crate::widget::{button::Catalog, container, segmented_button::Entity, slider};
use derive_setters::Setters;
use iced::Task;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::gradient::{ColorStop, Linear};
use iced_core::renderer::Quad;
use iced_core::widget::{Tree, tree};

View file

@ -88,7 +88,7 @@ impl<Message: Clone + 'static> ContextMenu<'_, Message> {
bounds.x = my_state.context_cursor.x;
bounds.y = my_state.context_cursor.y;
let (id, root_list) = my_state.menu_bar_state.inner.with_data_mut(|state| {
let (id, _root_list) = my_state.menu_bar_state.inner.with_data_mut(|state| {
if let Some(id) = state.popup_id.get(&self.window_id).copied() {
// close existing popups
state.menu_states.clear();
@ -146,7 +146,7 @@ impl<Message: Clone + 'static> ContextMenu<'_, Message> {
layout.bounds(),
-bounds.height,
);
let (anchor_rect, gravity) = my_state.menu_bar_state.inner.with_data_mut(|state| {
let (anchor_rect, _gravity) = my_state.menu_bar_state.inner.with_data_mut(|state| {
use iced::Rectangle;
state.popup_id.insert(self.window_id, id);

View file

@ -8,8 +8,7 @@ use crate::{
};
use iced::{
Event, Length, Point, Rectangle, Vector,
clipboard::dnd::{DndAction, DndEvent, SourceEvent},
event, mouse, overlay,
clipboard::dnd::{DndAction, DndEvent, SourceEvent}, mouse, overlay,
};
use iced_core::{
self, Clipboard, Shell, layout, renderer,

View file

@ -8,9 +8,8 @@ use std::sync::{Arc, Mutex};
pub use appearance::{Appearance, StyleSheet};
use crate::surface;
use crate::widget::{Container, RcWrapper, icon};
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout::{self, Layout};
use iced_core::text::{self, Text};
use iced_core::widget::Tree;
@ -391,7 +390,7 @@ impl<'a, Message: Clone + 'a> crate::widget::Widget<Message, crate::Theme, crate
fn draw(
&self,
tree: &Tree,
_tree: &Tree,
renderer: &mut crate::Renderer,
theme: &crate::Theme,
style: &renderer::Style,
@ -554,12 +553,12 @@ where
fn draw(
&self,
state: &Tree,
_state: &Tree,
renderer: &mut crate::Renderer,
theme: &crate::Theme,
style: &renderer::Style,
_style: &renderer::Style,
layout: Layout<'_>,
cursor: mouse::Cursor,
_cursor: mouse::Cursor,
viewport: &Rectangle,
) {
let appearance = theme.appearance(&());

View file

@ -2,7 +2,7 @@ use super::Model;
pub use crate::widget::dropdown::menu::{Appearance, StyleSheet};
use crate::widget::Container;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout::{self, Layout};
use iced_core::text::{self, Text};
use iced_core::widget::Tree;

View file

@ -5,7 +5,7 @@
use super::menu::{self, Menu};
use crate::widget::icon;
use derive_setters::Setters;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::text::{self, Paragraph, Text};
use iced_core::widget::tree::{self, Tree};
use iced_core::{
@ -13,7 +13,6 @@ use iced_core::{
};
use iced_core::{Shadow, alignment, keyboard, layout, mouse, overlay, renderer, svg, touch};
use iced_widget::pick_list;
use std::ffi::OsStr;
pub use iced_widget::pick_list::{Catalog, Style};
@ -253,7 +252,7 @@ impl<Item: Clone + PartialEq + 'static> Default for State<Item> {
/// Computes the layout of a [`Dropdown`].
#[allow(clippy::too_many_arguments)]
pub fn layout(
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
limits: &layout::Limits,
width: Length,
gap: f32,
@ -376,7 +375,7 @@ pub fn mouse_interaction(layout: Layout<'_>, cursor: mouse::Cursor) -> mouse::In
#[allow(clippy::too_many_arguments)]
pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>(
layout: Layout<'_>,
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
state: &'a mut State<Item>,
gap: f32,
padding: Padding,

View file

@ -2,9 +2,6 @@
// SPDX-License-Identifier: MPL-2.0 AND MIT
//! Operate on dropdown widgets.
use super::State;
use iced::Rectangle;
use iced_core::widget::{Id, Operation};
pub trait Dropdown {
fn close(&mut self);

View file

@ -8,7 +8,7 @@ use crate::widget::icon::{self, Handle};
use crate::{Element, surface};
use derive_setters::Setters;
use iced::window;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::text::{self, Paragraph, Text};
use iced_core::widget::tree::{self, Tree};
use iced_core::{
@ -17,7 +17,6 @@ use iced_core::{
use iced_core::{Shadow, alignment, keyboard, layout, mouse, overlay, renderer, svg, touch};
use iced_widget::pick_list::{self, Catalog};
use std::borrow::Cow;
use std::ffi::OsStr;
use std::hash::{DefaultHasher, Hash, Hasher};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, LazyLock, Mutex};
@ -328,10 +327,10 @@ where
fn operate(
&mut self,
tree: &mut Tree,
_tree: &mut Tree,
_layout: Layout<'_>,
_renderer: &crate::Renderer,
operation: &mut dyn iced_core::widget::Operation,
_operation: &mut dyn iced_core::widget::Operation,
) {
// TODO: double check operation handling
// let state = tree.state.downcast_mut::<State>();
@ -343,7 +342,7 @@ where
tree: &'b mut Tree,
layout: Layout<'b>,
renderer: &crate::Renderer,
viewport: &Rectangle,
_viewport: &Rectangle,
translation: Vector,
) -> Option<overlay::Element<'b, Message, crate::Theme, crate::Renderer>> {
#[cfg(all(feature = "wayland", target_os = "linux"))]
@ -452,7 +451,7 @@ impl super::operation::Dropdown for State {
/// Computes the layout of a [`Dropdown`].
#[allow(clippy::too_many_arguments)]
pub fn layout(
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
limits: &layout::Limits,
width: Length,
gap: f32,
@ -546,7 +545,7 @@ pub fn update<
cursor: mouse::Cursor,
shell: &mut Shell<'_, Message>,
#[cfg(all(feature = "wayland", target_os = "linux"))]
positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner,
_positioner: iced_runtime::platform_specific::wayland::popup::SctkPositioner,
on_selected: Arc<dyn Fn(usize) -> Message + Send + Sync + 'static>,
selected: Option<usize>,
selections: &[S],
@ -558,7 +557,7 @@ pub fn update<
gap: f32,
padding: Padding,
text_size: Option<f32>,
font: Option<crate::font::Font>,
_font: Option<crate::font::Font>,
selected_option: Option<usize>,
) {
let state = state();

View file

@ -3,7 +3,7 @@
use crate::{Element, Renderer};
use derive_setters::Setters;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::widget::{Operation, Tree};
use iced_core::{
Clipboard, Layout, Length, Padding, Rectangle, Shell, Vector, Widget, layout, mouse, overlay,

View file

@ -3,7 +3,7 @@
use crate::{Element, Renderer};
use derive_setters::Setters;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::widget::{Operation, Tree};
use iced_core::{
Alignment, Clipboard, Layout, Length, Padding, Rectangle, Shell, Vector, Widget, layout, mouse,

View file

@ -5,7 +5,7 @@
/// Icon bundling is not enabled on unix platforms.
#[cfg(all(unix, not(target_os = "macos")))]
pub fn get(icon_name: &str) -> Option<super::Data> {
pub fn get(_icon_name: &str) -> Option<super::Data> {
None
}

View file

@ -1,4 +1,4 @@
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;

View file

@ -1,7 +1,7 @@
use crate::Theme;
use cosmic_theme::LayeredTheme;
use iced::widget::Container;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;

View file

@ -21,12 +21,11 @@ use crate::{
style::menu_bar::StyleSheet,
widget::{
RcWrapper,
dropdown::menu::{self, State},
menu::menu_inner::init_root_menu,
},
};
use iced::{Point, Shadow, Vector, event::Status, window};
use iced::{Point, Shadow, Vector, window};
use iced_core::Border;
use iced_widget::core::{
Alignment, Clipboard, Element, Layout, Length, Padding, Rectangle, Shell, Widget, event,
@ -754,7 +753,7 @@ where
tree: &'b mut Tree,
layout: Layout<'b>,
_renderer: &Renderer,
viewport: &Rectangle,
_viewport: &Rectangle,
translation: Vector,
) -> Option<overlay::Element<'b, Message, crate::Theme, Renderer>> {
#[cfg(all(

View file

@ -558,10 +558,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
) -> Option<(usize, MenuState)> {
use event::{
Event::{Mouse, Touch},
Status::{Captured, Ignored},
};
use event::Event::{Mouse, Touch};
use mouse::{
Button::Left,
Event::{ButtonPressed, ButtonReleased, CursorMoved, WheelScrolled},
@ -581,7 +578,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
let viewport_size = viewport.size();
let overlay_offset = Point::ORIGIN - viewport.position();
let overlay_cursor = view_cursor.position().unwrap_or_default() - overlay_offset;
let menu_roots = match &mut self.menu_roots {
let _menu_roots = match &mut self.menu_roots {
Cow::Borrowed(_) => panic!(),
Cow::Owned(o) => o.as_mut_slice(),
};
@ -951,7 +948,7 @@ impl<Message: std::clone::Clone + 'static> Widget<Message, crate::Theme, crate::
#[allow(clippy::too_many_lines)]
fn update(
&mut self,
tree: &mut Tree,
_tree: &mut Tree,
event: &iced::Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
@ -969,21 +966,21 @@ impl<Message: std::clone::Clone + 'static> Widget<Message, crate::Theme, crate::
target_os = "linux"
))]
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland))
&& let Some((new_root, new_ms)) = new_root
&& let Some((new_root, _new_ms)) = new_root
{
use iced_runtime::platform_specific::wayland::popup::{
SctkPopupSettings, SctkPositioner,
};
let overlay_offset = Point::ORIGIN - viewport.position();
let overlay_cursor = cursor.position().unwrap_or_default() - overlay_offset;
let _overlay_cursor = cursor.position().unwrap_or_default() - overlay_offset;
let Some((mut menu, popup_id)) = self.tree.inner.with_data_mut(|state| {
let popup_id = *state
.popup_id
.entry(self.window_id)
.or_insert_with(window::Id::unique);
let active_roots = state
let _active_roots = state
.active_root
.get(self.depth)
.cloned()
@ -997,7 +994,7 @@ impl<Message: std::clone::Clone + 'static> Widget<Message, crate::Theme, crate::
.map(|lo| lo.bounds())
.collect();
let mut popup_menu = Menu {
let popup_menu = Menu {
tree: self.tree.clone(),
menu_roots: Cow::Owned(Cow::into_owned(self.menu_roots.clone())),
bounds_expand: self.bounds_expand,
@ -1603,7 +1600,7 @@ fn process_scroll_events<Message>(
) where
Message: Clone,
{
use event::Status::{Captured, Ignored};
use mouse::ScrollDelta;
menu.tree.inner.with_data_mut(|state| {

View file

@ -119,8 +119,6 @@ pub mod calendar;
pub use calendar::{Calendar, calendar};
pub mod card;
#[doc(inline)]
pub use card::*;
pub mod color_picker;
#[doc(inline)]

View file

@ -4,7 +4,7 @@
//! A container which displays an overlay when a popup widget is attached.
use iced::widget;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;

View file

@ -1,7 +1,7 @@
//! Create choices using radio buttons.
use crate::{Theme, theme};
use iced::border;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;

View file

@ -5,7 +5,7 @@ use iced::futures::channel::mpsc::UnboundedSender;
use iced::widget::Container;
pub use subscription::*;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;

View file

@ -1,7 +1,7 @@
//! Responsive Container, which will notify of size changes.
use iced::{Limits, Size};
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;

View file

@ -21,12 +21,12 @@ use apply::Apply;
use iced::Limits;
use iced::clipboard::dnd::{DndAction, DndEvent, OfferEvent, SourceEvent};
use iced::clipboard::mime::AsMimeTypes;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::input_method::{self, InputMethod, Preedit};
use iced_core::mouse::{self, click};
use iced_core::overlay::Group;
use iced_core::renderer::{self, Renderer as CoreRenderer};
use iced_core::text::{self, Affinity, Paragraph, Renderer, Text};
use iced_core::text::{self, Paragraph, Renderer, Text};
use iced_core::time::{Duration, Instant};
use iced_core::touch;
use iced_core::widget::Id;
@ -829,7 +829,7 @@ where
&mut self,
tree: &mut Tree,
layout: Layout<'_>,
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
operation: &mut dyn Operation,
) {
operation.container(Some(&self.id), layout.bounds());
@ -921,7 +921,7 @@ where
// 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(
let _res = trailing_icon.as_widget_mut().update(
tree,
event,
trailing_layout,
@ -2220,7 +2220,7 @@ pub fn update<'a, Message: Clone + 'static>(
)) if *rectangle == Some(dnd_id) => {
cold();
let state = state();
let is_clicked = text_layout.bounds().contains(Point {
let _is_clicked = text_layout.bounds().contains(Point {
x: *x as f32,
y: *y as f32,
});
@ -2228,7 +2228,7 @@ pub fn update<'a, Message: Clone + 'static>(
let mut accepted = false;
for m in mime_types {
if SUPPORTED_TEXT_MIME_TYPES.contains(&m.as_str()) {
let clone = m.clone();
let _clone = m.clone();
accepted = true;
}
}
@ -2291,7 +2291,7 @@ pub fn update<'a, Message: Clone + 'static>(
cold();
let state = state();
if let DndOfferState::HandlingOffer(mime_types, _action) = state.dnd_offer.clone() {
let Some(mime_type) = SUPPORTED_TEXT_MIME_TYPES
let Some(_mime_type) = SUPPORTED_TEXT_MIME_TYPES
.iter()
.find(|&&m| mime_types.iter().any(|t| t == m))
else {
@ -2308,7 +2308,7 @@ pub fn update<'a, Message: Clone + 'static>(
Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != *id => {}
#[cfg(all(feature = "wayland", target_os = "linux"))]
Event::Dnd(DndEvent::Offer(
rectangle,
_rectangle,
OfferEvent::Leave | OfferEvent::LeaveDestination,
)) => {
cold();
@ -2611,7 +2611,7 @@ pub fn draw<'a, Message>(
let handling_dnd_offer = !matches!(state.dnd_offer, DndOfferState::None);
#[cfg(not(all(feature = "wayland", target_os = "linux")))]
let handling_dnd_offer = false;
let (cursors, offset, is_selecting) = if let Some(focus) =
let (cursors, offset, _is_selecting) = if let Some(focus) =
state.is_focused.filter(|f| f.focused).or_else(|| {
let now = Instant::now();
handling_dnd_offer.then_some(Focus {

View file

@ -6,7 +6,7 @@ use iced_core::layout::Node;
use iced_core::Element;
use iced_core::Overlay;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::layout;
use iced_core::mouse;
use iced_core::overlay;
@ -154,7 +154,7 @@ where
translation,
)
} else {
let bounds = layout.bounds();
let _bounds = layout.bounds();
Some(overlay::Element::new(Box::new(ToasterOverlay::new(
&mut state.children[1],

View file

@ -1,11 +1,10 @@
//! Show toggle controls using togglers.
use std::time::{Duration, Instant};
use std::time::Duration;
use crate::{Element, anim};
use iced_core::{
Border, Clipboard, Event, Layout, Length, Pixels, Rectangle, Shell, Size, Widget, alignment,
event, layout, mouse,
Border, Clipboard, Event, Layout, Length, Pixels, Rectangle, Shell, Size, Widget, alignment, layout, mouse,
renderer::{self, Renderer},
text, touch,
widget::{self, Tree, tree},
@ -13,7 +12,7 @@ use iced_core::{
};
use iced_widget::{Id, toggler::Status};
pub use iced_widget::toggler::{Catalog, Style};
pub use iced_widget::toggler::Catalog;
pub fn toggler<'a, Message>(is_checked: bool) -> Toggler<'a, Message> {
Toggler::new(is_checked)
@ -261,7 +260,7 @@ impl<'a, Message> Widget<Message, crate::Theme, crate::Renderer> for Toggler<'a,
shell.capture_event();
}
}
Event::Window(window::Event::RedrawRequested(now)) => {
Event::Window(window::Event::RedrawRequested(_now)) => {
state.anim.anim_done(self.duration);
if state.anim.last_change.is_some() {
shell.request_redraw();
@ -371,7 +370,7 @@ impl<'a, Message> Widget<Message, crate::Theme, crate::Renderer> for Toggler<'a,
},
style.background,
);
let mut t = state.anim.t(self.duration, self.is_toggled);
let t = state.anim.t(self.duration, self.is_toggled);
let toggler_foreground_bounds = Rectangle {
x: bounds.x

View file

@ -13,7 +13,7 @@ use std::time::Duration;
use iced::Task;
use iced_runtime::core::widget::Id;
use iced_core::event::{self, Event};
use iced_core::event::Event;
use iced_core::renderer;
use iced_core::touch;
use iced_core::widget::Operation;
@ -310,7 +310,7 @@ impl<'a, Message: 'static + Clone, TopLevelMessage: 'static + Clone>
}
let content_layout = layout.children().next().unwrap();
let state = tree.state.downcast_ref::<State>();
let _state = tree.state.downcast_ref::<State>();
let styling = theme.style(&self.style);

View file

@ -6,7 +6,7 @@ use std::{
};
use crate::Element;
use iced::{Length, Rectangle, Size, event};
use iced::{Length, Rectangle, Size};
use iced_core::{Widget, id::Id, widget, widget::tree};
#[derive(Debug)]