From 260a64cf628ef0255e7dfccd3312c5aded0df520 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 01:55:23 +0000 Subject: [PATCH] Clippy: lints the gate denies in ui-contract and window (identical if blocks, then_some, an Option mask in the icon trial, items after the test module); the it tests name epaint_default_fonts' special emojis and use Id::unique --- .../src/primitives/text_adapter.rs | 4 +--- crates/ui-contract/src/runtime/wheel.rs | 2 +- crates/ui-contract/src/testing/icon_trials.rs | 4 ++-- .../ui-contract/tests/it/fonts/on_demand.rs | 2 +- crates/ui-contract/tests/it/layout/fill.rs | 3 +-- crates/ui-contract/tests/it/runtime/wheel.rs | 8 +++---- crates/ui-contract/tests/it/text/input_cap.rs | 2 +- crates/window/src/policy.rs | 22 +++++++++---------- 8 files changed, 22 insertions(+), 25 deletions(-) diff --git a/crates/ui-contract/src/primitives/text_adapter.rs b/crates/ui-contract/src/primitives/text_adapter.rs index ca277b143..cb6135c78 100644 --- a/crates/ui-contract/src/primitives/text_adapter.rs +++ b/crates/ui-contract/src/primitives/text_adapter.rs @@ -473,9 +473,7 @@ pub(crate) fn run(state: &mut TextState, mut input: AdapterIn<'_>) -> AdapterOut if input.options.multiline() { input.intents.take(Intent::SubmitForce); } - } else if separated { - state.end = Some(End::Separator); - } else if stepped && state.end.is_none() { + } else if separated || (stepped && state.end.is_none()) { state.end = Some(End::Separator); } else if shown.lost_focus && !input.held && state.draft.is_some() && state.end.is_none() { state.end = Some(End::Blur); diff --git a/crates/ui-contract/src/runtime/wheel.rs b/crates/ui-contract/src/runtime/wheel.rs index ad29d162c..fd97d573f 100644 --- a/crates/ui-contract/src/runtime/wheel.rs +++ b/crates/ui-contract/src/runtime/wheel.rs @@ -132,7 +132,7 @@ pub(crate) fn begin(ctx: &Context) { } // A value control that owns the running gesture hears its end without a timer of its own: a pass at the gap. let value_owner = state.gesture.owner.is_some_and(|owner| state.last.iter().any(|taker| taker.owner == owner && taker.value)); - (value_owner && state.gesture.runs(now)).then(|| state.gesture.last + GESTURE_GAP - now) + (value_owner && state.gesture.runs(now)).then_some(state.gesture.last + GESTURE_GAP - now) }); if let Some(seconds) = wake { repaint::request_after(ctx, viewport, seconds.max(0.0)); diff --git a/crates/ui-contract/src/testing/icon_trials.rs b/crates/ui-contract/src/testing/icon_trials.rs index e7241483e..b6e620d16 100644 --- a/crates/ui-contract/src/testing/icon_trials.rs +++ b/crates/ui-contract/src/testing/icon_trials.rs @@ -23,8 +23,8 @@ fn icon(name: &'static str) -> Option { SvgIcon::of(&tokens, Direction::Ltr, 24.0, &IconId::from(std::borrow::Cow::Borrowed(name)), IconSet::default(), Mirror::Auto) } -fn mask(name: &'static str) -> ColorImage { - icon(name).expect("the name resolves").mask(24.0, 1.0) +fn mask(name: &'static str) -> Option { + icon(name).map(|icon| icon.mask(24.0, 1.0)) } #[trial] diff --git a/crates/ui-contract/tests/it/fonts/on_demand.rs b/crates/ui-contract/tests/it/fonts/on_demand.rs index 4f9061a6a..e91bb1c23 100644 --- a/crates/ui-contract/tests/it/fonts/on_demand.rs +++ b/crates/ui-contract/tests/it/fonts/on_demand.rs @@ -340,7 +340,7 @@ fn the_deflated_defaults_are_eguis_default_faces_and_draw_its_icons() { frames.frame(vec![], |_| {}); } for family in [FontId::proportional(14.0), FontId::monospace(14.0)] { - for icon in [egui::special_emojis::GITHUB, egui::special_emojis::OS_LINUX] { + for icon in [epaint_default_fonts::special_emojis::GITHUB, epaint_default_fonts::special_emojis::OS_LINUX] { assert!(frames.ctx.fonts_mut(|f| f.has_glyph(&family, icon)), "{icon} in {:?}", family.family); } } diff --git a/crates/ui-contract/tests/it/layout/fill.rs b/crates/ui-contract/tests/it/layout/fill.rs index f8091d924..84557b9ab 100644 --- a/crates/ui-contract/tests/it/layout/fill.rs +++ b/crates/ui-contract/tests/it/layout/fill.rs @@ -207,8 +207,7 @@ fn in_line() -> [Rect; 3] { }); }); fixture.room(Vec2::splat(800.0)).settle(); - let rects = [tall.borrow().rect, held.get(), leaf.borrow().rect]; - rects + [tall.borrow().rect, held.get(), leaf.borrow().rect] } #[trial] diff --git a/crates/ui-contract/tests/it/runtime/wheel.rs b/crates/ui-contract/tests/it/runtime/wheel.rs index 7a5536db6..56b6e4090 100644 --- a/crates/ui-contract/tests/it/runtime/wheel.rs +++ b/crates/ui-contract/tests/it/runtime/wheel.rs @@ -57,7 +57,7 @@ fn a_fractional_ctrl_wheel_is_a_pinch_and_a_whole_notch_stays_a_scroll() { for os in [Os::Windows, Os::Linux, Os::Mac] { let seen = Rc::new(RefCell::new(Vec::new())); let shares = Rc::clone(&seen); - let view = Id::new("pinch_view"); + let view = Id::unique("pinch_view"); let mut fixture = Fixture::new(move |ui| { register(ui.ctx(), WheelTaker::new(view, Rect::from_min_size(Pos2::ZERO, Vec2::new(400.0, 300.0))).vertical(true).zoom(true)); shares.borrow_mut().extend(take_share(ui.ctx(), view)); @@ -101,9 +101,9 @@ fn a_fractional_ctrl_wheel_is_a_pinch_and_a_whole_notch_stays_a_scroll() { #[trial] fn a_wheel_gesture_ends_for_a_value_control_in_any_wheel_scope_and_not_for_a_scroll_region_or_the_canvas() { - let panel = Id::new("gesture_panel"); - let slider = Id::new("gesture_slider"); - let canvas = Id::new("gesture_canvas"); + let panel = Id::unique("gesture_panel"); + let slider = Id::unique("gesture_slider"); + let canvas = Id::unique("gesture_canvas"); let seen: RefCell> = RefCell::new(Vec::new()); let mut show_frame = |ui: &mut egui::Ui| { let ctx = ui.ctx(); diff --git a/crates/ui-contract/tests/it/text/input_cap.rs b/crates/ui-contract/tests/it/text/input_cap.rs index 99958abab..d7e08e44a 100644 --- a/crates/ui-contract/tests/it/text/input_cap.rs +++ b/crates/ui-contract/tests/it/text/input_cap.rs @@ -143,7 +143,7 @@ fn oversized_text_events_are_cut_before_components_see_them() { assert_eq!(composing(&inside), Some((INPUT_TEXT_LIMIT, Some(2..4))), "a range inside the cut stays"); // A paste reaches an app's own focused widget cut too. - let field = Id::new("app_field"); + let field = Id::unique("app_field"); let pasted = RefCell::new(None); let mut frames = Frames::new(); let mut host = |ui: &mut egui::Ui| { diff --git a/crates/window/src/policy.rs b/crates/window/src/policy.rs index f08cbcd6d..6873c5710 100644 --- a/crates/window/src/policy.rs +++ b/crates/window/src/policy.rs @@ -287,6 +287,17 @@ pub fn apply(builder: egui::ViewportBuilder, frame: &Frame) -> egui::ViewportBui } } +impl From<&crate::Frame> for Frame { + /// The old two-way frame as a new one: `Desktop` is `Native`, `App(layout)` is integrated + /// with generic captions. + fn from(old: &crate::Frame) -> Self { + match old { + crate::Frame::Desktop => Frame::Native, + crate::Frame::App(layout) => Frame::Integrated(Captions { family: CaptionFamily::Generic, layout: layout.clone() }), + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -333,14 +344,3 @@ mod tests { assert_eq!(decided(TitleBarPref::System, Some("breeze"), Some("close:")), Frame::Native, "a native frame has no captions to change"); } } - -impl From<&crate::Frame> for Frame { - /// The old two-way frame as a new one: `Desktop` is `Native`, `App(layout)` is integrated - /// with generic captions. - fn from(old: &crate::Frame) -> Self { - match old { - crate::Frame::Desktop => Frame::Native, - crate::Frame::App(layout) => Frame::Integrated(Captions { family: CaptionFamily::Generic, layout: layout.clone() }), - } - } -}