From f9245954ebfb599fc77a5a33aa7c90504399faba Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 24 Apr 2025 17:32:50 +0200 Subject: [PATCH] Enable more clippy lints (#6853) * Follows https://github.com/emilk/egui/pull/6848 --- Cargo.toml | 10 ++++++++- crates/ecolor/src/rgba.rs | 3 +-- crates/eframe/src/epi.rs | 10 ++++----- crates/eframe/src/lib.rs | 4 ++-- crates/eframe/src/native/app_icon.rs | 10 ++++----- crates/eframe/src/native/epi_integration.rs | 6 +++--- .../eframe/src/native/event_loop_context.rs | 2 +- crates/eframe/src/native/file_storage.rs | 4 ++-- crates/eframe/src/native/glow_integration.rs | 20 +++++++++--------- crates/eframe/src/native/run.rs | 3 +-- crates/eframe/src/native/wgpu_integration.rs | 5 ++--- crates/eframe/src/web/app_runner.rs | 4 ++-- crates/eframe/src/web/events.rs | 6 +++--- crates/eframe/src/web/mod.rs | 2 +- crates/eframe/src/web/web_logger.rs | 2 +- crates/eframe/src/web/web_painter_glow.rs | 5 +++-- crates/eframe/src/web/web_painter_wgpu.rs | 4 ++-- crates/eframe/src/web/web_runner.rs | 6 +++--- crates/egui-wgpu/src/capture.rs | 5 +++-- crates/egui-wgpu/src/lib.rs | 2 +- crates/egui-wgpu/src/renderer.rs | 6 +++--- crates/egui-wgpu/src/setup.rs | 2 +- crates/egui-wgpu/src/winit.rs | 2 +- crates/egui-winit/src/clipboard.rs | 2 +- crates/egui/src/cache/cache_trait.rs | 2 +- crates/egui/src/containers/area.rs | 6 +++--- .../egui/src/containers/collapsing_header.rs | 2 +- crates/egui/src/containers/combo_box.rs | 6 +++--- crates/egui/src/containers/menu.rs | 3 ++- crates/egui/src/containers/old_popup.rs | 6 +++--- crates/egui/src/containers/panel.rs | 2 +- crates/egui/src/containers/popup.rs | 2 +- crates/egui/src/containers/resize.rs | 4 ++-- crates/egui/src/containers/scene.rs | 2 +- crates/egui/src/containers/scroll_area.rs | 4 ++-- crates/egui/src/context.rs | 21 ++++++++----------- crates/egui/src/data/input.rs | 2 +- crates/egui/src/data/output.rs | 14 ++++++------- crates/egui/src/grid.rs | 6 +++--- crates/egui/src/id.rs | 2 +- crates/egui/src/input_state/mod.rs | 4 ++-- crates/egui/src/introspection.rs | 2 +- crates/egui/src/layout.rs | 2 +- crates/egui/src/load.rs | 2 +- crates/egui/src/load/bytes_loader.rs | 2 +- crates/egui/src/load/texture_loader.rs | 4 ++-- crates/egui/src/menu.rs | 4 ++-- crates/egui/src/os.rs | 2 +- crates/egui/src/painter.rs | 6 +++--- crates/egui/src/pass_state.rs | 2 +- crates/egui/src/style.rs | 7 ++++--- .../text_selection/label_text_selection.rs | 2 +- .../src/text_selection/text_cursor_state.rs | 4 ++-- crates/egui/src/ui.rs | 8 +++---- crates/egui/src/ui_builder.rs | 2 +- crates/egui/src/ui_stack.rs | 2 +- crates/egui/src/util/id_type_map.rs | 2 +- crates/egui/src/viewport.rs | 1 - crates/egui/src/widgets/button.rs | 6 ++---- crates/egui/src/widgets/checkbox.rs | 4 ++-- crates/egui/src/widgets/color_picker.rs | 2 +- crates/egui/src/widgets/drag_value.rs | 6 +++--- crates/egui/src/widgets/hyperlink.rs | 4 ++-- crates/egui/src/widgets/progress_bar.rs | 4 ++-- crates/egui/src/widgets/radio_button.rs | 2 +- crates/egui/src/widgets/selected_label.rs | 4 +++- crates/egui/src/widgets/slider.rs | 4 ++-- crates/egui/src/widgets/text_edit/builder.rs | 6 +++--- crates/egui/src/widgets/text_edit/state.rs | 2 +- .../egui_demo_app/src/apps/custom3d_glow.rs | 2 +- .../egui_demo_app/src/apps/custom3d_wgpu.rs | 2 +- crates/egui_demo_app/src/backend_panel.rs | 2 +- crates/egui_demo_app/src/lib.rs | 2 +- crates/egui_demo_app/src/main.rs | 2 +- crates/egui_demo_app/src/web.rs | 2 +- crates/egui_demo_app/src/wrap_app.rs | 2 +- crates/egui_demo_app/tests/test_demo_app.rs | 2 +- crates/egui_demo_lib/src/demo/code_example.rs | 2 +- .../src/demo/demo_app_windows.rs | 6 +++--- crates/egui_demo_lib/src/demo/font_book.rs | 2 +- .../src/demo/interactive_container.rs | 2 +- crates/egui_demo_lib/src/demo/modals.rs | 6 +++--- crates/egui_demo_lib/src/demo/paint_bezier.rs | 2 +- crates/egui_demo_lib/src/demo/password.rs | 1 - crates/egui_demo_lib/src/demo/screenshot.rs | 2 +- crates/egui_demo_lib/src/demo/scrolling.rs | 4 ++-- .../src/demo/tests/tessellation_test.rs | 2 +- crates/egui_demo_lib/src/demo/text_edit.rs | 2 +- .../egui_demo_lib/src/demo/toggle_switch.rs | 2 +- .../egui_demo_lib/src/demo/widget_gallery.rs | 4 ++-- crates/egui_extras/src/datepicker/mod.rs | 2 +- crates/egui_extras/src/datepicker/popup.rs | 2 +- crates/egui_extras/src/layout.rs | 2 +- crates/egui_extras/src/lib.rs | 2 +- .../egui_extras/src/loaders/image_loader.rs | 2 +- crates/egui_extras/src/loaders/svg_loader.rs | 2 +- crates/egui_extras/src/loaders/webp_loader.rs | 2 +- crates/egui_extras/src/syntax_highlighting.rs | 9 ++++---- crates/egui_glow/examples/pure_glow.rs | 18 ++++++++-------- crates/egui_glow/src/lib.rs | 2 +- crates/egui_glow/src/painter.rs | 4 +--- crates/egui_glow/src/shader_version.rs | 3 +-- crates/egui_glow/src/vao.rs | 1 - crates/egui_kittest/src/snapshot.rs | 9 ++++---- crates/egui_kittest/tests/menu.rs | 2 +- crates/egui_kittest/tests/popup.rs | 2 +- crates/egui_kittest/tests/regression_tests.rs | 4 ++-- crates/egui_kittest/tests/tests.rs | 2 +- crates/emath/src/lib.rs | 2 +- crates/emath/src/numeric.rs | 4 ++-- crates/emath/src/ordered_float.rs | 2 +- crates/emath/src/smart_aim.rs | 2 +- crates/epaint/src/lib.rs | 2 +- crates/epaint/src/shapes/shape.rs | 2 +- crates/epaint/src/tessellator.rs | 6 +++--- crates/epaint/src/text/font.rs | 8 +++---- crates/epaint/src/text/fonts.rs | 1 - crates/epaint/src/text/text_layout.rs | 2 +- crates/epaint/src/text/text_layout_types.rs | 6 +++--- crates/epaint/src/texture_handle.rs | 6 +++--- examples/custom_style/src/main.rs | 2 +- examples/puffin_profiler/src/main.rs | 2 +- tests/egui_tests/tests/test_widgets.rs | 4 ++-- tests/test_inline_glow_paint/src/main.rs | 2 +- 124 files changed, 243 insertions(+), 244 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a7a5ede7..80fee9f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,6 +134,7 @@ broken_intra_doc_links = "warn" # See also clippy.toml [workspace.lints.clippy] +allow_attributes = "warn" as_ptr_cast_mut = "warn" await_holding_lock = "warn" bool_to_int_with_if = "warn" @@ -195,13 +196,13 @@ macro_use_imports = "warn" manual_assert = "warn" manual_clamp = "warn" manual_instant_elapsed = "warn" +manual_is_power_of_two = "warn" manual_is_variant_and = "warn" manual_let_else = "warn" manual_ok_or = "warn" manual_string_new = "warn" map_err_ignore = "warn" map_flatten = "warn" -map_unwrap_or = "warn" match_bool = "warn" match_on_vec_items = "warn" match_same_arms = "warn" @@ -222,11 +223,13 @@ needless_for_each = "warn" needless_pass_by_ref_mut = "warn" needless_pass_by_value = "warn" negative_feature_names = "warn" +non_zero_suggestions = "warn" nonstandard_macro_braces = "warn" option_as_ref_cloned = "warn" option_option = "warn" path_buf_push_overwrite = "warn" print_stderr = "warn" +pathbuf_init_then_push = "warn" ptr_as_ptr = "warn" ptr_cast_constness = "warn" pub_underscore_fields = "warn" @@ -240,6 +243,7 @@ ref_patterns = "warn" rest_pat_in_fully_bound_structs = "warn" same_functions_in_if_condition = "warn" semicolon_if_nothing_returned = "warn" +set_contains_or_insert = "warn" single_char_pattern = "warn" single_match_else = "warn" str_split_at_newline = "warn" @@ -252,6 +256,7 @@ string_to_string = "warn" suspicious_command_arg_space = "warn" suspicious_xor_used_as_pow = "warn" todo = "warn" +too_long_first_doc_paragraph = "warn" trailing_empty_array = "warn" trait_duplication_in_bounds = "warn" tuple_array_conversions = "warn" @@ -261,6 +266,7 @@ unimplemented = "warn" uninhabited_references = "warn" uninlined_format_args = "warn" unnecessary_box_returns = "warn" +unnecessary_literal_bound = "warn" unnecessary_safety_doc = "warn" unnecessary_struct_initialization = "warn" unnecessary_wraps = "warn" @@ -268,6 +274,7 @@ unnested_or_patterns = "warn" unused_peekable = "warn" unused_rounding = "warn" unused_self = "warn" +unused_trait_names = "warn" use_self = "warn" useless_transmute = "warn" verbose_file_reads = "warn" @@ -286,6 +293,7 @@ assigning_clones = "allow" # No please let_underscore_must_use = "allow" let_underscore_untyped = "allow" manual_range_contains = "allow" # this one is just worse imho +map_unwrap_or = "allow" # so is this one self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602 significant_drop_tightening = "allow" # Too many false positives wildcard_imports = "allow" # `use crate::*` is useful to avoid merge conflicts when adding/removing imports diff --git a/crates/ecolor/src/rgba.rs b/crates/ecolor/src/rgba.rs index 99fab41c..3e40af2b 100644 --- a/crates/ecolor/src/rgba.rs +++ b/crates/ecolor/src/rgba.rs @@ -33,12 +33,11 @@ pub(crate) fn f32_hash(state: &mut H, f: f32) { } else if f.is_nan() { state.write_u8(1); } else { - use std::hash::Hash; + use std::hash::Hash as _; f.to_bits().hash(state); } } -#[allow(clippy::derived_hash_with_manual_eq)] impl std::hash::Hash for Rgba { #[inline] fn hash(&self, state: &mut H) { diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 562311dc..fd08fc1e 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -91,7 +91,7 @@ pub struct CreationContext<'s> { pub(crate) raw_display_handle: Result, } -#[allow(unsafe_code)] +#[expect(unsafe_code)] #[cfg(not(target_arch = "wasm32"))] impl HasWindowHandle for CreationContext<'_> { fn window_handle(&self) -> Result, HandleError> { @@ -100,7 +100,7 @@ impl HasWindowHandle for CreationContext<'_> { } } -#[allow(unsafe_code)] +#[expect(unsafe_code)] #[cfg(not(target_arch = "wasm32"))] impl HasDisplayHandle for CreationContext<'_> { fn display_handle(&self) -> Result, HandleError> { @@ -662,7 +662,7 @@ pub struct Frame { #[cfg(not(target_arch = "wasm32"))] assert_not_impl_any!(Frame: Clone); -#[allow(unsafe_code)] +#[expect(unsafe_code)] #[cfg(not(target_arch = "wasm32"))] impl HasWindowHandle for Frame { fn window_handle(&self) -> Result, HandleError> { @@ -671,7 +671,7 @@ impl HasWindowHandle for Frame { } } -#[allow(unsafe_code)] +#[expect(unsafe_code)] #[cfg(not(target_arch = "wasm32"))] impl HasDisplayHandle for Frame { fn display_handle(&self) -> Result, HandleError> { @@ -703,7 +703,7 @@ impl Frame { /// True if you are in a web environment. /// /// Equivalent to `cfg!(target_arch = "wasm32")` - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub fn is_web(&self) -> bool { cfg!(target_arch = "wasm32") } diff --git a/crates/eframe/src/lib.rs b/crates/eframe/src/lib.rs index 7b342a4c..ec27b05a 100644 --- a/crates/eframe/src/lib.rs +++ b/crates/eframe/src/lib.rs @@ -69,7 +69,7 @@ //! #[wasm_bindgen] //! impl WebHandle { //! /// Installs a panic hook, then returns. -//! #[allow(clippy::new_without_default)] +//! #[expect(clippy::new_without_default)] //! #[wasm_bindgen(constructor)] //! pub fn new() -> Self { //! // Redirect [`log`] message to `console.log` and friends: @@ -236,7 +236,7 @@ pub mod icon_data; /// This function can fail if we fail to set up a graphics context. #[cfg(not(target_arch = "wasm32"))] #[cfg(any(feature = "glow", feature = "wgpu"))] -#[allow(clippy::needless_pass_by_value)] +#[allow(clippy::needless_pass_by_value, clippy::allow_attributes)] pub fn run_native( app_name: &str, mut native_options: NativeOptions, diff --git a/crates/eframe/src/native/app_icon.rs b/crates/eframe/src/native/app_icon.rs index 8591ba2a..1f1bf52f 100644 --- a/crates/eframe/src/native/app_icon.rs +++ b/crates/eframe/src/native/app_icon.rs @@ -47,7 +47,7 @@ enum AppIconStatus { NotSetTryAgain, /// We successfully set the icon and it should be visible now. - #[allow(dead_code)] // Not used on Linux + #[allow(dead_code, clippy::allow_attributes)] // Not used on Linux Set, } @@ -71,13 +71,13 @@ fn set_title_and_icon(_title: &str, _icon_data: Option<&IconData>) -> AppIconSta #[cfg(target_os = "macos")] return set_title_and_icon_mac(_title, _icon_data); - #[allow(unreachable_code)] + #[allow(unreachable_code, clippy::allow_attributes)] AppIconStatus::NotSetIgnored } /// Set icon for Windows applications. #[cfg(target_os = "windows")] -#[allow(unsafe_code)] +#[expect(unsafe_code)] fn set_app_icon_windows(icon_data: &IconData) -> AppIconStatus { use crate::icon_data::IconDataExt as _; use winapi::um::winuser; @@ -198,12 +198,12 @@ fn set_app_icon_windows(icon_data: &IconData) -> AppIconStatus { /// Set icon & app title for `MacOS` applications. #[cfg(target_os = "macos")] -#[allow(unsafe_code)] +#[expect(unsafe_code)] fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconStatus { use crate::icon_data::IconDataExt as _; profiling::function_scope!(); - use objc2::ClassType; + use objc2::ClassType as _; use objc2_app_kit::{NSApplication, NSImage}; use objc2_foundation::{NSData, NSString}; diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 03b5f2dc..aaa8c596 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -136,7 +136,7 @@ pub fn create_storage(_app_name: &str) -> Option> { None } -#[allow(clippy::unnecessary_wraps)] +#[expect(clippy::unnecessary_wraps)] pub fn create_storage_with_file(_file: impl Into) -> Option> { #[cfg(feature = "persistence")] return Some(Box::new( @@ -169,7 +169,7 @@ pub struct EpiIntegration { } impl EpiIntegration { - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new( egui_ctx: egui::Context, window: &winit::window::Window, @@ -326,7 +326,7 @@ impl EpiIntegration { } } - #[allow(clippy::unused_self)] + #[allow(clippy::unused_self, clippy::allow_attributes)] pub fn save(&mut self, _app: &mut dyn epi::App, _window: Option<&winit::window::Window>) { #[cfg(feature = "persistence")] if let Some(storage) = self.frame.storage_mut() { diff --git a/crates/eframe/src/native/event_loop_context.rs b/crates/eframe/src/native/event_loop_context.rs index f1262f85..810db8e1 100644 --- a/crates/eframe/src/native/event_loop_context.rs +++ b/crates/eframe/src/native/event_loop_context.rs @@ -27,7 +27,7 @@ impl Drop for EventLoopGuard { } // Helper function to safely use the current event loop -#[allow(unsafe_code)] +#[expect(unsafe_code)] pub fn with_current_event_loop(f: F) -> Option where F: FnOnce(&ActiveEventLoop) -> R, diff --git a/crates/eframe/src/native/file_storage.rs b/crates/eframe/src/native/file_storage.rs index 7fde2d28..fa89b905 100644 --- a/crates/eframe/src/native/file_storage.rs +++ b/crates/eframe/src/native/file_storage.rs @@ -1,6 +1,6 @@ use std::{ collections::HashMap, - io::Write, + io::Write as _, path::{Path, PathBuf}, }; @@ -42,7 +42,7 @@ pub fn storage_dir(app_id: &str) -> Option { // Adapted from // https://github.com/rust-lang/cargo/blob/6e11c77384989726bb4f412a0e23b59c27222c34/crates/home/src/windows.rs#L19-L37 #[cfg(all(windows, not(target_vendor = "uwp")))] -#[allow(unsafe_code)] +#[expect(unsafe_code)] fn roaming_appdata() -> Option { use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 94b25468..946210c8 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -11,13 +11,13 @@ use std::{cell::RefCell, num::NonZeroU32, rc::Rc, sync::Arc, time::Instant}; use egui_winit::ActionRequested; use glutin::{ - config::GlConfig, - context::NotCurrentGlContext, - display::GetGlDisplay, - prelude::{GlDisplay, PossiblyCurrentGlContext}, - surface::GlSurface, + config::GlConfig as _, + context::NotCurrentGlContext as _, + display::GetGlDisplay as _, + prelude::{GlDisplay as _, PossiblyCurrentGlContext as _}, + surface::GlSurface as _, }; -use raw_window_handle::HasWindowHandle; +use raw_window_handle::HasWindowHandle as _; use winit::{ event_loop::{ActiveEventLoop, EventLoop, EventLoopProxy}, window::{Window, WindowId}, @@ -139,7 +139,7 @@ impl<'app> GlowWinitApp<'app> { } } - #[allow(unsafe_code)] + #[expect(unsafe_code)] fn create_glutin_windowed_context( egui_ctx: &egui::Context, event_loop: &ActiveEventLoop, @@ -901,7 +901,7 @@ fn change_gl_context( } impl GlutinWindowContext { - #[allow(unsafe_code)] + #[expect(unsafe_code)] unsafe fn new( egui_ctx: &egui::Context, viewport_builder: ViewportBuilder, @@ -1094,7 +1094,7 @@ impl GlutinWindowContext { } /// Create a surface, window, and winit integration for the viewport, if missing. - #[allow(unsafe_code)] + #[expect(unsafe_code)] pub(crate) fn initialize_window( &mut self, viewport_id: ViewportId, @@ -1566,6 +1566,6 @@ fn save_screenshot_and_exit( }); log::info!("Screenshot saved to {path:?}."); - #[allow(clippy::exit)] + #[expect(clippy::exit)] std::process::exit(0); } diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 641459b5..9bcb4968 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -163,7 +163,6 @@ impl WinitAppWrapper { log::debug!("Exiting with return code 0"); - #[allow(clippy::exit)] std::process::exit(0); } } @@ -317,7 +316,7 @@ impl ApplicationHandler for WinitAppWrapper { #[cfg(not(target_os = "ios"))] fn run_and_return(event_loop: &mut EventLoop, winit_app: impl WinitApp) -> Result { - use winit::platform::run_on_demand::EventLoopExtRunOnDemand; + use winit::platform::run_on_demand::EventLoopExtRunOnDemand as _; log::trace!("Entering the winit event loop (run_app_on_demand)…"); diff --git a/crates/eframe/src/native/wgpu_integration.rs b/crates/eframe/src/native/wgpu_integration.rs index 60484cde..96e93300 100644 --- a/crates/eframe/src/native/wgpu_integration.rs +++ b/crates/eframe/src/native/wgpu_integration.rs @@ -15,7 +15,7 @@ use winit::{ window::{Window, WindowId}, }; -use ahash::{HashMap, HashSet, HashSetExt}; +use ahash::{HashMap, HashSet, HashSetExt as _}; use egui::{ DeferredViewportUiCallback, FullOutput, ImmediateViewport, ViewportBuilder, ViewportClass, ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportInfo, ViewportOutput, @@ -182,7 +182,6 @@ impl<'app> WgpuWinitApp<'app> { builder: ViewportBuilder, ) -> crate::Result<&mut WgpuWinitRunning<'app>> { profiling::function_scope!(); - #[allow(unsafe_code, unused_mut, unused_unsafe)] let mut painter = pollster::block_on(egui_wgpu::winit::Painter::new( egui_ctx.clone(), self.native_options.wgpu_options.clone(), @@ -236,7 +235,7 @@ impl<'app> WgpuWinitApp<'app> { }); } - #[allow(unused_mut)] // used for accesskit + #[allow(unused_mut, clippy::allow_attributes)] // used for accesskit let mut egui_winit = egui_winit::State::new( egui_ctx.clone(), ViewportId::ROOT, diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 76ae1761..675c57be 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -2,10 +2,10 @@ use egui::{TexturesDelta, UserData, ViewportCommand}; use crate::{epi, App}; -use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter, NeedRepaint}; +use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter as _, NeedRepaint}; pub struct AppRunner { - #[allow(dead_code)] + #[allow(dead_code, clippy::allow_attributes)] pub(crate) web_options: crate::WebOptions, pub(crate) frame: epi::Frame, egui_ctx: egui::Context, diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index 32fba9ef..1782a679 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -4,7 +4,7 @@ use super::{ button_from_mouse_event, location_hash, modifiers_from_kb_event, modifiers_from_mouse_event, modifiers_from_wheel_event, native_pixels_per_point, pos_from_mouse_event, prefers_color_scheme_dark, primary_touch_pos, push_touches, text_from_keyboard_event, - theme_from_dark_mode, translate_key, AppRunner, Closure, JsCast, JsValue, WebRunner, + theme_from_dark_mode, translate_key, AppRunner, Closure, JsCast as _, JsValue, WebRunner, DEBUG_RESIZE, }; @@ -163,7 +163,7 @@ fn install_keydown(runner_ref: &WebRunner, target: &EventTarget) -> Result<(), J ) } -#[allow(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener` +#[expect(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener` pub(crate) fn on_keydown(event: web_sys::KeyboardEvent, runner: &mut AppRunner) { let has_focus = runner.input.raw.focused; if !has_focus { @@ -261,7 +261,7 @@ fn install_keyup(runner_ref: &WebRunner, target: &EventTarget) -> Result<(), JsV runner_ref.add_event_listener(target, "keyup", on_keyup) } -#[allow(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener` +#[expect(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener` pub(crate) fn on_keyup(event: web_sys::KeyboardEvent, runner: &mut AppRunner) { let modifiers = modifiers_from_kb_event(&event); runner.input.raw.modifiers = modifiers; diff --git a/crates/eframe/src/web/mod.rs b/crates/eframe/src/web/mod.rs index c67fa69e..2bdd3af6 100644 --- a/crates/eframe/src/web/mod.rs +++ b/crates/eframe/src/web/mod.rs @@ -281,7 +281,7 @@ fn create_clipboard_item(mime: &str, bytes: &[u8]) -> Result &str { if let Some(i) = file_path.rfind("/src/") { if let Some(prev_slash) = file_path[..i].rfind('/') { diff --git a/crates/eframe/src/web/web_painter_glow.rs b/crates/eframe/src/web/web_painter_glow.rs index 876a6d78..ca6e11bf 100644 --- a/crates/eframe/src/web/web_painter_glow.rs +++ b/crates/eframe/src/web/web_painter_glow.rs @@ -1,7 +1,7 @@ use egui::{Event, UserData, ViewportId}; use egui_glow::glow; use std::sync::Arc; -use wasm_bindgen::JsCast; +use wasm_bindgen::JsCast as _; use wasm_bindgen::JsValue; use web_sys::HtmlCanvasElement; @@ -27,7 +27,8 @@ impl WebPainterGlow { ) -> Result { let (gl, shader_prefix) = init_glow_context_from_canvas(&canvas, options.webgl_context_option)?; - #[allow(clippy::arc_with_non_send_sync)] + + #[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm let gl = std::sync::Arc::new(gl); let painter = egui_glow::Painter::new(gl, shader_prefix, None, options.dithering) diff --git a/crates/eframe/src/web/web_painter_wgpu.rs b/crates/eframe/src/web/web_painter_wgpu.rs index f018c731..3cfc53f1 100644 --- a/crates/eframe/src/web/web_painter_wgpu.rs +++ b/crates/eframe/src/web/web_painter_wgpu.rs @@ -23,7 +23,7 @@ pub(crate) struct WebPainterWgpu { } impl WebPainterWgpu { - #[allow(unused)] // only used if `wgpu` is the only active feature. + #[expect(unused)] // only used if `wgpu` is the only active feature. pub fn render_state(&self) -> Option { self.render_state.clone() } @@ -55,7 +55,7 @@ impl WebPainterWgpu { }) } - #[allow(unused)] // only used if `wgpu` is the only active feature. + #[expect(unused)] // only used if `wgpu` is the only active feature. pub async fn new( ctx: egui::Context, canvas: web_sys::HtmlCanvasElement, diff --git a/crates/eframe/src/web/web_runner.rs b/crates/eframe/src/web/web_runner.rs index 4c43fcb6..099be7ae 100644 --- a/crates/eframe/src/web/web_runner.rs +++ b/crates/eframe/src/web/web_runner.rs @@ -37,7 +37,7 @@ pub struct WebRunner { impl WebRunner { /// Will install a panic handler that will catch and log any panics - #[allow(clippy::new_without_default)] + #[expect(clippy::new_without_default)] pub fn new() -> Self { let panic_handler = PanicHandler::install(); @@ -280,7 +280,7 @@ struct TargetEvent { closure: Closure, } -#[allow(unused)] +#[expect(unused)] struct IntervalHandle { handle: i32, closure: Closure, @@ -289,7 +289,7 @@ struct IntervalHandle { enum EventToUnsubscribe { TargetEvent(TargetEvent), - #[allow(unused)] + #[expect(unused)] IntervalHandle(IntervalHandle), } diff --git a/crates/egui-wgpu/src/capture.rs b/crates/egui-wgpu/src/capture.rs index 40cf5484..b4072a8b 100644 --- a/crates/egui-wgpu/src/capture.rs +++ b/crates/egui-wgpu/src/capture.rs @@ -4,6 +4,7 @@ use std::sync::{mpsc, Arc}; use wgpu::{BindGroupLayout, MultisampleState, StoreOp}; /// A texture and a buffer for reading the rendered frame back to the cpu. +/// /// The texture is required since [`wgpu::TextureUsages::COPY_SRC`] is not an allowed /// flag for the surface texture on all platforms. This means that anytime we want to /// capture the frame, we first render it to this texture, and then we can copy it to @@ -125,7 +126,7 @@ impl CaptureState { // It would be more efficient to reuse the Buffer, e.g. via some kind of ring buffer, but // for most screenshot use cases this should be fine. When taking many screenshots (e.g. for a video) // it might make sense to revisit this and implement a more efficient solution. - #[allow(clippy::arc_with_non_send_sync)] + #[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm let buffer = device.create_buffer(&wgpu::BufferDescriptor { label: Some("egui_screen_capture_buffer"), size: (self.padding.padded_bytes_per_row * self.texture.height()) as u64, @@ -184,7 +185,7 @@ impl CaptureState { tx: CaptureSender, viewport_id: ViewportId, ) { - #[allow(clippy::arc_with_non_send_sync)] + #[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm let buffer = Arc::new(buffer); let buffer_clone = buffer.clone(); let buffer_slice = buffer_clone.slice(..); diff --git a/crates/egui-wgpu/src/lib.rs b/crates/egui-wgpu/src/lib.rs index e19c2657..5df19db8 100644 --- a/crates/egui-wgpu/src/lib.rs +++ b/crates/egui-wgpu/src/lib.rs @@ -242,7 +242,7 @@ impl RenderState { // On wasm, depending on feature flags, wgpu objects may or may not implement sync. // It doesn't make sense to switch to Rc for that special usecase, so simply disable the lint. - #[allow(clippy::arc_with_non_send_sync)] + #[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm Ok(Self { adapter, #[cfg(not(target_arch = "wasm32"))] diff --git a/crates/egui-wgpu/src/renderer.rs b/crates/egui-wgpu/src/renderer.rs index 5a5c953b..0dc74632 100644 --- a/crates/egui-wgpu/src/renderer.rs +++ b/crates/egui-wgpu/src/renderer.rs @@ -3,7 +3,7 @@ use std::{borrow::Cow, num::NonZeroU64, ops::Range}; use ahash::HashMap; -use epaint::{emath::NumExt, PaintCallbackInfo, Primitive, Vertex}; +use epaint::{emath::NumExt as _, PaintCallbackInfo, Primitive, Vertex}; use wgpu::util::DeviceExt as _; @@ -749,7 +749,7 @@ impl Renderer { /// /// The texture must have the format [`wgpu::TextureFormat::Rgba8UnormSrgb`]. /// Any compare function supplied in the [`wgpu::SamplerDescriptor`] will be ignored. - #[allow(clippy::needless_pass_by_value)] // false positive + #[expect(clippy::needless_pass_by_value)] // false positive pub fn register_native_texture_with_sampler_options( &mut self, device: &wgpu::Device, @@ -796,7 +796,7 @@ impl Renderer { /// [`wgpu::SamplerDescriptor`] options. /// /// This allows applications to reuse [`epaint::TextureId`]s created with custom sampler options. - #[allow(clippy::needless_pass_by_value)] // false positive + #[expect(clippy::needless_pass_by_value)] // false positive pub fn update_egui_texture_from_wgpu_texture_with_sampler_options( &mut self, device: &wgpu::Device, diff --git a/crates/egui-wgpu/src/setup.rs b/crates/egui-wgpu/src/setup.rs index 1f70b6bb..2499d006 100644 --- a/crates/egui-wgpu/src/setup.rs +++ b/crates/egui-wgpu/src/setup.rs @@ -48,7 +48,7 @@ impl WgpuSetup { pub async fn new_instance(&self) -> wgpu::Instance { match self { Self::CreateNew(create_new) => { - #[allow(unused_mut)] + #[allow(unused_mut, clippy::allow_attributes)] let mut backends = create_new.instance_descriptor.backends; // Don't try WebGPU if we're not in a secure context. diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index cc3a7db2..e0eafee7 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -575,7 +575,7 @@ impl Painter { .retain(|id, _| active_viewports.contains(id)); } - #[allow(clippy::needless_pass_by_ref_mut, clippy::unused_self)] + #[expect(clippy::needless_pass_by_ref_mut, clippy::unused_self)] pub fn destroy(&mut self) { // TODO(emilk): something here? } diff --git a/crates/egui-winit/src/clipboard.rs b/crates/egui-winit/src/clipboard.rs index c8adcad2..a0221294 100644 --- a/crates/egui-winit/src/clipboard.rs +++ b/crates/egui-winit/src/clipboard.rs @@ -161,7 +161,7 @@ fn init_smithay_clipboard( if let Some(RawDisplayHandle::Wayland(display)) = raw_display_handle { log::trace!("Initializing smithay clipboard…"); - #[allow(unsafe_code)] + #[expect(unsafe_code)] Some(unsafe { smithay_clipboard::Clipboard::new(display.display.as_ptr()) }) } else { #[cfg(feature = "wayland")] diff --git a/crates/egui/src/cache/cache_trait.rs b/crates/egui/src/cache/cache_trait.rs index 73cb61f3..fc00a988 100644 --- a/crates/egui/src/cache/cache_trait.rs +++ b/crates/egui/src/cache/cache_trait.rs @@ -1,5 +1,5 @@ /// A cache, storing some value for some length of time. -#[allow(clippy::len_without_is_empty)] +#[expect(clippy::len_without_is_empty)] pub trait CacheTrait: 'static + Send + Sync { /// Call once per frame to evict cache. fn update(&mut self); diff --git a/crates/egui/src/containers/area.rs b/crates/egui/src/containers/area.rs index 55cdb075..0d21e8bd 100644 --- a/crates/egui/src/containers/area.rs +++ b/crates/egui/src/containers/area.rs @@ -5,8 +5,8 @@ use emath::GuiRounding as _; use crate::{ - emath, pos2, Align2, Context, Id, InnerResponse, LayerId, Layout, NumExt, Order, Pos2, Rect, - Response, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState, + emath, pos2, Align2, Context, Id, InnerResponse, LayerId, Layout, NumExt as _, Order, Pos2, + Rect, Response, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState, }; /// State of an [`Area`] that is persisted between frames. @@ -602,7 +602,7 @@ impl Prepared { self.move_response.id } - #[allow(clippy::needless_pass_by_value)] // intentional to swallow up `content_ui`. + #[expect(clippy::needless_pass_by_value)] // intentional to swallow up `content_ui`. pub(crate) fn end(self, ctx: &Context, content_ui: Ui) -> Response { let Self { info: _, diff --git a/crates/egui/src/containers/collapsing_header.rs b/crates/egui/src/containers/collapsing_header.rs index c34e5629..66e024f0 100644 --- a/crates/egui/src/containers/collapsing_header.rs +++ b/crates/egui/src/containers/collapsing_header.rs @@ -1,7 +1,7 @@ use std::hash::Hash; use crate::{ - emath, epaint, pos2, remap, remap_clamp, vec2, Context, Id, InnerResponse, NumExt, Rect, + emath, epaint, pos2, remap, remap_clamp, vec2, Context, Id, InnerResponse, NumExt as _, Rect, Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetInfo, WidgetText, WidgetType, }; diff --git a/crates/egui/src/containers/combo_box.rs b/crates/egui/src/containers/combo_box.rs index 7a5a160f..5544e759 100644 --- a/crates/egui/src/containers/combo_box.rs +++ b/crates/egui/src/containers/combo_box.rs @@ -2,11 +2,11 @@ use epaint::Shape; use crate::{ epaint, style::StyleModifier, style::WidgetVisuals, vec2, Align2, Context, Id, InnerResponse, - NumExt, Painter, Popup, PopupCloseBehavior, Rect, Response, ScrollArea, Sense, Stroke, + NumExt as _, Painter, Popup, PopupCloseBehavior, Rect, Response, ScrollArea, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo, WidgetText, WidgetType, }; -#[allow(unused_imports)] // Documentation +#[expect(unused_imports)] // Documentation use crate::style::Spacing; /// A function that paints the [`ComboBox`] icon @@ -297,7 +297,7 @@ impl ComboBox { } } -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] fn combo_box_dyn<'c, R>( ui: &mut Ui, button_id: Id, diff --git a/crates/egui/src/containers/menu.rs b/crates/egui/src/containers/menu.rs index 7511d07d..228bbd86 100644 --- a/crates/egui/src/containers/menu.rs +++ b/crates/egui/src/containers/menu.rs @@ -1,7 +1,7 @@ use crate::style::StyleModifier; use crate::{ Button, Color32, Context, Frame, Id, InnerResponse, Layout, Popup, PopupCloseBehavior, - Response, Style, Ui, UiBuilder, UiKind, UiStack, UiStackInfo, Widget, WidgetText, + Response, Style, Ui, UiBuilder, UiKind, UiStack, UiStackInfo, Widget as _, WidgetText, }; use emath::{vec2, Align, RectAlign, Vec2}; use epaint::Stroke; @@ -159,6 +159,7 @@ impl MenuState { } /// Horizontal menu bar where you can add [`MenuButton`]s. +/// /// The menu bar goes well in a [`crate::TopBottomPanel::top`], /// but can also be placed in a [`crate::Window`]. /// In the latter case you may want to wrap it in [`Frame`]. diff --git a/crates/egui/src/containers/old_popup.rs b/crates/egui/src/containers/old_popup.rs index fc4da4e2..3e5de650 100644 --- a/crates/egui/src/containers/old_popup.rs +++ b/crates/egui/src/containers/old_popup.rs @@ -4,7 +4,7 @@ use crate::containers::tooltip::Tooltip; use crate::{ Align, Context, Id, LayerId, Layout, Popup, PopupAnchor, PopupCloseBehavior, Pos2, Rect, - Response, Ui, Widget, WidgetText, + Response, Ui, Widget as _, WidgetText, }; use emath::RectAlign; // ---------------------------------------------------------------------------- @@ -19,7 +19,7 @@ use emath::RectAlign; /// /// ``` /// # egui::__run_test_ui(|ui| { -/// # #[allow(deprecated)] +/// # #[expect(deprecated)] /// if ui.ui_contains_pointer() { /// egui::show_tooltip(ui.ctx(), ui.layer_id(), egui::Id::new("my_tooltip"), |ui| { /// ui.label("Helpful text"); @@ -177,7 +177,7 @@ pub fn popup_below_widget( /// } /// let below = egui::AboveOrBelow::Below; /// let close_on_click_outside = egui::PopupCloseBehavior::CloseOnClickOutside; -/// # #[allow(deprecated)] +/// # #[expect(deprecated)] /// egui::popup_above_or_below_widget(ui, popup_id, &response, below, close_on_click_outside, |ui| { /// ui.set_min_width(200.0); // if you want to control the size /// ui.label("Some more info, or things you can select:"); diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index 6fd19e18..db0e8a7f 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -18,7 +18,7 @@ use emath::GuiRounding as _; use crate::{ - lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt, + lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt as _, Rangef, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, }; diff --git a/crates/egui/src/containers/popup.rs b/crates/egui/src/containers/popup.rs index 7159a052..47e800d2 100644 --- a/crates/egui/src/containers/popup.rs +++ b/crates/egui/src/containers/popup.rs @@ -466,7 +466,7 @@ impl<'a> Popup<'a> { }; RectAlign::find_best_align( - #[allow(clippy::iter_on_empty_collections)] + #[expect(clippy::iter_on_empty_collections)] once(self.rect_align).chain( self.alternative_aligns // Need the empty slice so the iters have the same type so we can unwrap_or diff --git a/crates/egui/src/containers/resize.rs b/crates/egui/src/containers/resize.rs index 0df9a113..fe386164 100644 --- a/crates/egui/src/containers/resize.rs +++ b/crates/egui/src/containers/resize.rs @@ -1,6 +1,6 @@ use crate::{ - pos2, vec2, Align2, Color32, Context, CursorIcon, Id, NumExt, Rect, Response, Sense, Shape, Ui, - UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, + pos2, vec2, Align2, Color32, Context, CursorIcon, Id, NumExt as _, Rect, Response, Sense, + Shape, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, }; #[derive(Clone, Copy, Debug)] diff --git a/crates/egui/src/containers/scene.rs b/crates/egui/src/containers/scene.rs index d023a4d3..e5a35032 100644 --- a/crates/egui/src/containers/scene.rs +++ b/crates/egui/src/containers/scene.rs @@ -1,6 +1,6 @@ use core::f32; -use emath::{GuiRounding, Pos2}; +use emath::{GuiRounding as _, Pos2}; use crate::{ emath::TSTransform, InnerResponse, LayerId, PointerButton, Rangef, Rect, Response, Sense, Ui, diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index c430b6ea..b2df2100 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -1,8 +1,8 @@ #![allow(clippy::needless_range_loop)] use crate::{ - emath, epaint, lerp, pass_state, pos2, remap, remap_clamp, Context, Id, NumExt, Pos2, Rangef, - Rect, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, + emath, epaint, lerp, pass_state, pos2, remap, remap_clamp, Context, Id, NumExt as _, Pos2, + Rangef, Rect, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, }; #[derive(Clone, Copy, Debug)] diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 6ec79f87..47be4f3d 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -34,9 +34,10 @@ use crate::{ viewport::ViewportClass, Align2, CursorIcon, DeferredViewportUiCallback, FontDefinitions, Grid, Id, ImmediateViewport, ImmediateViewportRendererCallback, Key, KeyboardShortcut, Label, LayerId, Memory, - ModifierNames, NumExt, Order, Painter, RawInput, Response, RichText, ScrollArea, Sense, Style, - TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder, ViewportCommand, ViewportId, - ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput, Widget, WidgetRect, WidgetText, + ModifierNames, NumExt as _, Order, Painter, RawInput, Response, RichText, ScrollArea, Sense, + Style, TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder, ViewportCommand, + ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput, Widget as _, + WidgetRect, WidgetText, }; #[cfg(feature = "accesskit")] @@ -314,7 +315,7 @@ impl std::fmt::Display for RepaintCause { impl RepaintCause { /// Capture the file and line number of the call site. - #[allow(clippy::new_without_default)] + #[expect(clippy::new_without_default)] #[track_caller] pub fn new() -> Self { let caller = Location::caller(); @@ -327,7 +328,6 @@ impl RepaintCause { /// Capture the file and line number of the call site, /// as well as add a reason. - #[allow(clippy::new_without_default)] #[track_caller] pub fn new_reason(reason: impl Into>) -> Self { let caller = Location::caller(); @@ -1160,7 +1160,6 @@ impl Context { /// /// `allow_focus` should usually be true, unless you call this function multiple times with the /// same widget, then `allow_focus` should only be true once (like in [`Ui::new`] (true) and [`Ui::remember_min_rect`] (false)). - #[allow(clippy::too_many_arguments)] pub(crate) fn create_widget(&self, w: WidgetRect, allow_focus: bool) -> Response { let interested_in_focus = w.enabled && w.sense.is_focusable() @@ -1189,7 +1188,7 @@ impl Context { self.check_for_id_clash(w.id, w.rect, "widget"); } - #[allow(clippy::let_and_return)] + #[allow(clippy::let_and_return, clippy::allow_attributes)] let res = self.get_response(w); #[cfg(feature = "accesskit")] @@ -2350,7 +2349,6 @@ impl ContextImpl { // Inform the backend of all textures that have been updated (including font atlas). let textures_delta = self.tex_manager.0.write().take_delta(); - #[cfg_attr(not(feature = "accesskit"), allow(unused_mut))] let mut platform_output: PlatformOutput = std::mem::take(&mut viewport.output); #[cfg(feature = "accesskit")] @@ -2651,7 +2649,7 @@ impl Context { /// Is an egui context menu open? /// /// This only works with the old, deprecated [`crate::menu`] API. - #[allow(deprecated)] + #[expect(deprecated)] #[deprecated = "Use `is_popup_open` instead"] pub fn is_context_menu_open(&self) -> bool { self.data(|d| { @@ -3205,7 +3203,7 @@ impl Context { } }); - #[allow(deprecated)] + #[expect(deprecated)] ui.horizontal(|ui| { ui.label(format!( "{} menu bars", @@ -3263,7 +3261,7 @@ impl Context { /// the function is still called, but with no other effect. /// /// No locks are held while the given closure is called. - #[allow(clippy::unused_self, clippy::let_and_return)] + #[allow(clippy::unused_self, clippy::let_and_return, clippy::allow_attributes)] #[inline] pub fn with_accessibility_parent(&self, _id: Id, f: impl FnOnce() -> R) -> R { // TODO(emilk): this isn't thread-safe - another thread can call this function between the push/pop calls @@ -3596,7 +3594,6 @@ impl Context { /// * Set the window attributes (position, size, …) based on [`ImmediateViewport::builder`]. /// * Call [`Context::run`] with [`ImmediateViewport::viewport_ui_cb`]. /// * Handle the output from [`Context::run`], including rendering - #[allow(clippy::unused_self)] pub fn set_immediate_viewport_renderer( callback: impl for<'a> Fn(&Self, ImmediateViewport<'a>) + 'static, ) { diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index cc872524..9f15f1c4 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -1233,7 +1233,7 @@ pub struct EventFilter { pub escape: bool, } -#[allow(clippy::derivable_impls)] // let's be explicit +#[expect(clippy::derivable_impls)] // let's be explicit impl Default for EventFilter { fn default() -> Self { Self { diff --git a/crates/egui/src/data/output.rs b/crates/egui/src/data/output.rs index 2fdaec1e..ab9044cb 100644 --- a/crates/egui/src/data/output.rs +++ b/crates/egui/src/data/output.rs @@ -252,7 +252,7 @@ pub struct OpenUrl { } impl OpenUrl { - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn same_tab(url: impl ToString) -> Self { Self { url: url.to_string(), @@ -260,7 +260,7 @@ impl OpenUrl { } } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn new_tab(url: impl ToString) -> Self { Self { url: url.to_string(), @@ -607,7 +607,7 @@ impl WidgetInfo { } } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn labeled(typ: WidgetType, enabled: bool, label: impl ToString) -> Self { Self { enabled, @@ -617,7 +617,7 @@ impl WidgetInfo { } /// checkboxes, radio-buttons etc - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn selected(typ: WidgetType, enabled: bool, selected: bool, label: impl ToString) -> Self { Self { enabled, @@ -635,7 +635,7 @@ impl WidgetInfo { } } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn slider(enabled: bool, value: f64, label: impl ToString) -> Self { let label = label.to_string(); Self { @@ -646,7 +646,7 @@ impl WidgetInfo { } } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn text_edit( enabled: bool, prev_text_value: impl ToString, @@ -670,7 +670,7 @@ impl WidgetInfo { } } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn text_selection_changed( enabled: bool, text_selection: std::ops::RangeInclusive, diff --git a/crates/egui/src/grid.rs b/crates/egui/src/grid.rs index 9ad386cc..dbc22a09 100644 --- a/crates/egui/src/grid.rs +++ b/crates/egui/src/grid.rs @@ -1,8 +1,8 @@ use emath::GuiRounding as _; use crate::{ - vec2, Align2, Color32, Context, Id, InnerResponse, NumExt, Painter, Rect, Region, Style, Ui, - UiBuilder, Vec2, + vec2, Align2, Color32, Context, Id, InnerResponse, NumExt as _, Painter, Rect, Region, Style, + Ui, UiBuilder, Vec2, }; #[cfg(debug_assertions)] @@ -184,7 +184,7 @@ impl GridLayout { Rect::from_min_size(cursor.min, size).round_ui() } - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub(crate) fn align_size_within_rect(&self, size: Vec2, frame: Rect) -> Rect { // TODO(emilk): allow this alignment to be customized Align2::LEFT_CENTER diff --git a/crates/egui/src/id.rs b/crates/egui/src/id.rs index ddc1a59b..7bcef8dc 100644 --- a/crates/egui/src/id.rs +++ b/crates/egui/src/id.rs @@ -59,7 +59,7 @@ impl Id { /// Generate a new [`Id`] by hashing the parent [`Id`] and the given argument. pub fn with(self, child: impl std::hash::Hash) -> Self { - use std::hash::{BuildHasher, Hasher}; + use std::hash::{BuildHasher as _, Hasher as _}; let mut hasher = ahash::RandomState::with_seeds(1, 2, 3, 4).build_hasher(); hasher.write_u64(self.0.get()); child.hash(&mut hasher); diff --git a/crates/egui/src/input_state/mod.rs b/crates/egui/src/input_state/mod.rs index a5fc83ee..a5d6951c 100644 --- a/crates/egui/src/input_state/mod.rs +++ b/crates/egui/src/input_state/mod.rs @@ -5,7 +5,7 @@ use crate::data::input::{ TouchDeviceId, ViewportInfo, NUM_POINTER_BUTTONS, }; use crate::{ - emath::{vec2, NumExt, Pos2, Rect, Vec2}, + emath::{vec2, NumExt as _, Pos2, Rect, Vec2}, util::History, }; use std::{ @@ -344,7 +344,7 @@ impl InputState { let is_zoom = modifiers.ctrl || modifiers.mac_cmd || modifiers.command; - #[allow(clippy::collapsible_else_if)] + #[expect(clippy::collapsible_else_if)] if is_zoom { if is_smooth { smooth_scroll_delta_for_zoom += delta.y; diff --git a/crates/egui/src/introspection.rs b/crates/egui/src/introspection.rs index e21ddb3a..8826eca7 100644 --- a/crates/egui/src/introspection.rs +++ b/crates/egui/src/introspection.rs @@ -1,7 +1,7 @@ //! Showing UI:s for egui/epaint types. use crate::{ epaint, memory, pos2, remap_clamp, vec2, Color32, CursorIcon, FontFamily, FontId, Label, Mesh, - NumExt, Rect, Response, Sense, Shape, Slider, TextStyle, TextWrapMode, Ui, Widget, + NumExt as _, Rect, Response, Sense, Shape, Slider, TextStyle, TextWrapMode, Ui, Widget, }; pub fn font_family_ui(ui: &mut Ui, font_family: &mut FontFamily) { diff --git a/crates/egui/src/layout.rs b/crates/egui/src/layout.rs index 91f39fb2..a0665246 100644 --- a/crates/egui/src/layout.rs +++ b/crates/egui/src/layout.rs @@ -1,7 +1,7 @@ use emath::GuiRounding as _; use crate::{ - emath::{pos2, vec2, Align2, NumExt, Pos2, Rect, Vec2}, + emath::{pos2, vec2, Align2, NumExt as _, Pos2, Rect, Vec2}, Align, }; const INFINITY: f32 = f32::INFINITY; diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index 26950eb2..6e30d4ca 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -64,7 +64,7 @@ use std::{ use ahash::HashMap; -use emath::{Float, OrderedFloat}; +use emath::{Float as _, OrderedFloat}; use epaint::{mutex::Mutex, textures::TextureOptions, ColorImage, TextureHandle, TextureId, Vec2}; use crate::Context; diff --git a/crates/egui/src/load/bytes_loader.rs b/crates/egui/src/load/bytes_loader.rs index 9c70f54e..5f3e0d3b 100644 --- a/crates/egui/src/load/bytes_loader.rs +++ b/crates/egui/src/load/bytes_loader.rs @@ -28,7 +28,7 @@ impl DefaultBytesLoader { } impl BytesLoader for DefaultBytesLoader { - fn id(&self) -> &str { + fn id(&self) -> &'static str { generate_loader_id!(DefaultBytesLoader) } diff --git a/crates/egui/src/load/texture_loader.rs b/crates/egui/src/load/texture_loader.rs index a1170257..4e9dc1e1 100644 --- a/crates/egui/src/load/texture_loader.rs +++ b/crates/egui/src/load/texture_loader.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use super::{ - BytesLoader, Context, HashMap, ImagePoll, Mutex, SizeHint, SizedTexture, TextureHandle, + BytesLoader as _, Context, HashMap, ImagePoll, Mutex, SizeHint, SizedTexture, TextureHandle, TextureLoadResult, TextureLoader, TextureOptions, TexturePoll, }; @@ -11,7 +11,7 @@ pub struct DefaultTextureLoader { } impl TextureLoader for DefaultTextureLoader { - fn id(&self) -> &str { + fn id(&self) -> &'static str { crate::generate_loader_id!(DefaultTextureLoader) } diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index ef84451d..8de1fe95 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -23,8 +23,8 @@ use super::{ use crate::{ epaint, vec2, widgets::{Button, ImageButton}, - Align2, Area, Color32, Frame, Key, LayerId, Layout, NumExt, Order, Stroke, Style, TextWrapMode, - UiKind, WidgetText, + Align2, Area, Color32, Frame, Key, LayerId, Layout, NumExt as _, Order, Stroke, Style, + TextWrapMode, UiKind, WidgetText, }; use epaint::mutex::RwLock; use std::sync::Arc; diff --git a/crates/egui/src/os.rs b/crates/egui/src/os.rs index 766ecf55..e7497160 100644 --- a/crates/egui/src/os.rs +++ b/crates/egui/src/os.rs @@ -1,5 +1,5 @@ /// An `enum` of common operating systems. -#[allow(clippy::upper_case_acronyms)] // `Ios` looks too ugly +#[expect(clippy::upper_case_acronyms)] // `Ios` looks too ugly #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum OperatingSystem { /// Unknown OS - could be wasm diff --git a/crates/egui/src/painter.rs b/crates/egui/src/painter.rs index 22a0a0a9..732d78ee 100644 --- a/crates/egui/src/painter.rs +++ b/crates/egui/src/painter.rs @@ -294,7 +294,7 @@ impl Painter { /// ## Debug painting impl Painter { - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn debug_rect(&self, rect: Rect, color: Color32, text: impl ToString) { self.rect( rect, @@ -320,7 +320,7 @@ impl Painter { /// Text with a background. /// /// See also [`Context::debug_text`]. - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn debug_text( &self, pos: Pos2, @@ -497,7 +497,7 @@ impl Painter { /// [`Self::layout`] or [`Self::layout_no_wrap`]. /// /// Returns where the text ended up. - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn text( &self, pos: Pos2, diff --git a/crates/egui/src/pass_state.rs b/crates/egui/src/pass_state.rs index 49d6c758..1f629253 100644 --- a/crates/egui/src/pass_state.rs +++ b/crates/egui/src/pass_state.rs @@ -3,7 +3,7 @@ use ahash::HashMap; use crate::{id::IdSet, style, Align, Id, IdMap, LayerId, Rangef, Rect, Vec2, WidgetRects}; #[cfg(debug_assertions)] -use crate::{pos2, Align2, Color32, FontId, NumExt, Painter}; +use crate::{pos2, Align2, Color32, FontId, NumExt as _, Painter}; /// Reset at the start of each frame. #[derive(Clone, Debug, Default)] diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 38d40374..7b73edbb 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -747,7 +747,8 @@ impl ScrollStyle { // ---------------------------------------------------------------------------- -/// Scroll animation configuration, used when programmatically scrolling somewhere (e.g. with `[crate::Ui::scroll_to_cursor]`) +/// Scroll animation configuration, used when programmatically scrolling somewhere (e.g. with `[crate::Ui::scroll_to_cursor]`). +/// /// The animation duration is calculated based on the distance to be scrolled via `[ScrollAnimation::points_per_second]` /// and can be clamped to a min / max duration via `[ScrollAnimation::duration]`. #[derive(Copy, Clone, Debug, PartialEq)] @@ -1260,7 +1261,7 @@ pub fn default_text_styles() -> BTreeMap { impl Default for Style { fn default() -> Self { - #[allow(deprecated)] + #[expect(deprecated)] Self { override_font_id: None, override_text_style: None, @@ -1562,7 +1563,7 @@ use crate::{ impl Style { pub fn ui(&mut self, ui: &mut crate::Ui) { - #[allow(deprecated)] + #[expect(deprecated)] let Self { override_font_id, override_text_style, diff --git a/crates/egui/src/text_selection/label_text_selection.rs b/crates/egui/src/text_selection/label_text_selection.rs index e24992a0..9ce8fbd5 100644 --- a/crates/egui/src/text_selection/label_text_selection.rs +++ b/crates/egui/src/text_selection/label_text_selection.rs @@ -616,7 +616,7 @@ impl LabelSelectionState { let old_primary = old_selection.map(|s| s.primary); let new_primary = self.selection.as_ref().map(|s| s.primary); if let Some(new_primary) = new_primary { - let primary_changed = old_primary.map_or(true, |old| { + let primary_changed = old_primary.is_none_or(|old| { old.widget_id != new_primary.widget_id || old.ccursor != new_primary.ccursor }); if primary_changed && new_primary.widget_id == widget_id { diff --git a/crates/egui/src/text_selection/text_cursor_state.rs b/crates/egui/src/text_selection/text_cursor_state.rs index aaa3beb9..298d8abf 100644 --- a/crates/egui/src/text_selection/text_cursor_state.rs +++ b/crates/egui/src/text_selection/text_cursor_state.rs @@ -1,9 +1,9 @@ //! Text cursor changes/interaction, without modifying the text. use epaint::text::{cursor::CCursor, Galley}; -use unicode_segmentation::UnicodeSegmentation; +use unicode_segmentation::UnicodeSegmentation as _; -use crate::{epaint, NumExt, Rect, Response, Ui}; +use crate::{epaint, NumExt as _, Rect, Response, Ui}; use super::CCursorRange; diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 0e8509bb..4174ca96 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -98,7 +98,7 @@ pub struct Ui { sizing_pass: bool, /// Indicates whether this Ui belongs to a Menu. - #[allow(deprecated)] + #[expect(deprecated)] menu_state: Option>>, /// The [`UiStack`] for this [`Ui`]. @@ -666,7 +666,7 @@ impl Ui { /// /// This is determined first by [`Style::wrap_mode`], and then by the layout of this [`Ui`]. pub fn wrap_mode(&self) -> TextWrapMode { - #[allow(deprecated)] + #[expect(deprecated)] if let Some(wrap_mode) = self.style.wrap_mode { wrap_mode } @@ -3015,7 +3015,7 @@ impl Ui { self.close_kind(UiKind::Menu); } - #[allow(deprecated)] + #[expect(deprecated)] pub(crate) fn set_menu_state( &mut self, menu_state: Option>>, @@ -3156,7 +3156,7 @@ impl Drop for Ui { /// Show this rectangle to the user if certain debug options are set. #[cfg(debug_assertions)] fn register_rect(ui: &Ui, rect: Rect) { - use emath::{Align2, GuiRounding}; + use emath::{Align2, GuiRounding as _}; let debug = ui.style().debug; diff --git a/crates/egui/src/ui_builder.rs b/crates/egui/src/ui_builder.rs index 4d225ae4..4aade7d6 100644 --- a/crates/egui/src/ui_builder.rs +++ b/crates/egui/src/ui_builder.rs @@ -1,7 +1,7 @@ use std::{hash::Hash, sync::Arc}; use crate::close_tag::ClosableTag; -#[allow(unused_imports)] // Used for doclinks +#[expect(unused_imports)] // Used for doclinks use crate::Ui; use crate::{Id, LayerId, Layout, Rect, Sense, Style, UiStackInfo}; diff --git a/crates/egui/src/ui_stack.rs b/crates/egui/src/ui_stack.rs index 64a776ee..0122f568 100644 --- a/crates/egui/src/ui_stack.rs +++ b/crates/egui/src/ui_stack.rs @@ -258,7 +258,7 @@ impl UiStack { // these methods act on the entire stack impl UiStack { /// Return an iterator that walks the stack from this node to the root. - #[allow(clippy::iter_without_into_iter)] + #[expect(clippy::iter_without_into_iter)] pub fn iter(&self) -> UiStackIterator<'_> { UiStackIterator { next: Some(self) } } diff --git a/crates/egui/src/util/id_type_map.rs b/crates/egui/src/util/id_type_map.rs index a7b8f18c..bd4d14ef 100644 --- a/crates/egui/src/util/id_type_map.rs +++ b/crates/egui/src/util/id_type_map.rs @@ -467,7 +467,7 @@ impl IdTypeMap { /// For tests #[cfg(feature = "persistence")] - #[allow(unused)] + #[allow(unused, clippy::allow_attributes)] fn get_generation(&self, id: Id) -> Option { let element = self.map.get(&hash(TypeId::of::(), id))?; match element { diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index 9aba6991..2a469435 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -260,7 +260,6 @@ pub type ImmediateViewportRendererCallback = dyn for<'a> Fn(&Context, ImmediateV /// The default values are implementation defined, so you may want to explicitly /// configure the size of the window, and what buttons are shown. #[derive(Clone, Debug, Default, Eq, PartialEq)] -#[allow(clippy::option_option)] pub struct ViewportBuilder { /// The title of the viewport. /// `eframe` will use this as the title of the native window. diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index c0701c19..2a85a164 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -1,6 +1,6 @@ use crate::{ - widgets, Align, Color32, CornerRadius, FontSelection, Image, NumExt, Rect, Response, Sense, - Stroke, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, + widgets, Align, Color32, CornerRadius, FontSelection, Image, NumExt as _, Rect, Response, + Sense, Stroke, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, }; /// Clickable button with text. @@ -46,13 +46,11 @@ impl<'a> Button<'a> { } /// Creates a button with an image. The size of the image as displayed is defined by the provided size. - #[allow(clippy::needless_pass_by_value)] pub fn image(image: impl Into>) -> Self { Self::opt_image_and_text(Some(image.into()), None) } /// Creates a button with an image to the left of the text. The size of the image as displayed is defined by the provided size. - #[allow(clippy::needless_pass_by_value)] pub fn image_and_text(image: impl Into>, text: impl Into) -> Self { Self::opt_image_and_text(Some(image.into()), Some(text.into())) } diff --git a/crates/egui/src/widgets/checkbox.rs b/crates/egui/src/widgets/checkbox.rs index 7bdb6c86..97bd97b8 100644 --- a/crates/egui/src/widgets/checkbox.rs +++ b/crates/egui/src/widgets/checkbox.rs @@ -1,6 +1,6 @@ use crate::{ - epaint, pos2, vec2, NumExt, Response, Sense, Shape, TextStyle, Ui, Vec2, Widget, WidgetInfo, - WidgetText, WidgetType, + epaint, pos2, vec2, NumExt as _, Response, Sense, Shape, TextStyle, Ui, Vec2, Widget, + WidgetInfo, WidgetText, WidgetType, }; // TODO(emilk): allow checkbox without a text label diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index f8e18665..07678d45 100644 --- a/crates/egui/src/widgets/color_picker.rs +++ b/crates/egui/src/widgets/color_picker.rs @@ -3,7 +3,7 @@ use crate::util::fixed_cache::FixedCache; use crate::{ epaint, lerp, remap_clamp, Area, Context, DragValue, Frame, Id, Key, Order, Painter, Response, - Sense, Ui, UiKind, Widget, WidgetInfo, WidgetType, + Sense, Ui, UiKind, Widget as _, WidgetInfo, WidgetType, }; use epaint::{ ecolor::{Color32, Hsva, HsvaGamma, Rgba}, diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index f0f35c1e..864222ae 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -3,8 +3,8 @@ use std::{cmp::Ordering, ops::RangeInclusive}; use crate::{ - emath, text, Button, CursorIcon, Key, Modifiers, NumExt, Response, RichText, Sense, TextEdit, - TextWrapMode, Ui, Widget, WidgetInfo, MINUS_CHAR_STR, + emath, text, Button, CursorIcon, Key, Modifiers, NumExt as _, Response, RichText, Sense, + TextEdit, TextWrapMode, Ui, Widget, WidgetInfo, MINUS_CHAR_STR, }; // ---------------------------------------------------------------------------- @@ -550,7 +550,7 @@ impl Widget for DragValue<'_> { } // some clones below are redundant if AccessKit is disabled - #[allow(clippy::redundant_clone)] + #[expect(clippy::redundant_clone)] let mut response = if is_kb_editing { let mut value_text = ui .data_mut(|data| data.remove_temp::(id)) diff --git a/crates/egui/src/widgets/hyperlink.rs b/crates/egui/src/widgets/hyperlink.rs index 7d5129b1..4896be41 100644 --- a/crates/egui/src/widgets/hyperlink.rs +++ b/crates/egui/src/widgets/hyperlink.rs @@ -96,7 +96,7 @@ pub struct Hyperlink { } impl Hyperlink { - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn new(url: impl ToString) -> Self { let url = url.to_string(); Self { @@ -106,7 +106,7 @@ impl Hyperlink { } } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn from_label_and_url(text: impl Into, url: impl ToString) -> Self { Self { url: url.to_string(), diff --git a/crates/egui/src/widgets/progress_bar.rs b/crates/egui/src/widgets/progress_bar.rs index 44c9b897..6739c0e2 100644 --- a/crates/egui/src/widgets/progress_bar.rs +++ b/crates/egui/src/widgets/progress_bar.rs @@ -1,6 +1,6 @@ use crate::{ - lerp, vec2, Color32, CornerRadius, NumExt, Pos2, Rect, Response, Rgba, Sense, Shape, Stroke, - TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, + lerp, vec2, Color32, CornerRadius, NumExt as _, Pos2, Rect, Response, Rgba, Sense, Shape, + Stroke, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, }; enum ProgressBarText { diff --git a/crates/egui/src/widgets/radio_button.rs b/crates/egui/src/widgets/radio_button.rs index fabf565b..7c178840 100644 --- a/crates/egui/src/widgets/radio_button.rs +++ b/crates/egui/src/widgets/radio_button.rs @@ -1,5 +1,5 @@ use crate::{ - epaint, pos2, vec2, NumExt, Response, Sense, TextStyle, Ui, Vec2, Widget, WidgetInfo, + epaint, pos2, vec2, NumExt as _, Response, Sense, TextStyle, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, }; diff --git a/crates/egui/src/widgets/selected_label.rs b/crates/egui/src/widgets/selected_label.rs index dfed4d2b..4b2ee9ae 100644 --- a/crates/egui/src/widgets/selected_label.rs +++ b/crates/egui/src/widgets/selected_label.rs @@ -1,4 +1,6 @@ -use crate::{NumExt, Response, Sense, TextStyle, Ui, Widget, WidgetInfo, WidgetText, WidgetType}; +use crate::{ + NumExt as _, Response, Sense, TextStyle, Ui, Widget, WidgetInfo, WidgetText, WidgetType, +}; /// One out of several alternatives, either selected or not. /// Will mark selected items with a different background color. diff --git a/crates/egui/src/widgets/slider.rs b/crates/egui/src/widgets/slider.rs index 0f7eb049..017270fc 100644 --- a/crates/egui/src/widgets/slider.rs +++ b/crates/egui/src/widgets/slider.rs @@ -4,8 +4,8 @@ use std::ops::RangeInclusive; use crate::{ emath, epaint, lerp, pos2, remap, remap_clamp, style, style::HandleShape, vec2, Color32, - DragValue, EventFilter, Key, Label, NumExt, Pos2, Rangef, Rect, Response, Sense, TextStyle, - TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, MINUS_CHAR_STR, + DragValue, EventFilter, Key, Label, NumExt as _, Pos2, Rangef, Rect, Response, Sense, + TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, MINUS_CHAR_STR, }; use super::drag_value::clamp_value_to_range; diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 6a424449..ca201edd 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -13,8 +13,8 @@ use crate::{ response, text_selection, text_selection::{text_cursor_state::cursor_rect, visuals::paint_text_selection, CCursorRange}, vec2, Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, - ImeEvent, Key, KeyboardShortcut, Margin, Modifiers, NumExt, Response, Sense, Shape, TextBuffer, - TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, + ImeEvent, Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape, + TextBuffer, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, }; use super::{TextEditOutput, TextEditState}; @@ -878,7 +878,7 @@ fn mask_if_password(is_password: bool, text: &str) -> String { // ---------------------------------------------------------------------------- /// Check for (keyboard) events to edit the cursor and/or text. -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] fn events( ui: &crate::Ui, state: &mut TextEditState, diff --git a/crates/egui/src/widgets/text_edit/state.rs b/crates/egui/src/widgets/text_edit/state.rs index 0734811b..0051ea8e 100644 --- a/crates/egui/src/widgets/text_edit/state.rs +++ b/crates/egui/src/widgets/text_edit/state.rs @@ -72,7 +72,7 @@ impl TextEditState { self.undoer.lock().clone() } - #[allow(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability + #[expect(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability pub fn set_undoer(&mut self, undoer: TextEditUndoer) { *self.undoer.lock() = undoer; } diff --git a/crates/egui_demo_app/src/apps/custom3d_glow.rs b/crates/egui_demo_app/src/apps/custom3d_glow.rs index ad6bfc3b..b3ff74b1 100644 --- a/crates/egui_demo_app/src/apps/custom3d_glow.rs +++ b/crates/egui_demo_app/src/apps/custom3d_glow.rs @@ -80,7 +80,7 @@ struct RotatingTriangle { vertex_array: glow::VertexArray, } -#[allow(unsafe_code)] // we need unsafe code to use glow +#[expect(unsafe_code)] // we need unsafe code to use glow impl RotatingTriangle { fn new(gl: &glow::Context) -> Option { use glow::HasContext as _; diff --git a/crates/egui_demo_app/src/apps/custom3d_wgpu.rs b/crates/egui_demo_app/src/apps/custom3d_wgpu.rs index 2e3a34f7..d3b10d48 100644 --- a/crates/egui_demo_app/src/apps/custom3d_wgpu.rs +++ b/crates/egui_demo_app/src/apps/custom3d_wgpu.rs @@ -1,7 +1,7 @@ use std::num::NonZeroU64; use eframe::{ - egui_wgpu::wgpu::util::DeviceExt, + egui_wgpu::wgpu::util::DeviceExt as _, egui_wgpu::{self, wgpu}, }; diff --git a/crates/egui_demo_app/src/backend_panel.rs b/crates/egui_demo_app/src/backend_panel.rs index e0a29f14..289d9b6e 100644 --- a/crates/egui_demo_app/src/backend_panel.rs +++ b/crates/egui_demo_app/src/backend_panel.rs @@ -110,7 +110,7 @@ impl BackendPanel { if cfg!(debug_assertions) && cfg!(target_arch = "wasm32") { ui.separator(); // For testing panic handling on web: - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if ui.button("panic!()").clicked() { panic!("intentional panic!"); } diff --git a/crates/egui_demo_app/src/lib.rs b/crates/egui_demo_app/src/lib.rs index 0eb34486..9cfa26ba 100644 --- a/crates/egui_demo_app/src/lib.rs +++ b/crates/egui_demo_app/src/lib.rs @@ -10,7 +10,7 @@ pub use wrap_app::{Anchor, WrapApp}; /// Time of day as seconds since midnight. Used for clock in demo app. pub(crate) fn seconds_since_midnight() -> f64 { - use chrono::Timelike; + use chrono::Timelike as _; let time = chrono::Local::now().time(); time.num_seconds_from_midnight() as f64 + 1e-9 * (time.nanosecond() as f64) } diff --git a/crates/egui_demo_app/src/main.rs b/crates/egui_demo_app/src/main.rs index 6a2bb2da..476ffdac 100644 --- a/crates/egui_demo_app/src/main.rs +++ b/crates/egui_demo_app/src/main.rs @@ -75,7 +75,7 @@ fn start_puffin_server() { // We can store the server if we want, but in this case we just want // it to keep running. Dropping it closes the server, so let's not drop it! - #[allow(clippy::mem_forget)] + #[expect(clippy::mem_forget)] std::mem::forget(puffin_server); } Err(err) => { diff --git a/crates/egui_demo_app/src/web.rs b/crates/egui_demo_app/src/web.rs index 8c9cdd1d..104ef1dc 100644 --- a/crates/egui_demo_app/src/web.rs +++ b/crates/egui_demo_app/src/web.rs @@ -14,7 +14,7 @@ pub struct WebHandle { #[wasm_bindgen] impl WebHandle { /// Installs a panic hook, then returns. - #[allow(clippy::new_without_default)] + #[allow(clippy::new_without_default, clippy::allow_attributes)] #[wasm_bindgen(constructor)] pub fn new() -> Self { // Redirect [`log`] message to `console.log` and friends: diff --git a/crates/egui_demo_app/src/wrap_app.rs b/crates/egui_demo_app/src/wrap_app.rs index a571cfbb..ea5fbfab 100644 --- a/crates/egui_demo_app/src/wrap_app.rs +++ b/crates/egui_demo_app/src/wrap_app.rs @@ -188,7 +188,7 @@ impl WrapApp { // This gives us image support: egui_extras::install_image_loaders(&cc.egui_ctx); - #[allow(unused_mut)] + #[allow(unused_mut, clippy::allow_attributes)] let mut slf = Self { state: State::default(), diff --git a/crates/egui_demo_app/tests/test_demo_app.rs b/crates/egui_demo_app/tests/test_demo_app.rs index 056bee49..8b0b272f 100644 --- a/crates/egui_demo_app/tests/test_demo_app.rs +++ b/crates/egui_demo_app/tests/test_demo_app.rs @@ -1,7 +1,7 @@ use egui::accesskit::Role; use egui::Vec2; use egui_demo_app::{Anchor, WrapApp}; -use egui_kittest::kittest::Queryable; +use egui_kittest::kittest::Queryable as _; use egui_kittest::SnapshotResults; #[test] diff --git a/crates/egui_demo_lib/src/demo/code_example.rs b/crates/egui_demo_lib/src/demo/code_example.rs index 9094c19a..89a8cdaf 100644 --- a/crates/egui_demo_lib/src/demo/code_example.rs +++ b/crates/egui_demo_lib/src/demo/code_example.rs @@ -105,7 +105,7 @@ impl crate::Demo for CodeExample { } fn show(&mut self, ctx: &egui::Context, open: &mut bool) { - use crate::View; + use crate::View as _; egui::Window::new(self.name()) .open(open) .min_width(375.0) diff --git a/crates/egui_demo_lib/src/demo/demo_app_windows.rs b/crates/egui_demo_lib/src/demo/demo_app_windows.rs index ce18ac92..7b897278 100644 --- a/crates/egui_demo_lib/src/demo/demo_app_windows.rs +++ b/crates/egui_demo_lib/src/demo/demo_app_windows.rs @@ -3,7 +3,7 @@ use std::collections::BTreeSet; use super::About; use crate::is_mobile; use crate::Demo; -use crate::View; +use crate::View as _; use egui::containers::menu; use egui::style::StyleModifier; use egui::{Context, Modifiers, ScrollArea, Ui}; @@ -359,9 +359,9 @@ fn file_menu_button(ui: &mut Ui) { #[cfg(test)] mod tests { - use crate::{demo::demo_app_windows::DemoGroups, Demo}; + use crate::{demo::demo_app_windows::DemoGroups, Demo as _}; use egui::Vec2; - use egui_kittest::kittest::Queryable; + use egui_kittest::kittest::Queryable as _; use egui_kittest::{Harness, SnapshotOptions, SnapshotResults}; #[test] diff --git a/crates/egui_demo_lib/src/demo/font_book.rs b/crates/egui_demo_lib/src/demo/font_book.rs index 605b7ed7..1ef9867f 100644 --- a/crates/egui_demo_lib/src/demo/font_book.rs +++ b/crates/egui_demo_lib/src/demo/font_book.rs @@ -169,7 +169,7 @@ fn char_name(chr: char) -> String { } fn special_char_name(chr: char) -> Option<&'static str> { - #[allow(clippy::match_same_arms)] // many "flag" + #[expect(clippy::match_same_arms)] // many "flag" match chr { // Special private-use-area extensions found in `emoji-icon-font.ttf`: // Private use area extensions: diff --git a/crates/egui_demo_lib/src/demo/interactive_container.rs b/crates/egui_demo_lib/src/demo/interactive_container.rs index 11d8afa4..5faeb845 100644 --- a/crates/egui_demo_lib/src/demo/interactive_container.rs +++ b/crates/egui_demo_lib/src/demo/interactive_container.rs @@ -1,4 +1,4 @@ -use egui::{Frame, Label, RichText, Sense, UiBuilder, Widget}; +use egui::{Frame, Label, RichText, Sense, UiBuilder, Widget as _}; /// Showcase [`egui::Ui::response`]. #[derive(PartialEq, Eq, Default)] diff --git a/crates/egui_demo_lib/src/demo/modals.rs b/crates/egui_demo_lib/src/demo/modals.rs index f83820e7..fcb33f0b 100644 --- a/crates/egui_demo_lib/src/demo/modals.rs +++ b/crates/egui_demo_lib/src/demo/modals.rs @@ -1,4 +1,4 @@ -use egui::{ComboBox, Context, Id, Modal, ProgressBar, Ui, Widget, Window}; +use egui::{ComboBox, Context, Id, Modal, ProgressBar, Ui, Widget as _, Window}; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(default))] @@ -163,10 +163,10 @@ impl crate::View for Modals { #[cfg(test)] mod tests { use crate::demo::modals::Modals; - use crate::Demo; + use crate::Demo as _; use egui::accesskit::Role; use egui::Key; - use egui_kittest::kittest::Queryable; + use egui_kittest::kittest::Queryable as _; use egui_kittest::{Harness, SnapshotResults}; #[test] diff --git a/crates/egui_demo_lib/src/demo/paint_bezier.rs b/crates/egui_demo_lib/src/demo/paint_bezier.rs index 08e29a9f..df85e437 100644 --- a/crates/egui_demo_lib/src/demo/paint_bezier.rs +++ b/crates/egui_demo_lib/src/demo/paint_bezier.rs @@ -2,7 +2,7 @@ use egui::{ emath, epaint::{self, CubicBezierShape, PathShape, QuadraticBezierShape}, pos2, Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2, - Widget, Window, + Widget as _, Window, }; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/demo/password.rs b/crates/egui_demo_lib/src/demo/password.rs index 528f5a51..88a2bb70 100644 --- a/crates/egui_demo_lib/src/demo/password.rs +++ b/crates/egui_demo_lib/src/demo/password.rs @@ -8,7 +8,6 @@ /// ``` ignore /// password_ui(ui, &mut my_password); /// ``` -#[allow(clippy::ptr_arg)] // false positive pub fn password_ui(ui: &mut egui::Ui, password: &mut String) -> egui::Response { // This widget has its own state — show or hide password characters (`show_plaintext`). // In this case we use a simple `bool`, but you can also declare your own type. diff --git a/crates/egui_demo_lib/src/demo/screenshot.rs b/crates/egui_demo_lib/src/demo/screenshot.rs index eb62611c..c2367914 100644 --- a/crates/egui_demo_lib/src/demo/screenshot.rs +++ b/crates/egui_demo_lib/src/demo/screenshot.rs @@ -1,4 +1,4 @@ -use egui::{Image, UserData, ViewportCommand, Widget}; +use egui::{Image, UserData, ViewportCommand, Widget as _}; use std::sync::Arc; /// Showcase [`ViewportCommand::Screenshot`]. diff --git a/crates/egui_demo_lib/src/demo/scrolling.rs b/crates/egui_demo_lib/src/demo/scrolling.rs index 7a2ca4d7..dab3c4f5 100644 --- a/crates/egui_demo_lib/src/demo/scrolling.rs +++ b/crates/egui_demo_lib/src/demo/scrolling.rs @@ -1,6 +1,6 @@ use egui::{ - pos2, scroll_area::ScrollBarVisibility, Align, Align2, Color32, DragValue, NumExt, Rect, - ScrollArea, Sense, Slider, TextStyle, TextWrapMode, Ui, Vec2, Widget, + pos2, scroll_area::ScrollBarVisibility, Align, Align2, Color32, DragValue, NumExt as _, Rect, + ScrollArea, Sense, Slider, TextStyle, TextWrapMode, Ui, Vec2, Widget as _, }; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs b/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs index 031f3e2c..20e8d21b 100644 --- a/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs +++ b/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs @@ -1,5 +1,5 @@ use egui::{ - emath::{GuiRounding, TSTransform}, + emath::{GuiRounding as _, TSTransform}, epaint::{self, RectShape}, vec2, Color32, Pos2, Rect, Sense, StrokeKind, Vec2, }; diff --git a/crates/egui_demo_lib/src/demo/text_edit.rs b/crates/egui_demo_lib/src/demo/text_edit.rs index 06911957..685a9c38 100644 --- a/crates/egui_demo_lib/src/demo/text_edit.rs +++ b/crates/egui_demo_lib/src/demo/text_edit.rs @@ -114,7 +114,7 @@ impl crate::View for TextEditDemo { #[cfg(test)] mod tests { use egui::{accesskit, CentralPanel}; - use egui_kittest::kittest::{Key, Queryable}; + use egui_kittest::kittest::{Key, Queryable as _}; use egui_kittest::Harness; #[test] diff --git a/crates/egui_demo_lib/src/demo/toggle_switch.rs b/crates/egui_demo_lib/src/demo/toggle_switch.rs index 9619bd2c..623228cb 100644 --- a/crates/egui_demo_lib/src/demo/toggle_switch.rs +++ b/crates/egui_demo_lib/src/demo/toggle_switch.rs @@ -76,7 +76,7 @@ pub fn toggle_ui(ui: &mut egui::Ui, on: &mut bool) -> egui::Response { } /// Here is the same code again, but a bit more compact: -#[allow(dead_code)] +#[expect(dead_code)] fn toggle_ui_compact(ui: &mut egui::Ui, on: &mut bool) -> egui::Response { let desired_size = ui.spacing().interact_size.y * egui::vec2(2.0, 1.0); let (rect, mut response) = ui.allocate_exact_size(desired_size, egui::Sense::click()); diff --git a/crates/egui_demo_lib/src/demo/widget_gallery.rs b/crates/egui_demo_lib/src/demo/widget_gallery.rs index 6005d6ae..c7b6df28 100644 --- a/crates/egui_demo_lib/src/demo/widget_gallery.rs +++ b/crates/egui_demo_lib/src/demo/widget_gallery.rs @@ -48,7 +48,7 @@ impl Default for WidgetGallery { } impl WidgetGallery { - #[allow(unused_mut)] // if not chrono + #[allow(unused_mut, clippy::allow_attributes)] // if not chrono #[inline] pub fn with_date_button(mut self, _with_date_button: bool) -> Self { #[cfg(feature = "chrono")] @@ -308,7 +308,7 @@ fn doc_link_label_with_crate<'a>( #[cfg(test)] mod tests { use super::*; - use crate::View; + use crate::View as _; use egui::Vec2; use egui_kittest::Harness; diff --git a/crates/egui_extras/src/datepicker/mod.rs b/crates/egui_extras/src/datepicker/mod.rs index 33038d76..e7ba47e7 100644 --- a/crates/egui_extras/src/datepicker/mod.rs +++ b/crates/egui_extras/src/datepicker/mod.rs @@ -2,7 +2,7 @@ mod button; mod popup; pub use button::DatePickerButton; -use chrono::{Datelike, Duration, NaiveDate, Weekday}; +use chrono::{Datelike as _, Duration, NaiveDate, Weekday}; #[derive(Debug)] struct Week { diff --git a/crates/egui_extras/src/datepicker/popup.rs b/crates/egui_extras/src/datepicker/popup.rs index 8bf2f1a1..79f3d37f 100644 --- a/crates/egui_extras/src/datepicker/popup.rs +++ b/crates/egui_extras/src/datepicker/popup.rs @@ -1,4 +1,4 @@ -use chrono::{Datelike, NaiveDate, Weekday}; +use chrono::{Datelike as _, NaiveDate, Weekday}; use egui::{Align, Button, Color32, ComboBox, Direction, Id, Layout, RichText, Ui, Vec2}; diff --git a/crates/egui_extras/src/layout.rs b/crates/egui_extras/src/layout.rs index fb62cec4..b1c79d0a 100644 --- a/crates/egui_extras/src/layout.rs +++ b/crates/egui_extras/src/layout.rs @@ -1,4 +1,4 @@ -use egui::{emath::GuiRounding, Id, Pos2, Rect, Response, Sense, Ui, UiBuilder}; +use egui::{emath::GuiRounding as _, Id, Pos2, Rect, Response, Sense, Ui, UiBuilder}; #[derive(Clone, Copy)] pub(crate) enum CellSize { diff --git a/crates/egui_extras/src/lib.rs b/crates/egui_extras/src/lib.rs index 6f339010..1a58402f 100644 --- a/crates/egui_extras/src/lib.rs +++ b/crates/egui_extras/src/lib.rs @@ -26,7 +26,7 @@ mod table; pub use crate::datepicker::DatePickerButton; #[doc(hidden)] -#[allow(deprecated)] +#[expect(deprecated)] pub use crate::image::RetainedImage; pub(crate) use crate::layout::StripLayout; pub use crate::sizing::Size; diff --git a/crates/egui_extras/src/loaders/image_loader.rs b/crates/egui_extras/src/loaders/image_loader.rs index 87ca4db0..bb025651 100644 --- a/crates/egui_extras/src/loaders/image_loader.rs +++ b/crates/egui_extras/src/loaders/image_loader.rs @@ -77,7 +77,7 @@ impl ImageLoader for ImageCrateLoader { } #[cfg(not(target_arch = "wasm32"))] - #[allow(clippy::unnecessary_wraps)] // needed here to match other return types + #[expect(clippy::unnecessary_wraps)] // needed here to match other return types fn load_image( ctx: &egui::Context, uri: &str, diff --git a/crates/egui_extras/src/loaders/svg_loader.rs b/crates/egui_extras/src/loaders/svg_loader.rs index 4c33281f..63cfd4a9 100644 --- a/crates/egui_extras/src/loaders/svg_loader.rs +++ b/crates/egui_extras/src/loaders/svg_loader.rs @@ -30,7 +30,7 @@ fn is_supported(uri: &str) -> bool { impl Default for SvgLoader { fn default() -> Self { // opt is mutated when `svg_text` feature flag is enabled - #[allow(unused_mut)] + #[allow(unused_mut, clippy::allow_attributes)] let mut options = resvg::usvg::Options::default(); #[cfg(feature = "svg_text")] diff --git a/crates/egui_extras/src/loaders/webp_loader.rs b/crates/egui_extras/src/loaders/webp_loader.rs index 528c449a..ef1a5d52 100644 --- a/crates/egui_extras/src/loaders/webp_loader.rs +++ b/crates/egui_extras/src/loaders/webp_loader.rs @@ -5,7 +5,7 @@ use egui::{ mutex::Mutex, ColorImage, FrameDurations, Id, }; -use image::{codecs::webp::WebPDecoder, AnimationDecoder as _, ColorType, ImageDecoder, Rgba}; +use image::{codecs::webp::WebPDecoder, AnimationDecoder as _, ColorType, ImageDecoder as _, Rgba}; use std::{io::Cursor, mem::size_of, sync::Arc, time::Duration}; #[derive(Clone)] diff --git a/crates/egui_extras/src/syntax_highlighting.rs b/crates/egui_extras/src/syntax_highlighting.rs index ac51c673..6bb51184 100644 --- a/crates/egui_extras/src/syntax_highlighting.rs +++ b/crates/egui_extras/src/syntax_highlighting.rs @@ -33,7 +33,7 @@ pub fn highlight( // performing it at a separate thread (ctx, ctx.style()) can be used and when ui is available // (ui.ctx(), ui.style()) can be used - #[allow(non_local_definitions)] + #[expect(non_local_definitions)] impl egui::cache::ComputerMut<(&egui::FontId, &CodeTheme, &str, &str), LayoutJob> for Highlighter { fn compute( &mut self, @@ -285,7 +285,7 @@ impl CodeTheme { impl CodeTheme { // The syntect version takes it by value. This could be avoided by specializing the from_style // function, but at the cost of more code duplication. - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] fn dark_with_font_id(font_id: egui::FontId) -> Self { use egui::{Color32, TextFormat}; Self { @@ -302,7 +302,7 @@ impl CodeTheme { } // The syntect version takes it by value - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] fn light_with_font_id(font_id: egui::FontId) -> Self { use egui::{Color32, TextFormat}; Self { @@ -413,7 +413,6 @@ impl Default for Highlighter { } impl Highlighter { - #[allow(clippy::unused_self, clippy::unnecessary_wraps)] fn highlight( &self, font_id: egui::FontId, @@ -512,7 +511,7 @@ struct Highlighter {} #[cfg(not(feature = "syntect"))] impl Highlighter { - #[allow(clippy::unused_self, clippy::unnecessary_wraps)] + #[expect(clippy::unused_self, clippy::unnecessary_wraps)] fn highlight_impl( &self, theme: &CodeTheme, diff --git a/crates/egui_glow/examples/pure_glow.rs b/crates/egui_glow/examples/pure_glow.rs index d151be37..7f38700c 100644 --- a/crates/egui_glow/examples/pure_glow.rs +++ b/crates/egui_glow/examples/pure_glow.rs @@ -9,7 +9,7 @@ use std::num::NonZeroU32; use std::sync::Arc; use egui_winit::winit; -use winit::raw_window_handle::HasWindowHandle; +use winit::raw_window_handle::HasWindowHandle as _; /// The majority of `GlutinWindowContext` is taken from `eframe` struct GlutinWindowContext { @@ -22,12 +22,12 @@ struct GlutinWindowContext { impl GlutinWindowContext { // refactor this function to use `glutin-winit` crate eventually. // preferably add android support at the same time. - #[allow(unsafe_code)] + #[expect(unsafe_code)] unsafe fn new(event_loop: &winit::event_loop::ActiveEventLoop) -> Self { - use glutin::context::NotCurrentGlContext; - use glutin::display::GetGlDisplay; - use glutin::display::GlDisplay; - use glutin::prelude::GlSurface; + use glutin::context::NotCurrentGlContext as _; + use glutin::display::GetGlDisplay as _; + use glutin::display::GlDisplay as _; + use glutin::prelude::GlSurface as _; let winit_window_builder = winit::window::WindowAttributes::default() .with_resizable(true) .with_inner_size(winit::dpi::LogicalSize { @@ -138,7 +138,7 @@ impl GlutinWindowContext { } fn resize(&self, physical_size: winit::dpi::PhysicalSize) { - use glutin::surface::GlSurface; + use glutin::surface::GlSurface as _; self.gl_surface.resize( &self.gl_context, physical_size.width.try_into().unwrap(), @@ -147,12 +147,12 @@ impl GlutinWindowContext { } fn swap_buffers(&self) -> glutin::error::Result<()> { - use glutin::surface::GlSurface; + use glutin::surface::GlSurface as _; self.gl_surface.swap_buffers(&self.gl_context) } fn get_proc_address(&self, addr: &std::ffi::CStr) -> *const std::ffi::c_void { - use glutin::display::GlDisplay; + use glutin::display::GlDisplay as _; self.gl_display.get_proc_address(addr) } } diff --git a/crates/egui_glow/src/lib.rs b/crates/egui_glow/src/lib.rs index 430f1287..aaea1d0b 100644 --- a/crates/egui_glow/src/lib.rs +++ b/crates/egui_glow/src/lib.rs @@ -73,7 +73,7 @@ macro_rules! check_for_gl_error_even_in_release { #[doc(hidden)] pub fn check_for_gl_error_impl(gl: &glow::Context, file: &str, line: u32, context: &str) { use glow::HasContext as _; - #[allow(unsafe_code)] + #[expect(unsafe_code)] let error_code = unsafe { gl.get_error() }; if error_code != glow::NO_ERROR { let error_str = match error_code { diff --git a/crates/egui_glow/src/painter.rs b/crates/egui_glow/src/painter.rs index 1d1322c4..939246e6 100644 --- a/crates/egui_glow/src/painter.rs +++ b/crates/egui_glow/src/painter.rs @@ -296,7 +296,7 @@ impl Painter { /// So if in a [`egui::Shape::Callback`] you need to use an offscreen FBO, you should /// then restore to this afterwards with /// `gl.bind_framebuffer(glow::FRAMEBUFFER, painter.intermediate_fbo());` - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub fn intermediate_fbo(&self) -> Option { // We don't currently ever render to an offscreen buffer, // but we may want to start to in order to do anti-aliasing on web, for instance. @@ -663,7 +663,6 @@ impl Painter { self.textures.get(&texture_id).copied() } - #[allow(clippy::needless_pass_by_value)] // False positive pub fn register_native_texture(&mut self, native: glow::Texture) -> egui::TextureId { self.assert_not_destroyed(); let id = egui::TextureId::User(self.next_native_tex_id); @@ -672,7 +671,6 @@ impl Painter { id } - #[allow(clippy::needless_pass_by_value)] // False positive pub fn replace_native_texture(&mut self, id: egui::TextureId, replacing: glow::Texture) { if let Some(old_tex) = self.textures.insert(id, replacing) { self.textures_to_destroy.push(old_tex); diff --git a/crates/egui_glow/src/shader_version.rs b/crates/egui_glow/src/shader_version.rs index 77c1e63c..249cda36 100644 --- a/crates/egui_glow/src/shader_version.rs +++ b/crates/egui_glow/src/shader_version.rs @@ -1,11 +1,10 @@ #![allow(unsafe_code)] #![allow(clippy::undocumented_unsafe_blocks)] -use std::convert::TryInto; +use std::convert::TryInto as _; /// Helper for parsing and interpreting the OpenGL shader version. #[derive(Copy, Clone, Debug, PartialEq, Eq)] -#[allow(dead_code)] pub enum ShaderVersion { Gl120, diff --git a/crates/egui_glow/src/vao.rs b/crates/egui_glow/src/vao.rs index 6759a829..febe67fd 100644 --- a/crates/egui_glow/src/vao.rs +++ b/crates/egui_glow/src/vao.rs @@ -27,7 +27,6 @@ pub(crate) struct VertexArrayObject { } impl VertexArrayObject { - #[allow(clippy::needless_pass_by_value)] // false positive pub(crate) unsafe fn new( gl: &glow::Context, vbo: glow::Buffer, diff --git a/crates/egui_kittest/src/snapshot.rs b/crates/egui_kittest/src/snapshot.rs index 86ed053d..acd260a4 100644 --- a/crates/egui_kittest/src/snapshot.rs +++ b/crates/egui_kittest/src/snapshot.rs @@ -339,6 +339,7 @@ pub fn image_snapshot_options(current: &image::RgbaImage, name: &str, options: & } /// Image snapshot test. +/// /// The snapshot will be saved under `tests/snapshots/{name}.png`. /// The new image from the last test run will be saved under `tests/snapshots/{name}.new.png`. /// If the new image didn't match the snapshot, a diff image will be saved under `tests/snapshots/{name}.diff.png`. @@ -451,7 +452,7 @@ impl Harness<'_, State> { // Deprecated wgpu_snapshot functions // TODO(lucasmerlin): Remove in 0.32 -#[allow(clippy::missing_errors_doc)] +#[expect(clippy::missing_errors_doc)] #[cfg(feature = "wgpu")] impl Harness<'_, State> { #[deprecated( @@ -552,7 +553,7 @@ impl SnapshotResults { } /// Convert this into a `Result<(), Self>`. - #[allow(clippy::missing_errors_doc)] + #[expect(clippy::missing_errors_doc)] pub fn into_result(self) -> Result<(), Self> { if self.has_errors() { Err(self) @@ -566,7 +567,7 @@ impl SnapshotResults { } /// Panics if there are any errors, displaying each. - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] #[track_caller] pub fn unwrap(self) { // Panic is handled in drop @@ -586,7 +587,7 @@ impl Drop for SnapshotResults { if std::thread::panicking() { return; } - #[allow(clippy::manual_assert)] + #[expect(clippy::manual_assert)] if self.has_errors() { panic!("{}", self); } diff --git a/crates/egui_kittest/tests/menu.rs b/crates/egui_kittest/tests/menu.rs index 4c6d6fd5..a01e39dc 100644 --- a/crates/egui_kittest/tests/menu.rs +++ b/crates/egui_kittest/tests/menu.rs @@ -1,7 +1,7 @@ use egui::containers::menu::{Bar, MenuConfig, SubMenuButton}; use egui::{include_image, PopupCloseBehavior, Ui}; use egui_kittest::{Harness, SnapshotResults}; -use kittest::Queryable; +use kittest::Queryable as _; struct TestMenu { config: MenuConfig, diff --git a/crates/egui_kittest/tests/popup.rs b/crates/egui_kittest/tests/popup.rs index f55bf638..368e8de7 100644 --- a/crates/egui_kittest/tests/popup.rs +++ b/crates/egui_kittest/tests/popup.rs @@ -1,4 +1,4 @@ -use kittest::Queryable; +use kittest::Queryable as _; #[test] fn test_interactive_tooltip() { diff --git a/crates/egui_kittest/tests/regression_tests.rs b/crates/egui_kittest/tests/regression_tests.rs index bd3f7926..50ed1095 100644 --- a/crates/egui_kittest/tests/regression_tests.rs +++ b/crates/egui_kittest/tests/regression_tests.rs @@ -1,6 +1,6 @@ use egui::accesskit::Role; -use egui::{Button, ComboBox, Image, Vec2, Widget}; -use egui_kittest::{kittest::Queryable, Harness, SnapshotResults}; +use egui::{Button, ComboBox, Image, Vec2, Widget as _}; +use egui_kittest::{kittest::Queryable as _, Harness, SnapshotResults}; #[test] pub fn focus_should_skip_over_disabled_buttons() { diff --git a/crates/egui_kittest/tests/tests.rs b/crates/egui_kittest/tests/tests.rs index 52f455c7..9bf07063 100644 --- a/crates/egui_kittest/tests/tests.rs +++ b/crates/egui_kittest/tests/tests.rs @@ -1,6 +1,6 @@ use egui::Modifiers; use egui_kittest::Harness; -use kittest::{Key, Queryable}; +use kittest::{Key, Queryable as _}; #[test] fn test_shrink() { diff --git a/crates/emath/src/lib.rs b/crates/emath/src/lib.rs index ad657fcc..337fa204 100644 --- a/crates/emath/src/lib.rs +++ b/crates/emath/src/lib.rs @@ -248,7 +248,7 @@ pub fn almost_equal(a: f32, b: f32, epsilon: f32) -> bool { } } -#[allow(clippy::approx_constant)] +#[expect(clippy::approx_constant)] #[test] fn test_format() { assert_eq!(format_with_minimum_decimals(1_234_567.0, 0), "1234567"); diff --git a/crates/emath/src/numeric.rs b/crates/emath/src/numeric.rs index 9a7814b2..1fbddbc6 100644 --- a/crates/emath/src/numeric.rs +++ b/crates/emath/src/numeric.rs @@ -23,7 +23,7 @@ macro_rules! impl_numeric_float { #[inline(always)] fn to_f64(self) -> f64 { - #[allow(trivial_numeric_casts)] + #[allow(trivial_numeric_casts, clippy::allow_attributes)] { self as f64 } @@ -31,7 +31,7 @@ macro_rules! impl_numeric_float { #[inline(always)] fn from_f64(num: f64) -> Self { - #[allow(trivial_numeric_casts)] + #[allow(trivial_numeric_casts, clippy::allow_attributes)] { num as Self } diff --git a/crates/emath/src/ordered_float.rs b/crates/emath/src/ordered_float.rs index 0b8014d9..fa80a498 100644 --- a/crates/emath/src/ordered_float.rs +++ b/crates/emath/src/ordered_float.rs @@ -101,7 +101,7 @@ impl Float for f64 { // Keep this trait in private module, to avoid exposing its methods as extensions in user code mod private { - use super::{Hash, Hasher}; + use super::{Hash as _, Hasher}; pub trait FloatImpl { fn is_nan(&self) -> bool; diff --git a/crates/emath/src/smart_aim.rs b/crates/emath/src/smart_aim.rs index 9ef010d9..e75ae42c 100644 --- a/crates/emath/src/smart_aim.rs +++ b/crates/emath/src/smart_aim.rs @@ -115,7 +115,7 @@ fn simplest_digit_closed_range(min: i32, max: i32) -> i32 { } } -#[allow(clippy::approx_constant)] +#[expect(clippy::approx_constant)] #[test] fn test_aim() { assert_eq!(best_in_range_f64(-0.2, 0.0), 0.0, "Prefer zero"); diff --git a/crates/epaint/src/lib.rs b/crates/epaint/src/lib.rs index f84a8caf..a1972769 100644 --- a/crates/epaint/src/lib.rs +++ b/crates/epaint/src/lib.rs @@ -72,7 +72,7 @@ pub use self::{ #[deprecated = "Renamed to CornerRadius"] pub type Rounding = CornerRadius; -#[allow(deprecated)] +#[expect(deprecated)] pub use tessellator::tessellate_shapes; pub use ecolor::{Color32, Hsva, HsvaGamma, Rgba}; diff --git a/crates/epaint/src/shapes/shape.rs b/crates/epaint/src/shapes/shape.rs index a855d653..bc16e43d 100644 --- a/crates/epaint/src/shapes/shape.rs +++ b/crates/epaint/src/shapes/shape.rs @@ -296,7 +296,7 @@ impl Shape { Self::Rect(RectShape::stroke(rect, corner_radius, stroke, stroke_kind)) } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn text( fonts: &Fonts, pos: Pos2, diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index 2b24869a..32f715b1 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -5,7 +5,7 @@ #![allow(clippy::identity_op)] -use emath::{pos2, remap, vec2, GuiRounding as _, NumExt, Pos2, Rect, Rot2, Vec2}; +use emath::{pos2, remap, vec2, GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2}; use crate::{ color::ColorMode, emath, stroke::PathStroke, texture_atlas::PreparedDisc, CircleShape, @@ -16,7 +16,7 @@ use crate::{ // ---------------------------------------------------------------------------- -#[allow(clippy::approx_constant)] +#[expect(clippy::approx_constant)] mod precomputed_vertices { // fn main() { // let n = 64; @@ -2222,7 +2222,7 @@ impl Tessellator { /// /// ## Returns /// A list of clip rectangles with matching [`Mesh`]. - #[allow(unused_mut)] + #[allow(unused_mut, clippy::allow_attributes)] pub fn tessellate_shapes(&mut self, mut shapes: Vec) -> Vec { profiling::function_scope!(); diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 5415bae0..78d9c141 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use std::sync::Arc; -use emath::{vec2, GuiRounding, Vec2}; +use emath::{vec2, GuiRounding as _, Vec2}; use crate::{ mutex::{Mutex, RwLock}, @@ -100,7 +100,7 @@ impl FontImpl { "pixels_per_point must be greater than 0, got: {pixels_per_point:?}" ); - use ab_glyph::{Font, ScaleFont}; + use ab_glyph::{Font as _, ScaleFont as _}; let scaled = ab_glyph_font.as_scaled(scale_in_pixels); let ascent = (scaled.ascent() / pixels_per_point).round_ui(); let descent = (scaled.descent() / pixels_per_point).round_ui(); @@ -241,7 +241,7 @@ impl FontImpl { last_glyph_id: ab_glyph::GlyphId, glyph_id: ab_glyph::GlyphId, ) -> f32 { - use ab_glyph::{Font as _, ScaleFont}; + use ab_glyph::{Font as _, ScaleFont as _}; self.ab_glyph_font .as_scaled(self.scale_in_pixels as f32) .kern(last_glyph_id, glyph_id) @@ -271,7 +271,7 @@ impl FontImpl { fn allocate_glyph(&self, glyph_id: ab_glyph::GlyphId) -> GlyphInfo { assert!(glyph_id.0 != 0, "Can't allocate glyph for id 0"); - use ab_glyph::{Font as _, ScaleFont}; + use ab_glyph::{Font as _, ScaleFont as _}; let glyph = glyph_id.with_scale_and_position( self.scale_in_pixels as f32, diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index bfa85468..bca9212d 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -54,7 +54,6 @@ impl FontId { } } -#[allow(clippy::derived_hash_with_manual_eq)] impl std::hash::Hash for FontId { #[inline(always)] fn hash(&self, state: &mut H) { diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index b2dba96f..63dfc389 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use emath::{pos2, vec2, Align, GuiRounding as _, NumExt, Pos2, Rect, Vec2}; +use emath::{pos2, vec2, Align, GuiRounding as _, NumExt as _, Pos2, Rect, Vec2}; use crate::{stroke::PathStroke, text::font::Font, Color32, Mesh, Stroke, Vertex}; diff --git a/crates/epaint/src/text/text_layout_types.rs b/crates/epaint/src/text/text_layout_types.rs index 4bd15d3e..49ec2908 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -9,7 +9,7 @@ use super::{ font::UvRect, }; use crate::{Color32, FontId, Mesh, Stroke}; -use emath::{pos2, vec2, Align, GuiRounding as _, NumExt, OrderedFloat, Pos2, Rect, Vec2}; +use emath::{pos2, vec2, Align, GuiRounding as _, NumExt as _, OrderedFloat, Pos2, Rect, Vec2}; /// Describes the task of laying out text. /// @@ -971,7 +971,7 @@ impl Galley { /// /// This is the same as [`CCursor::default`]. #[inline] - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub fn begin(&self) -> CCursor { CCursor::default() } @@ -1062,7 +1062,7 @@ impl Galley { /// ## Cursor positions impl Galley { - #[allow(clippy::unused_self)] + #[expect(clippy::unused_self)] pub fn cursor_left_one_character(&self, cursor: &CCursor) -> CCursor { if cursor.index == 0 { Default::default() diff --git a/crates/epaint/src/texture_handle.rs b/crates/epaint/src/texture_handle.rs index 1f640a17..31543775 100644 --- a/crates/epaint/src/texture_handle.rs +++ b/crates/epaint/src/texture_handle.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use crate::{ - emath::NumExt, mutex::RwLock, textures::TextureOptions, ImageData, ImageDelta, TextureId, + emath::NumExt as _, mutex::RwLock, textures::TextureOptions, ImageData, ImageDelta, TextureId, TextureManager, }; @@ -66,7 +66,7 @@ impl TextureHandle { } /// Assign a new image to an existing texture. - #[allow(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability + #[expect(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability pub fn set(&mut self, image: impl Into, options: TextureOptions) { self.tex_mngr .write() @@ -74,7 +74,7 @@ impl TextureHandle { } /// Assign a new image to a subregion of the whole texture. - #[allow(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability + #[expect(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability pub fn set_partial( &mut self, pos: [usize; 2], diff --git a/examples/custom_style/src/main.rs b/examples/custom_style/src/main.rs index 11113937..1e78bea0 100644 --- a/examples/custom_style/src/main.rs +++ b/examples/custom_style/src/main.rs @@ -4,7 +4,7 @@ use eframe::egui::{ self, global_theme_preference_buttons, style::Selection, Color32, Stroke, Style, Theme, }; -use egui_demo_lib::{View, WidgetGallery}; +use egui_demo_lib::{View as _, WidgetGallery}; fn main() -> eframe::Result { env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index f2d7a0c0..b75a20e0 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -165,7 +165,7 @@ fn start_puffin_server() { // We can store the server if we want, but in this case we just want // it to keep running. Dropping it closes the server, so let's not drop it! - #[allow(clippy::mem_forget)] + #[expect(clippy::mem_forget)] std::mem::forget(puffin_server); } Err(err) => { diff --git a/tests/egui_tests/tests/test_widgets.rs b/tests/egui_tests/tests/test_widgets.rs index 264b0052..96015cbd 100644 --- a/tests/egui_tests/tests/test_widgets.rs +++ b/tests/egui_tests/tests/test_widgets.rs @@ -2,9 +2,9 @@ use egui::load::SizedTexture; use egui::{ include_image, Align, Button, Color32, ColorImage, Direction, DragValue, Event, Grid, Layout, PointerButton, Pos2, Response, Slider, Stroke, StrokeKind, TextWrapMode, TextureHandle, - TextureOptions, Ui, UiBuilder, Vec2, Widget, + TextureOptions, Ui, UiBuilder, Vec2, Widget as _, }; -use egui_kittest::kittest::{by, Node, Queryable}; +use egui_kittest::kittest::{by, Node, Queryable as _}; use egui_kittest::{Harness, SnapshotResult, SnapshotResults}; #[test] diff --git a/tests/test_inline_glow_paint/src/main.rs b/tests/test_inline_glow_paint/src/main.rs index 12569652..3245af34 100644 --- a/tests/test_inline_glow_paint/src/main.rs +++ b/tests/test_inline_glow_paint/src/main.rs @@ -29,7 +29,7 @@ impl eframe::App for MyTestApp { use glow::HasContext as _; let gl = frame.gl().unwrap(); - #[allow(unsafe_code)] + #[expect(unsafe_code)] unsafe { gl.disable(glow::SCISSOR_TEST); gl.viewport(0, 0, 100, 100);