yoda: libcosmic-yoda dead-code purge (14→0 warnings)

Real bug fixes:
- spin_button::vertical(): was constructing the SpinButton with
  Orientation::Horizontal — vertical() rendered horizontally. Fixed
  to use Orientation::Vertical, which also resolves the
  'Vertical never constructed' warning.
- text_input/input.rs: rewrite the iterator-skip logic for trailing
  icon layout. The previous `let mut icon_layout = ...; if has_start
  ... = ...; ... = ...;` triggered two value-never-read warnings and
  obscured the intent. Now it reads as 'skip text, optionally skip
  start-icon, then take the trailing-icon layout'.

Dead code removed:
- core::Core::portal_is_high_contrast — assigned at construction,
  never read anywhere
- widget::menu::menu_bar::bar_pressed field and the
  pub fn get_mut_or_default helper — no callers
- widget::popover::State — declared, never constructed
- widget::segmented_button::widget::Focus.now — sibling of updated_at,
  never read
- widget::wayland::tooltip::widget::Variant — orphan enum (and the
  cargo fix follow-up dropped a now-unused Element import)
- widget::button::widget::Button::is_hovered method — trivial getter
  with no callers; the underlying `is_hovered` field is still used

Visibility / nits:
- segmented_button::widget::TabDragSource: gain pub(super) so the
  pub(super) field tab_drag stops exposing a more private type
- widget::menu::flex::resolve: #[allow(dead_code)] (170-line public
  helper, kept for future use)
- app/cosmic.rs: drop one unreachable arm in the surface-message match
- widget::dropdown::multi: drop unused Paragraph import

Leyoda 2026 – GPLv3
This commit is contained in:
Lionel DARNIS 2026-05-05 19:02:31 +02:00
parent a9492d764c
commit 84437e219b
11 changed files with 8 additions and 43 deletions

View file

@ -364,7 +364,6 @@ where
crate::surface::Action::Task(f) => {
f().map(|sm| crate::Action::Cosmic(Action::Surface(sm)))
}
_ => iced::Task::none(),
}
#[cfg(not(feature = "surface-message"))]

View file

@ -78,8 +78,6 @@ pub struct Core {
pub(super) portal_accent: Option<Srgba>,
pub(super) portal_is_high_contrast: Option<bool>,
pub(super) title: HashMap<Id, String>,
pub window: Window,
@ -155,7 +153,6 @@ impl Default for Core {
settings_daemon: None,
portal_is_dark: None,
portal_accent: None,
portal_is_high_contrast: None,
main_window: None,
exit_on_main_window_closed: true,
menu_bars: HashMap::new(),

View file

@ -748,12 +748,6 @@ impl State {
self.is_focused
}
/// Returns whether the [`Button`] is currently hovered or not.
#[inline]
pub fn is_hovered(self) -> bool {
self.is_hovered
}
/// Focuses the [`Button`].
#[inline]
pub fn focus(&mut self) {

View file

@ -6,7 +6,7 @@ use super::menu::{self, Menu};
use crate::widget::icon;
use derive_setters::Setters;
use iced_core::event::Event;
use iced_core::text::{self, Paragraph, Text};
use iced_core::text::{self, Text};
use iced_core::widget::tree::{self, Tree};
use iced_core::{
Clipboard, Layout, Length, Padding, Pixels, Rectangle, Shell, Size, Vector, Widget,

View file

@ -50,6 +50,7 @@ impl Axis {
/// padding and alignment to the items as needed.
///
/// It returns a new layout [`Node`].
#[allow(dead_code)] // kept as public helper; not currently called by libcosmic
pub fn resolve<'a, E, Message, Renderer>(
axis: &Axis,
renderer: &Renderer,

View file

@ -54,7 +54,6 @@ pub(crate) struct MenuBarStateInner {
pub(crate) tree: Tree,
pub(crate) popup_id: HashMap<window::Id, window::Id>,
pub(crate) pressed: bool,
pub(crate) bar_pressed: bool,
pub(crate) view_cursor: Cursor,
pub(crate) open: bool,
pub(crate) active_root: Vec<usize>,
@ -91,7 +90,6 @@ impl Default for MenuBarStateInner {
vertical_direction: Direction::Positive,
menu_states: Vec::new(),
popup_id: HashMap::new(),
bar_pressed: false,
}
}
}
@ -168,14 +166,6 @@ where
}
}
pub fn get_mut_or_default<T: Default>(vec: &mut Vec<T>, index: usize) -> &mut T {
if index < vec.len() {
&mut vec[index]
} else {
vec.resize_with(index + 1, T::default);
&mut vec[index]
}
}
/// A `MenuBar` collects `MenuTree`s and handles all the layout, event processing, and drawing.
#[allow(missing_debug_implementations)]

View file

@ -476,12 +476,6 @@ where
}
}
/// The local state of a [`Popover`].
#[derive(Debug, Default)]
struct State {
is_open: bool,
}
/// The first child in [`Popover::children`] is always the wrapped content.
fn content_tree(tree: &Tree) -> &Tree {
&tree.children[0]

View file

@ -2364,7 +2364,7 @@ where
}
}
struct TabDragSource<Message> {
pub(super) struct TabDragSource<Message> {
mime: String,
threshold: f32,
_marker: PhantomData<Message>,
@ -2415,7 +2415,6 @@ struct TabDragCandidate {
#[derive(Debug, Clone, Copy)]
struct Focus {
updated_at: Instant,
now: Instant,
}
/// State that is maintained by each individual widget.
@ -2488,7 +2487,6 @@ impl LocalState {
self.focused = Some(Focus {
updated_at: now,
now,
});
}
}

View file

@ -63,7 +63,7 @@ where
step,
min,
max,
Orientation::Horizontal,
Orientation::Vertical,
on_press,
);

View file

@ -2794,11 +2794,11 @@ pub fn draw<'a, Message>(
// draw the end icon in the text input
if let (Some(icon), Some(tree)) = (trailing_icon, trailing_icon_tree) {
let mut children = text_layout.children();
let mut icon_layout = children.next().unwrap();
children.next().unwrap(); // skip text layout
if has_start_icon {
icon_layout = children.next().unwrap();
children.next().unwrap(); // skip start-icon layout
}
icon_layout = children.next().unwrap();
let icon_layout = children.next().unwrap(); // trailing-icon layout
icon.as_widget().draw(
tree,

View file

@ -23,18 +23,10 @@ use iced_core::{
};
use iced_core::{Border, mouse};
use iced_core::{Shadow, overlay};
use iced_core::{layout, svg};
use iced_core::layout;
pub use super::{Catalog, Style};
/// Internally defines different button widget variants.
enum Variant<Message> {
Normal,
Image {
close_icon: svg::Handle,
on_remove: Option<Message>,
},
}
/// A generic button which emits a message when pressed.
#[allow(missing_debug_implementations)]