1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Replace #[allow attributes with expect (#7796)

We do have `clippy::allow_attributes` turned on, but it doesn't seem to
work properly
This commit is contained in:
Emil Ernerfeldt
2025-12-19 20:55:50 +01:00
committed by GitHub
parent 7fe58bbfd4
commit 8d98763fe1
75 changed files with 89 additions and 111 deletions

View File

@@ -41,7 +41,7 @@ impl Hsva {
/// From linear RGBA with premultiplied alpha /// From linear RGBA with premultiplied alpha
#[inline] #[inline]
pub fn from_rgba_premultiplied(r: f32, g: f32, b: f32, a: f32) -> Self { pub fn from_rgba_premultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
#![allow(clippy::many_single_char_names)] #![expect(clippy::many_single_char_names)]
if a <= 0.0 { if a <= 0.0 {
if r == 0.0 && b == 0.0 && a == 0.0 { if r == 0.0 && b == 0.0 && a == 0.0 {
Self::default() Self::default()
@@ -57,7 +57,7 @@ impl Hsva {
/// From linear RGBA without premultiplied alpha /// From linear RGBA without premultiplied alpha
#[inline] #[inline]
pub fn from_rgba_unmultiplied(r: f32, g: f32, b: f32, a: f32) -> Self { pub fn from_rgba_unmultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
#![allow(clippy::many_single_char_names)] #![expect(clippy::many_single_char_names)]
let (h, s, v) = hsv_from_rgb([r, g, b]); let (h, s, v) = hsv_from_rgb([r, g, b]);
Self { h, s, v, a } Self { h, s, v, a }
} }
@@ -189,7 +189,7 @@ impl From<Color32> for Hsva {
/// All ranges in 0-1, rgb is linear. /// All ranges in 0-1, rgb is linear.
#[inline] #[inline]
pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) { pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) {
#![allow(clippy::many_single_char_names)] #![expect(clippy::many_single_char_names)]
let min = r.min(g.min(b)); let min = r.min(g.min(b));
let max = r.max(g.max(b)); // value let max = r.max(g.max(b)); // value
@@ -213,7 +213,7 @@ pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) {
/// All ranges in 0-1, rgb is linear. /// All ranges in 0-1, rgb is linear.
#[inline] #[inline]
pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] { pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] {
#![allow(clippy::many_single_char_names)] #![expect(clippy::many_single_char_names)]
let h = (h.fract() + 1.0).fract(); // wrap let h = (h.fract() + 1.0).fract(); // wrap
let s = s.clamp(0.0, 1.0); let s = s.clamp(0.0, 1.0);

View File

@@ -19,7 +19,7 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//! //!
#![allow(clippy::wrong_self_convention)] #![expect(clippy::wrong_self_convention)]
#[cfg(feature = "cint")] #[cfg(feature = "cint")]
mod cint_impl; mod cint_impl;

View File

@@ -142,7 +142,6 @@
//! //!
#![warn(missing_docs)] // let's keep eframe well-documented #![warn(missing_docs)] // let's keep eframe well-documented
#![allow(clippy::needless_doctest_main)]
// Limitation imposed by `accesskit_winit`: // Limitation imposed by `accesskit_winit`:
// https://github.com/AccessKit/accesskit/tree/accesskit-v0.18.0/platforms/winit#android-activity-compatibility` // https://github.com/AccessKit/accesskit/tree/accesskit-v0.18.0/platforms/winit#android-activity-compatibility`
@@ -253,7 +252,7 @@ pub mod icon_data;
/// This function can fail if we fail to set up a graphics context. /// This function can fail if we fail to set up a graphics context.
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
#[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))] #[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))]
#[allow(clippy::needless_pass_by_value, clippy::allow_attributes)] #[allow(clippy::allow_attributes, clippy::needless_pass_by_value)]
pub fn run_native( pub fn run_native(
app_name: &str, app_name: &str,
mut native_options: NativeOptions, mut native_options: NativeOptions,

View File

@@ -47,7 +47,7 @@ enum AppIconStatus {
NotSetTryAgain, NotSetTryAgain,
/// We successfully set the icon and it should be visible now. /// We successfully set the icon and it should be visible now.
#[allow(dead_code, clippy::allow_attributes)] // Not used on Linux #[allow(clippy::allow_attributes, dead_code)] // Not used on Linux
Set, Set,
} }
@@ -71,7 +71,7 @@ fn set_title_and_icon(_title: &str, _icon_data: Option<&IconData>) -> AppIconSta
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
return set_title_and_icon_mac(_title, _icon_data); return set_title_and_icon_mac(_title, _icon_data);
#[allow(unreachable_code, clippy::allow_attributes)] #[allow(clippy::allow_attributes, unreachable_code)]
AppIconStatus::NotSetIgnored AppIconStatus::NotSetIgnored
} }

View File

@@ -349,8 +349,6 @@ pub fn run_glow(
mut native_options: epi::NativeOptions, mut native_options: epi::NativeOptions,
app_creator: epi::AppCreator<'_>, app_creator: epi::AppCreator<'_>,
) -> Result { ) -> Result {
#![allow(clippy::needless_return_with_question_mark)] // False positive
use super::glow_integration::GlowWinitApp; use super::glow_integration::GlowWinitApp;
#[cfg(not(target_os = "ios"))] #[cfg(not(target_os = "ios"))]
@@ -387,8 +385,6 @@ pub fn run_wgpu(
mut native_options: epi::NativeOptions, mut native_options: epi::NativeOptions,
app_creator: epi::AppCreator<'_>, app_creator: epi::AppCreator<'_>,
) -> Result { ) -> Result {
#![allow(clippy::needless_return_with_question_mark)] // False positive
use super::wgpu_integration::WgpuWinitApp; use super::wgpu_integration::WgpuWinitApp;
#[cfg(not(target_os = "ios"))] #[cfg(not(target_os = "ios"))]

View File

@@ -256,7 +256,7 @@ impl<'app> WgpuWinitApp<'app> {
}); });
} }
#[allow(unused_mut, clippy::allow_attributes)] // used for accesskit #[allow(clippy::allow_attributes, unused_mut)] // used for accesskit
let mut egui_winit = egui_winit::State::new( let mut egui_winit = egui_winit::State::new(
egui_ctx.clone(), egui_ctx.clone(),
ViewportId::ROOT, ViewportId::ROOT,

View File

@@ -1,4 +1,4 @@
#![allow(dead_code)] // not everything is used on wasm #![allow(clippy::allow_attributes, dead_code)] // not used on all platforms
use web_time::Instant; use web_time::Instant;

View File

@@ -7,7 +7,7 @@ use crate::{App, epi, web::web_painter::WebPainter};
use super::{NeedRepaint, now_sec, text_agent::TextAgent}; use super::{NeedRepaint, now_sec, text_agent::TextAgent};
pub struct AppRunner { pub struct AppRunner {
#[allow(dead_code, clippy::allow_attributes)] #[allow(clippy::allow_attributes, dead_code)]
pub(crate) web_options: crate::WebOptions, pub(crate) web_options: crate::WebOptions,
pub(crate) frame: epi::Frame, pub(crate) frame: epi::Frame,
egui_ctx: egui::Context, egui_ctx: egui::Context,

View File

@@ -38,7 +38,7 @@ impl log::Log for WebLogger {
} }
fn log(&self, record: &log::Record<'_>) { fn log(&self, record: &log::Record<'_>) {
#![allow(clippy::match_same_arms)] #![expect(clippy::match_same_arms)]
if !self.enabled(record.metadata()) { if !self.enabled(record.metadata()) {
return; return;
@@ -110,7 +110,7 @@ mod console {
/// * `tokio-1.24.1/src/runtime/runtime.rs` /// * `tokio-1.24.1/src/runtime/runtime.rs`
/// * `rerun/src/main.rs` /// * `rerun/src/main.rs`
/// * `core/src/ops/function.rs` /// * `core/src/ops/function.rs`
#[allow(dead_code, clippy::allow_attributes)] // only used on web and in tests #[allow(clippy::allow_attributes, dead_code)] // only used on web and in tests
fn shorten_file_path(file_path: &str) -> &str { fn shorten_file_path(file_path: &str) -> &str {
if let Some(i) = file_path.rfind("/src/") { if let Some(i) = file_path.rfind("/src/") {
if let Some(prev_slash) = file_path[..i].rfind('/') { if let Some(prev_slash) = file_path[..i].rfind('/') {

View File

@@ -28,7 +28,7 @@ impl WebPainterGlow {
let (gl, shader_prefix) = let (gl, shader_prefix) =
init_glow_context_from_canvas(&canvas, options.webgl_context_option)?; init_glow_context_from_canvas(&canvas, options.webgl_context_option)?;
#[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm #[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm
let gl = std::sync::Arc::new(gl); let gl = std::sync::Arc::new(gl);
let painter = egui_glow::Painter::new(gl, shader_prefix, None, options.dithering) let painter = egui_glow::Painter::new(gl, shader_prefix, None, options.dithering)

View File

@@ -126,7 +126,7 @@ impl CaptureState {
// It would be more efficient to reuse the Buffer, e.g. via some kind of ring buffer, but // 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) // 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. // it might make sense to revisit this and implement a more efficient solution.
#[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm #[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm
let buffer = device.create_buffer(&wgpu::BufferDescriptor { let buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("egui_screen_capture_buffer"), label: Some("egui_screen_capture_buffer"),
size: (self.padding.padded_bytes_per_row * self.texture.height()) as u64, size: (self.padding.padded_bytes_per_row * self.texture.height()) as u64,
@@ -186,7 +186,7 @@ impl CaptureState {
tx: CaptureSender, tx: CaptureSender,
viewport_id: ViewportId, viewport_id: ViewportId,
) { ) {
#[allow(clippy::arc_with_non_send_sync, clippy::allow_attributes)] // For wasm #[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm
let buffer = Arc::new(buffer); let buffer = Arc::new(buffer);
let buffer_clone = Arc::clone(&buffer); let buffer_clone = Arc::clone(&buffer);
let buffer_slice = buffer_clone.slice(..); let buffer_slice = buffer_clone.slice(..);

View File

@@ -16,8 +16,6 @@
#![doc = document_features::document_features!()] #![doc = document_features::document_features!()]
//! //!
#![allow(unsafe_code)]
pub use wgpu; pub use wgpu;
/// Low-level painting of [`egui`](https://github.com/emilk/egui) on [`wgpu`]. /// Low-level painting of [`egui`](https://github.com/emilk/egui) on [`wgpu`].
@@ -247,7 +245,7 @@ impl RenderState {
// On wasm, depending on feature flags, wgpu objects may or may not implement sync. // 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. // 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, clippy::allow_attributes)] // For wasm #[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm
Ok(Self { Ok(Self {
adapter, adapter,
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]

View File

@@ -48,7 +48,7 @@ impl WgpuSetup {
pub async fn new_instance(&self) -> wgpu::Instance { pub async fn new_instance(&self) -> wgpu::Instance {
match self { match self {
Self::CreateNew(create_new) => { Self::CreateNew(create_new) => {
#[allow(unused_mut, clippy::allow_attributes)] #[allow(clippy::allow_attributes, unused_mut)]
let mut backends = create_new.instance_descriptor.backends; let mut backends = create_new.instance_descriptor.backends;
// Don't try WebGPU if we're not in a secure context. // Don't try WebGPU if we're not in a secure context.

View File

@@ -1,6 +1,7 @@
#![expect(clippy::missing_errors_doc)] #![expect(clippy::missing_errors_doc)]
#![expect(clippy::undocumented_unsafe_blocks)] #![expect(clippy::undocumented_unsafe_blocks)]
#![expect(clippy::unwrap_used)] // TODO(emilk): avoid unwraps #![expect(clippy::unwrap_used)] // TODO(emilk): avoid unwraps
#![expect(unsafe_code)]
use crate::{RenderState, SurfaceErrorAction, WgpuConfiguration, renderer}; use crate::{RenderState, SurfaceErrorAction, WgpuConfiguration, renderer};
use crate::{ use crate::{

View File

@@ -175,7 +175,7 @@ fn init_arboard() -> Option<arboard::Clipboard> {
fn init_smithay_clipboard( fn init_smithay_clipboard(
raw_display_handle: Option<RawDisplayHandle>, raw_display_handle: Option<RawDisplayHandle>,
) -> Option<smithay_clipboard::Clipboard> { ) -> Option<smithay_clipboard::Clipboard> {
#![allow(clippy::undocumented_unsafe_blocks)] #![expect(clippy::undocumented_unsafe_blocks)]
profiling::function_scope!(); profiling::function_scope!();

View File

@@ -7,7 +7,7 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//! //!
#![allow(clippy::manual_range_contains)] #![expect(clippy::manual_range_contains)]
#[cfg(feature = "accesskit")] #[cfg(feature = "accesskit")]
pub use accesskit_winit; pub use accesskit_winit;

View File

@@ -25,7 +25,7 @@ mod ios {
let app = UIApplication::sharedApplication(main_thread_marker); let app = UIApplication::sharedApplication(main_thread_marker);
#[allow(unsafe_code)] #[expect(unsafe_code)]
unsafe { unsafe {
// Look for the first window scene that's in the foreground // Look for the first window scene that's in the foreground
for scene in app.connectedScenes() { for scene in app.connectedScenes() {

View File

@@ -198,8 +198,7 @@ macro_rules! all_the_atoms {
$($T: IntoAtoms<'a>),* $($T: IntoAtoms<'a>),*
{ {
fn collect(self, _atoms: &mut Atoms<'a>) { fn collect(self, _atoms: &mut Atoms<'a>) {
#[allow(clippy::allow_attributes)] #[allow(clippy::allow_attributes, non_snake_case)]
#[allow(non_snake_case)]
let ($($T),*) = self; let ($($T),*) = self;
$($T.collect(_atoms);)* $($T.collect(_atoms);)*
} }

View File

@@ -1,5 +1,5 @@
//! Old and deprecated API for popups. Use [`Popup`] instead. //! Old and deprecated API for popups. Use [`Popup`] instead.
#![allow(deprecated)] #![expect(deprecated)]
use crate::containers::tooltip::Tooltip; use crate::containers::tooltip::Tooltip;
use crate::{ use crate::{

View File

@@ -1,6 +1,6 @@
//! See [`ScrollArea`] for docs. //! See [`ScrollArea`] for docs.
#![allow(clippy::needless_range_loop)] #![expect(clippy::needless_range_loop)]
use std::ops::{Add, AddAssign, BitOr, BitOrAssign}; use std::ops::{Add, AddAssign, BitOr, BitOrAssign};

View File

@@ -1254,7 +1254,7 @@ impl Context {
self.check_for_id_clash(w.id, w.rect, "widget"); self.check_for_id_clash(w.id, w.rect, "widget");
} }
#[allow(clippy::let_and_return, clippy::allow_attributes)] #[allow(clippy::allow_attributes, clippy::let_and_return)]
let res = self.get_response(w); let res = self.get_response(w);
#[cfg(debug_assertions)] #[cfg(debug_assertions)]

View File

@@ -201,7 +201,7 @@ fn contains_circle(interact_rect: emath::Rect, pos: Pos2, radius: f32) -> bool {
} }
fn hit_test_on_close(close: &[WidgetRect], pos: Pos2) -> WidgetHits { fn hit_test_on_close(close: &[WidgetRect], pos: Pos2) -> WidgetHits {
#![allow(clippy::collapsible_else_if)] #![expect(clippy::collapsible_else_if)]
// First find the best direct hits: // First find the best direct hits:
let hit_click = find_closest_within( let hit_click = find_closest_within(

View File

@@ -385,8 +385,8 @@
//! egui apps can run significantly (~20%) faster by using a custom allocator, like [mimalloc](https://crates.io/crates/mimalloc) or [talc](https://crates.io/crates/talc). //! egui apps can run significantly (~20%) faster by using a custom allocator, like [mimalloc](https://crates.io/crates/mimalloc) or [talc](https://crates.io/crates/talc).
//! //!
#![allow(clippy::float_cmp)] #![expect(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)] #![expect(clippy::manual_range_contains)]
mod animation_manager; mod animation_manager;
mod atomics; mod atomics;

View File

@@ -39,7 +39,7 @@ impl Theme {
/// This is not the best design as it doesn't allow switching back to "follow system". /// This is not the best design as it doesn't allow switching back to "follow system".
#[must_use] #[must_use]
pub(crate) fn small_toggle_button(self, ui: &mut crate::Ui) -> Option<Self> { pub(crate) fn small_toggle_button(self, ui: &mut crate::Ui) -> Option<Self> {
#![allow(clippy::collapsible_else_if)] #![expect(clippy::collapsible_else_if)]
if self == Self::Dark { if self == Self::Dark {
if ui if ui
.add(Button::new("").frame(false)) .add(Button::new("").frame(false))

View File

@@ -1,4 +1,4 @@
#![allow(deprecated)] #![expect(deprecated)]
//! Deprecated menu API - Use [`crate::containers::menu`] instead. //! Deprecated menu API - Use [`crate::containers::menu`] instead.
//! //!
//! Usage: //! Usage:

View File

@@ -1,7 +1,5 @@
//! egui theme (spacing, colors, etc). //! egui theme (spacing, colors, etc).
#![allow(clippy::if_same_then_else)]
use emath::Align; use emath::Align;
use epaint::{AlphaFromCoverage, CornerRadius, Shadow, Stroke, TextOptions, text::FontTweak}; use epaint::{AlphaFromCoverage, CornerRadius, Shadow, Stroke, TextOptions, text::FontTweak};
use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc}; use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc};

View File

@@ -1,5 +1,5 @@
#![warn(missing_docs)] // Let's keep `Ui` well-documented. #![warn(missing_docs)] // Let's keep `Ui` well-documented.
#![allow(clippy::use_self)] #![expect(clippy::use_self)]
use std::{any::Any, hash::Hash, ops::Deref, sync::Arc}; use std::{any::Any, hash::Hash, ops::Deref, sync::Arc};

View File

@@ -484,7 +484,7 @@ impl IdTypeMap {
/// For tests /// For tests
#[cfg(feature = "persistence")] #[cfg(feature = "persistence")]
#[allow(unused, clippy::allow_attributes)] #[allow(clippy::allow_attributes, unused)]
fn get_generation<T: SerializableAny>(&self, id: Id) -> Option<usize> { fn get_generation<T: SerializableAny>(&self, id: Id) -> Option<usize> {
let element = self.map.get(&hash(TypeId::of::<T>(), id))?; let element = self.map.get(&hash(TypeId::of::<T>(), id))?;
match element { match element {
@@ -724,7 +724,7 @@ fn test_two_id_two_type() {
#[test] #[test]
fn test_two_id_x_two_types() { fn test_two_id_x_two_types() {
#![allow(clippy::approx_constant)] #![expect(clippy::approx_constant)]
let a = Id::new("a"); let a = Id::new("a");
let b = Id::new("b"); let b = Id::new("b");

View File

@@ -114,7 +114,7 @@ fn color_button(ui: &mut Ui, color: Color32, open: bool) -> Response {
} }
fn color_slider_1d(ui: &mut Ui, value: &mut f32, color_at: impl Fn(f32) -> Color32) -> Response { fn color_slider_1d(ui: &mut Ui, value: &mut f32, color_at: impl Fn(f32) -> Color32) -> Response {
#![allow(clippy::identity_op)] #![expect(clippy::identity_op)]
let desired_size = vec2(ui.spacing().slider_width, ui.spacing().interact_size.y); let desired_size = vec2(ui.spacing().slider_width, ui.spacing().interact_size.y);
let (rect, response) = ui.allocate_at_least(desired_size, Sense::click_and_drag()); let (rect, response) = ui.allocate_at_least(desired_size, Sense::click_and_drag());

View File

@@ -1,4 +1,4 @@
#![allow(clippy::needless_pass_by_value)] // False positives with `impl ToString` #![expect(clippy::needless_pass_by_value)] // False positives with `impl ToString`
use std::{cmp::Ordering, ops::RangeInclusive}; use std::{cmp::Ordering, ops::RangeInclusive};

View File

@@ -1,4 +1,4 @@
#![allow(clippy::needless_pass_by_value)] // False positives with `impl ToString` #![expect(clippy::needless_pass_by_value)] // False positives with `impl ToString`
use std::ops::RangeInclusive; use std::ops::RangeInclusive;

View File

@@ -1,4 +1,4 @@
#![allow(clippy::undocumented_unsafe_blocks)] #![expect(clippy::undocumented_unsafe_blocks)]
use std::sync::Arc; use std::sync::Arc;

View File

@@ -1,8 +1,8 @@
//! Demo app for egui //! Demo app for egui
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
#![allow(clippy::never_loop)] // False positive #![allow(clippy::allow_attributes, clippy::never_loop)]
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; // Much faster allocator, can give 20% speedups: https://github.com/emilk/egui/pull/7029 static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; // Much faster allocator, can give 20% speedups: https://github.com/emilk/egui/pull/7029

View File

@@ -1,5 +1,3 @@
#![allow(clippy::mem_forget)] // False positives from #[wasm_bindgen] macro
use eframe::wasm_bindgen::{self, prelude::*}; use eframe::wasm_bindgen::{self, prelude::*};
use crate::WrapApp; use crate::WrapApp;
@@ -14,7 +12,7 @@ pub struct WebHandle {
#[wasm_bindgen] #[wasm_bindgen]
impl WebHandle { impl WebHandle {
/// Installs a panic hook, then returns. /// Installs a panic hook, then returns.
#[allow(clippy::new_without_default, clippy::allow_attributes)] #[allow(clippy::allow_attributes, clippy::new_without_default)]
#[wasm_bindgen(constructor)] #[wasm_bindgen(constructor)]
pub fn new() -> Self { pub fn new() -> Self {
// Redirect [`log`] message to `console.log` and friends: // Redirect [`log`] message to `console.log` and friends:

View File

@@ -183,7 +183,7 @@ impl WrapApp {
cc.egui_ctx cc.egui_ctx
.add_plugin(crate::accessibility_inspector::AccessibilityInspectorPlugin::default()); .add_plugin(crate::accessibility_inspector::AccessibilityInspectorPlugin::default());
#[allow(unused_mut, clippy::allow_attributes)] #[allow(clippy::allow_attributes, unused_mut)]
let mut slf = Self { let mut slf = Self {
state: State::default(), state: State::default(),

View File

@@ -48,7 +48,7 @@ impl Default for WidgetGallery {
} }
impl WidgetGallery { impl WidgetGallery {
#[allow(unused_mut, clippy::allow_attributes)] // if not chrono #[allow(clippy::allow_attributes, unused_mut)] // if not chrono
#[inline] #[inline]
pub fn with_date_button(mut self, _with_date_button: bool) -> Self { pub fn with_date_button(mut self, _with_date_button: bool) -> Self {
#[cfg(feature = "chrono")] #[cfg(feature = "chrono")]

View File

@@ -6,8 +6,7 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//! //!
#![allow(clippy::float_cmp)] #![expect(clippy::manual_range_contains)]
#![allow(clippy::manual_range_contains)]
#[cfg(feature = "chrono")] #[cfg(feature = "chrono")]
mod datepicker; mod datepicker;

View File

@@ -36,7 +36,7 @@ fn is_supported(uri: &str) -> bool {
impl Default for SvgLoader { impl Default for SvgLoader {
fn default() -> Self { fn default() -> Self {
// opt is mutated when `svg_text` feature flag is enabled // opt is mutated when `svg_text` feature flag is enabled
#[allow(unused_mut, clippy::allow_attributes)] #[allow(clippy::allow_attributes, unused_mut)]
let mut options = resvg::usvg::Options::default(); let mut options = resvg::usvg::Options::default();
#[cfg(feature = "svg_text")] #[cfg(feature = "svg_text")]

View File

@@ -3,8 +3,6 @@
//! Turn on the `syntect` feature for great syntax highlighting of any language. //! Turn on the `syntect` feature for great syntax highlighting of any language.
//! Otherwise, a very simple fallback will be used, that works okish for C, C++, Rust, and Python. //! Otherwise, a very simple fallback will be used, that works okish for C, C++, Rust, and Python.
#![allow(clippy::mem_forget)] // False positive from enum_map macro
use egui::TextStyle; use egui::TextStyle;
use egui::text::LayoutJob; use egui::text::LayoutJob;
@@ -272,7 +270,7 @@ impl CodeTheme {
/// ///
/// There is one dark and one light theme stored at any one time. /// There is one dark and one light theme stored at any one time.
pub fn from_memory(ctx: &egui::Context, style: &egui::Style) -> Self { pub fn from_memory(ctx: &egui::Context, style: &egui::Style) -> Self {
#![allow(clippy::needless_return)] #![expect(clippy::needless_return)]
let (id, default) = if style.visuals.dark_mode { let (id, default) = if style.visuals.dark_mode {
(egui::Id::new("dark"), Self::dark as fn(f32) -> Self) (egui::Id::new("dark"), Self::dark as fn(f32) -> Self)
@@ -361,6 +359,7 @@ impl CodeTheme {
// function, but at the cost of more code duplication. // function, but at the cost of more code duplication.
#[expect(clippy::needless_pass_by_value)] #[expect(clippy::needless_pass_by_value)]
fn dark_with_font_id(font_id: egui::FontId) -> Self { fn dark_with_font_id(font_id: egui::FontId) -> Self {
#![expect(clippy::mem_forget)]
use egui::{Color32, TextFormat}; use egui::{Color32, TextFormat};
Self { Self {
dark_mode: true, dark_mode: true,
@@ -378,6 +377,7 @@ impl CodeTheme {
// The syntect version takes it by value // The syntect version takes it by value
#[expect(clippy::needless_pass_by_value)] #[expect(clippy::needless_pass_by_value)]
fn light_with_font_id(font_id: egui::FontId) -> Self { fn light_with_font_id(font_id: egui::FontId) -> Self {
#![expect(clippy::mem_forget)]
use egui::{Color32, TextFormat}; use egui::{Color32, TextFormat};
Self { Self {
dark_mode: false, dark_mode: false,

View File

@@ -656,7 +656,7 @@ impl TableState {
} }
fn store(self, ui: &egui::Ui, state_id: egui::Id) { fn store(self, ui: &egui::Ui, state_id: egui::Id) {
#![allow(clippy::needless_return)] #![expect(clippy::needless_return)]
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
{ {
return ui.data_mut(|d| d.insert_persisted(state_id, self)); return ui.data_mut(|d| d.insert_persisted(state_id, self));

View File

@@ -8,9 +8,7 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//! //!
#![allow(clippy::float_cmp)] #![expect(clippy::undocumented_unsafe_blocks)]
#![allow(clippy::manual_range_contains)]
#![allow(clippy::undocumented_unsafe_blocks)]
pub mod painter; pub mod painter;
pub use glow; pub use glow;

View File

@@ -1,4 +1,4 @@
#![allow(unsafe_code)] #![expect(unsafe_code)]
use glow::HasContext as _; use glow::HasContext as _;

View File

@@ -1,6 +1,5 @@
#![allow(clippy::collapsible_else_if)] #![expect(clippy::unwrap_used)]
#![allow(clippy::unwrap_used)] #![expect(unsafe_code)]
#![allow(unsafe_code)]
use std::{collections::HashMap, sync::Arc}; use std::{collections::HashMap, sync::Arc};

View File

@@ -19,7 +19,7 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//! //!
#![allow(clippy::float_cmp)] #![expect(clippy::float_cmp)]
use std::ops::{Add, Div, Mul, RangeInclusive, Sub}; use std::ops::{Add, Div, Mul, RangeInclusive, Sub};

View File

@@ -23,7 +23,7 @@ macro_rules! impl_numeric_float {
#[inline(always)] #[inline(always)]
fn to_f64(self) -> f64 { fn to_f64(self) -> f64 {
#[allow(trivial_numeric_casts, clippy::allow_attributes)] #[allow(clippy::allow_attributes, trivial_numeric_casts)]
{ {
self as f64 self as f64
} }
@@ -31,7 +31,7 @@ macro_rules! impl_numeric_float {
#[inline(always)] #[inline(always)]
fn from_f64(num: f64) -> Self { fn from_f64(num: f64) -> Self {
#[allow(trivial_numeric_casts, clippy::allow_attributes)] #[allow(clippy::allow_attributes, trivial_numeric_casts)]
{ {
num as Self num as Self
} }

View File

@@ -20,8 +20,8 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//! //!
#![allow(clippy::float_cmp)] #![expect(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)] #![expect(clippy::manual_range_contains)]
mod brush; mod brush;
pub mod color; pub mod color;

View File

@@ -186,7 +186,7 @@ impl std::ops::Div<f32> for Margin {
#[inline] #[inline]
fn div(self, v: f32) -> Self { fn div(self, v: f32) -> Self {
#![allow(clippy::suspicious_arithmetic_impl)] #![expect(clippy::suspicious_arithmetic_impl)]
self * v.recip() self * v.recip()
} }
} }

View File

@@ -189,7 +189,7 @@ impl Mesh {
/// Rectangle with a texture and color. /// Rectangle with a texture and color.
#[inline(always)] #[inline(always)]
pub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32) { pub fn add_rect_with_uv(&mut self, rect: Rect, uv: Rect, color: Color32) {
#![allow(clippy::identity_op)] #![expect(clippy::identity_op)]
let idx = self.vertices.len() as u32; let idx = self.vertices.len() as u32;
self.indices self.indices
.extend_from_slice(&[idx + 0, idx + 1, idx + 2, idx + 2, idx + 1, idx + 3]); .extend_from_slice(&[idx + 0, idx + 1, idx + 2, idx + 2, idx + 1, idx + 3]);

View File

@@ -125,7 +125,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::disallowed_methods)] // Ok for tests #![expect(clippy::disallowed_methods)] // Ok for tests
use crate::mutex::Mutex; use crate::mutex::Mutex;
use std::time::Duration; use std::time::Duration;
@@ -158,7 +158,7 @@ mod tests {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
#[cfg(test)] #[cfg(test)]
mod tests_rwlock { mod tests_rwlock {
#![allow(clippy::disallowed_methods)] // Ok for tests #![expect(clippy::disallowed_methods)] // Ok for tests
use crate::mutex::RwLock; use crate::mutex::RwLock;
use std::time::Duration; use std::time::Duration;

View File

@@ -10,7 +10,7 @@ pub fn adjust_colors(
shape: &mut Shape, shape: &mut Shape,
adjust_color: impl Fn(&mut Color32) + Send + Sync + Copy + 'static, adjust_color: impl Fn(&mut Color32) + Send + Sync + Copy + 'static,
) { ) {
#![allow(clippy::match_same_arms)] #![expect(clippy::match_same_arms)]
match shape { match shape {
Shape::Noop => {} Shape::Noop => {}

View File

@@ -1,5 +1,4 @@
#![allow(clippy::many_single_char_names)] #![expect(clippy::many_single_char_names)]
#![allow(clippy::wrong_self_convention)] // False positives
use std::ops::Range; use std::ops::Range;

View File

@@ -1,5 +1,3 @@
#![allow(clippy::derived_hash_with_manual_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
use std::{fmt::Debug, sync::Arc}; use std::{fmt::Debug, sync::Arc};
use emath::GuiRounding as _; use emath::GuiRounding as _;

View File

@@ -3,7 +3,7 @@
//! This module converts lines, circles, text and more represented by [`Shape`] //! This module converts lines, circles, text and more represented by [`Shape`]
//! into textured triangles represented by [`Mesh`]. //! into textured triangles represented by [`Mesh`].
#![allow(clippy::identity_op)] #![expect(clippy::identity_op)]
use emath::{GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2, pos2, remap, vec2}; use emath::{GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2, pos2, remap, vec2};
@@ -2207,7 +2207,7 @@ impl Tessellator {
/// ///
/// ## Returns /// ## Returns
/// A list of clip rectangles with matching [`Mesh`]. /// A list of clip rectangles with matching [`Mesh`].
#[allow(unused_mut, clippy::allow_attributes)] #[allow(clippy::allow_attributes, unused_mut)]
pub fn tessellate_shapes(&mut self, mut shapes: Vec<ClippedShape>) -> Vec<ClippedPrimitive> { pub fn tessellate_shapes(&mut self, mut shapes: Vec<ClippedShape>) -> Vec<ClippedPrimitive> {
profiling::function_scope!(); profiling::function_scope!();

View File

@@ -1,4 +1,4 @@
#![allow(clippy::mem_forget)] #![expect(clippy::mem_forget)]
use emath::{GuiRounding as _, OrderedFloat, Vec2, vec2}; use emath::{GuiRounding as _, OrderedFloat, Vec2, vec2};
use self_cell::self_cell; use self_cell::self_cell;

View File

@@ -1,6 +1,3 @@
#![allow(clippy::derived_hash_with_manual_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
#![allow(clippy::wrong_self_convention)] // We use `from_` to indicate conversion direction. It's non-diomatic, but makes sense in this context.
use std::ops::Range; use std::ops::Range;
use std::sync::Arc; use std::sync::Arc;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;

View File

@@ -1,7 +1,7 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
#![allow(unsafe_code)] #![expect(unsafe_code)]
#![allow(clippy::undocumented_unsafe_blocks)] #![expect(clippy::undocumented_unsafe_blocks)]
use eframe::{egui, egui_glow, glow}; use eframe::{egui, egui_glow, glow};

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::{ use eframe::{
egui, egui,

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;
use egui::{FontFamily, FontId, RichText, TextStyle}; use egui::{FontFamily, FontId, RichText, TextStyle};

View File

@@ -1,5 +1,5 @@
// #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release // #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;
mod keypad; mod keypad;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui::{ use eframe::egui::{
self, Color32, Stroke, Style, Theme, global_theme_preference_buttons, style::Selection, self, Color32, Stroke, Style, Theme, global_theme_preference_buttons, style::Selection,

View File

@@ -1,4 +1,4 @@
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
mod app; mod app;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;
use egui::{Key, ScrollArea}; use egui::{Key, ScrollArea};

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::{ use std::sync::{
Arc, Arc,

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui::{CentralPanel, ComboBox, Popup, PopupCloseBehavior}; use eframe::egui::{CentralPanel, ComboBox, Popup, PopupCloseBehavior};

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::{ use std::sync::{
Arc, Arc,

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui; use eframe::egui;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::{CreationContext, NativeOptions, egui}; use eframe::{CreationContext, NativeOptions, egui};
use egui::{Button, CentralPanel, UserAttentionType}; use egui::{Button, CentralPanel, UserAttentionType};

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's a test #![expect(rustdoc::missing_crate_level_docs)] // it's a test
use eframe::egui; use eframe::egui;

View File

@@ -1,5 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example #![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::Arc; use std::sync::Arc;

View File

@@ -1,7 +1,6 @@
//! Helper crate for running scripts within the `egui` repo //! Helper crate for running scripts within the `egui` repo
#![allow(clippy::print_stdout)] #![expect(clippy::print_stderr, clippy::print_stdout)]
#![allow(clippy::print_stderr)]
#![allow(clippy::exit)] #![allow(clippy::exit)]
mod deny; mod deny;