From 78fffc7707a287b3da34a4e4eeb74997abb55ec4 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 7 Oct 2025 14:12:51 +0200 Subject: [PATCH] clean up the clippy.toml:s (#7594) --- clippy.toml | 24 +++++++++--------------- scripts/clippy_wasm/clippy.toml | 9 ++++----- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/clippy.toml b/clippy.toml index 1b39bdae..839586db 100644 --- a/clippy.toml +++ b/clippy.toml @@ -35,17 +35,13 @@ disallowed-macros = [ # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods disallowed-methods = [ - "std::env::temp_dir", # Use the tempdir crate instead - - # There are many things that aren't allowed on wasm, + # NOTE: There are many things that aren't allowed on wasm, # but we cannot disable them all here (because of e.g. https://github.com/rust-lang/rust-clippy/issues/10406) # so we do that in `clipppy_wasm.toml` instead. - "std::thread::spawn", # Use `std::thread::Builder` and name the thread - - "sha1::Digest::new", # SHA1 is cryptographically broken - - "std::panic::catch_unwind", # We compile with `panic = "abort"` + { path = "std::env::temp_dir", readon = "Use the tempdir crate instead" }, + { path = "std::panic::catch_unwind", reason = "We compile with `panic = abort" }, + { path = "std::thread::spawn", readon = "Use `std::thread::Builder` and name the thread" }, ] # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names @@ -53,14 +49,12 @@ disallowed-names = [] # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types disallowed-types = [ - # Use the faster & simpler non-poisonable primitives in `parking_lot` instead - "std::sync::Mutex", - "std::sync::RwLock", - "std::sync::Condvar", + { path = "std::sync::Condvar", reason = "Use parking_lot instead" }, + { path = "std::sync::Mutex", reason = "Use epaint::mutex instead" }, + { path = "std::sync::RwLock", reason = "Use epaint::mutex instead" }, + { path = "winit::dpi::LogicalPosition", reason = "We do our own pixels<->point conversion, taking `egui_ctx.zoom_factor` into account" }, + { path = "winit::dpi::LogicalSize", reason = "We do our own pixels<->point conversion, taking `egui_ctx.zoom_factor` into account" }, # "std::sync::Once", # enabled for now as the `log_once` macro uses it internally - - "winit::dpi::LogicalSize", # We do our own pixels<->point conversion, taking `egui_ctx.zoom_factor` into account - "winit::dpi::LogicalPosition", # We do our own pixels<->point conversion, taking `egui_ctx.zoom_factor` into account ] # ----------------------------------------------------------------------------- diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index c138ea5b..d2b8365d 100644 --- a/scripts/clippy_wasm/clippy.toml +++ b/scripts/clippy_wasm/clippy.toml @@ -26,12 +26,11 @@ type-complexity-threshold = 350 # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods disallowed-methods = [ - "std::time::Instant::now", # use `instant` crate instead for wasm/web compatibility - "std::time::Duration::elapsed", # use `instant` crate instead for wasm/web compatibility - "std::time::SystemTime::now", # use `instant` or `time` crates instead for wasm/web compatibility + { path = "std::time::Instant::elapsed", reason = "use `instant` crate instead for wasm/web compatibility" }, + { path = "std::time::Instant::now", reason = "use `instant` crate instead for wasm/web compatibility" }, + { path = "std::time::SystemTime::now", reason = "use `instant` or `time` crates instead for wasm/web compatibility" }, - # Cannot spawn threads on wasm: - "std::thread::spawn", + { path = "std::thread::spawn", reason = "Cannot spawn threads on wasm" }, ] # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types