From 2bc2fb9c393bbbfc4832a35af1c100bc4ea48719 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 6 Oct 2023 09:01:31 +0200 Subject: [PATCH] Fix some lints found by clippy 1.73 --- crates/egui/src/containers/resize.rs | 4 ++-- crates/egui/src/containers/window.rs | 15 +++++---------- crates/egui/src/context.rs | 2 +- crates/egui/src/grid.rs | 6 +++--- crates/egui/src/menu.rs | 2 +- crates/egui/src/widgets/color_picker.rs | 2 +- crates/egui/src/widgets/image.rs | 4 ++-- crates/egui/src/widgets/slider.rs | 2 +- crates/egui/src/widgets/text_edit/builder.rs | 6 +++--- crates/egui_demo_app/src/backend_panel.rs | 2 +- crates/epaint/src/text/text_layout.rs | 2 +- 11 files changed, 21 insertions(+), 26 deletions(-) diff --git a/crates/egui/src/containers/resize.rs b/crates/egui/src/containers/resize.rs index e991e4e1..78917234 100644 --- a/crates/egui/src/containers/resize.rs +++ b/crates/egui/src/containers/resize.rs @@ -332,12 +332,12 @@ impl Resize { use epaint::Stroke; -pub fn paint_resize_corner(ui: &mut Ui, response: &Response) { +pub fn paint_resize_corner(ui: &Ui, response: &Response) { let stroke = ui.style().interact(response).fg_stroke; paint_resize_corner_with_style(ui, &response.rect, stroke, Align2::RIGHT_BOTTOM); } -pub fn paint_resize_corner_with_style(ui: &mut Ui, rect: &Rect, stroke: Stroke, corner: Align2) { +pub fn paint_resize_corner_with_style(ui: &Ui, rect: &Rect, stroke: Stroke, corner: Align2) { let painter = ui.painter(); let cp = painter.round_pos_to_pixels(corner.pos_in_rect(rect)); let mut w = 2.0; diff --git a/crates/egui/src/containers/window.rs b/crates/egui/src/containers/window.rs index aa3fad11..c12199d4 100644 --- a/crates/egui/src/containers/window.rs +++ b/crates/egui/src/containers/window.rs @@ -429,7 +429,7 @@ impl<'open> Window<'open> { .map_or((None, None), |ir| (Some(ir.inner), Some(ir.response))); let outer_rect = frame.end(&mut area_content_ui).rect; - paint_resize_corner(&mut area_content_ui, &possible, outer_rect, frame_stroke); + paint_resize_corner(&area_content_ui, &possible, outer_rect, frame_stroke); // END FRAME -------------------------------- @@ -448,7 +448,7 @@ impl<'open> Window<'open> { if let Some(interaction) = interaction { paint_frame_interaction( - &mut area_content_ui, + &area_content_ui, outer_rect, interaction, ctx.style().visuals.widgets.active, @@ -456,7 +456,7 @@ impl<'open> Window<'open> { } else if let Some(hover_interaction) = hover_interaction { if ctx.input(|i| i.pointer.has_pointer()) { paint_frame_interaction( - &mut area_content_ui, + &area_content_ui, outer_rect, hover_interaction, ctx.style().visuals.widgets.hovered, @@ -476,12 +476,7 @@ impl<'open> Window<'open> { } } -fn paint_resize_corner( - ui: &mut Ui, - possible: &PossibleInteractions, - outer_rect: Rect, - stroke: Stroke, -) { +fn paint_resize_corner(ui: &Ui, possible: &PossibleInteractions, outer_rect: Rect, stroke: Stroke) { let corner = if possible.resize_right && possible.resize_bottom { Align2::RIGHT_BOTTOM } else if possible.resize_left && possible.resize_bottom { @@ -758,7 +753,7 @@ fn resize_hover( /// Fill in parts of the window frame when we resize by dragging that part fn paint_frame_interaction( - ui: &mut Ui, + ui: &Ui, rect: Rect, interaction: WindowInteraction, visuals: style::WidgetVisuals, diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 0900a111..27060021 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1284,7 +1284,7 @@ impl Context { }); #[cfg_attr(not(feature = "accesskit"), allow(unused_mut))] - let mut platform_output: PlatformOutput = self.output_mut(|o| std::mem::take(o)); + let mut platform_output: PlatformOutput = self.output_mut(std::mem::take); #[cfg(feature = "accesskit")] { diff --git a/crates/egui/src/grid.rs b/crates/egui/src/grid.rs index 3e3e1df9..fe8f952b 100644 --- a/crates/egui/src/grid.rs +++ b/crates/egui/src/grid.rs @@ -221,7 +221,7 @@ impl GridLayout { self.col += 1; } - fn paint_row(&mut self, cursor: &mut Rect, painter: &Painter) { + fn paint_row(&mut self, cursor: &Rect, painter: &Painter) { // handle row color painting based on color-picker function let Some(color_picker) = self.color_picker.as_ref() else { return; @@ -433,9 +433,9 @@ impl Grid { // paint first incoming row if is_color { - let mut cursor = ui.cursor(); + let cursor = ui.cursor(); let painter = ui.painter(); - grid.paint_row(&mut cursor, painter); + grid.paint_row(&cursor, painter); } ui.set_grid(grid); diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index 55f60e52..410d6b2e 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -608,7 +608,7 @@ impl MenuState { } /// Sense button interaction opening and closing submenu. - fn submenu_button_interaction(&mut self, ui: &mut Ui, sub_id: Id, button: &Response) { + fn submenu_button_interaction(&mut self, ui: &Ui, sub_id: Id, button: &Response) { let pointer = ui.input(|i| i.pointer.clone()); let open = self.is_open(sub_id); if self.moving_towards_current_submenu(&pointer) { diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index aed95479..5958d075 100644 --- a/crates/egui/src/widgets/color_picker.rs +++ b/crates/egui/src/widgets/color_picker.rs @@ -317,7 +317,7 @@ fn color_picker_hsvag_2d(ui: &mut Ui, hsva: &mut HsvaGamma, alpha: Alpha) { color_slider_2d(ui, s, v, |s, v| HsvaGamma { s, v, ..opaque }.into()); } -//// Shows a color picker where the user can change the given [`Hsva`] color. +/// Shows a color picker where the user can change the given [`Hsva`] color. /// /// Returns `true` on change. pub fn color_picker_hsva_2d(ui: &mut Ui, hsva: &mut Hsva, alpha: Alpha) -> bool { diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs index c1838b46..2bf150c9 100644 --- a/crates/egui/src/widgets/image.rs +++ b/crates/egui/src/widgets/image.rs @@ -269,7 +269,7 @@ impl<'a> Image<'a> { self.size.calc_size(available_size, original_image_size) } - pub fn load_and_calc_size(&self, ui: &mut Ui, available_size: Vec2) -> Option { + pub fn load_and_calc_size(&self, ui: &Ui, available_size: Vec2) -> Option { let image_size = self.load_for_size(ui.ctx(), available_size).ok()?.size()?; Some(self.size.calc_size(available_size, image_size)) } @@ -317,7 +317,7 @@ impl<'a> Image<'a> { /// # }); /// ``` #[inline] - pub fn paint_at(&self, ui: &mut Ui, rect: Rect) { + pub fn paint_at(&self, ui: &Ui, rect: Rect) { paint_texture_load_result( ui, &self.load_for_size(ui.ctx(), rect.size()), diff --git a/crates/egui/src/widgets/slider.rs b/crates/egui/src/widgets/slider.rs index 1d4c5f8d..72bceb32 100644 --- a/crates/egui/src/widgets/slider.rs +++ b/crates/egui/src/widgets/slider.rs @@ -548,7 +548,7 @@ impl<'a> Slider<'a> { } /// Just the slider, no text - fn slider_ui(&mut self, ui: &mut Ui, response: &Response) { + fn slider_ui(&mut self, ui: &Ui, response: &Response) { let rect = &response.rect; let position_range = self.position_range(rect); diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index f07beede..7de4733a 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -876,7 +876,7 @@ fn ccursor_from_accesskit_text_position( /// Check for (keyboard) events to edit the cursor and/or text. #[allow(clippy::too_many_arguments)] fn events( - ui: &mut crate::Ui, + ui: &crate::Ui, state: &mut TextEditState, text: &mut dyn TextBuffer, galley: &mut Arc, @@ -1089,7 +1089,7 @@ fn events( // ---------------------------------------------------------------------------- fn paint_cursor_selection( - ui: &mut Ui, + ui: &Ui, painter: &Painter, pos: Pos2, galley: &Galley, @@ -1131,7 +1131,7 @@ fn paint_cursor_selection( } fn paint_cursor_end( - ui: &mut Ui, + ui: &Ui, row_height: f32, painter: &Painter, pos: Pos2, diff --git a/crates/egui_demo_app/src/backend_panel.rs b/crates/egui_demo_app/src/backend_panel.rs index ae733615..fb0d9ae4 100644 --- a/crates/egui_demo_app/src/backend_panel.rs +++ b/crates/egui_demo_app/src/backend_panel.rs @@ -62,7 +62,7 @@ pub struct BackendPanel { } impl BackendPanel { - pub fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { + pub fn update(&mut self, ctx: &egui::Context, frame: &eframe::Frame) { self.frame_history .on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage); diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index e36ee1ea..9b055edc 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -665,7 +665,7 @@ fn tessellate_row( point_scale: PointScale, job: &LayoutJob, format_summary: &FormatSummary, - row: &mut Row, + row: &Row, ) -> RowVisuals { if row.glyphs.is_empty() { return Default::default();