From 096ed1c0cb2d7d624d35e1947ccd014f448cab87 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 2 Oct 2025 20:19:23 +0200 Subject: [PATCH] Replace cargo check with cargo clippy on ci (#7581) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/rust.yml | 51 ++++++++------------- crates/eframe/src/native/epi_integration.rs | 16 ++++--- crates/egui/src/context.rs | 1 + 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b45f027e..1d4a9555 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -38,39 +38,26 @@ jobs: - name: Lint vertical spacing run: ./scripts/lint.py - - name: check --all-features - run: cargo check --locked --all-features --all-targets + - run: cargo clippy --locked --all-features --all-targets - - name: check egui_extras --all-features - run: cargo check --locked --all-features -p egui_extras + - run: cargo clippy --locked --all-features -p egui_extras - - name: check default features - run: cargo check --locked --all-targets + - run: cargo clippy --locked --all-targets - - name: check --no-default-features - run: cargo check --locked --no-default-features --lib --all-targets + - run: cargo clippy --locked --no-default-features --lib --all-targets - - name: check eframe --no-default-features - run: cargo check --locked --no-default-features --features x11 --lib -p eframe + - run: cargo clippy --locked --no-default-features --features x11 --lib -p eframe - - name: check egui_extras --no-default-features - run: cargo check --locked --no-default-features --lib -p egui_extras + - run: cargo clippy --locked --no-default-features --lib -p egui_extras - - name: check epaint --no-default-features - run: cargo check --locked --no-default-features --lib -p epaint + - run: cargo clippy --locked --no-default-features --lib -p epaint # Regression test for https://github.com/emilk/egui/issues/4771 - - name: cargo check -p test_egui_extras_compilation - run: cargo check -p test_egui_extras_compilation + - run: cargo clippy -p test_egui_extras_compilation - - name: cargo doc --lib - run: cargo doc --lib --no-deps --all-features + - run: cargo doc --lib --no-deps --all-features - - name: cargo doc --document-private-items - run: cargo doc --document-private-items --no-deps --all-features - - - name: clippy - run: cargo clippy --all-targets --all-features -- -D warnings + - run: cargo doc --document-private-items --no-deps --all-features - name: clippy release run: cargo clippy --all-targets --all-features --release -- -D warnings @@ -93,14 +80,14 @@ jobs: - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - - name: Check wasm32 egui_demo_app - run: cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown + - name: clippy wasm32 egui_demo_app + run: cargo clippy -p egui_demo_app --lib --target wasm32-unknown-unknown - - name: Check wasm32 egui_demo_app --all-features - run: cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown --all-features + - name: clippy wasm32 egui_demo_app --all-features + run: cargo clippy -p egui_demo_app --lib --target wasm32-unknown-unknown --all-features - - name: Check wasm32 eframe - run: cargo check -p eframe --lib --no-default-features --features glow,persistence --target wasm32-unknown-unknown + - name: clippy wasm32 eframe + run: cargo clippy -p eframe --lib --no-default-features --features glow,persistence --target wasm32-unknown-unknown - name: wasm-bindgen uses: jetli/wasm-bindgen-action@v0.1.0 @@ -222,11 +209,9 @@ jobs: - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - - name: Check all - run: cargo check --all-targets --all-features + - run: cargo clippy --all-targets --all-features - - name: Check hello_world - run: cargo check -p hello_world + - run: cargo clippy -p hello_world # --------------------------------------------------------------------------- diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 69c42427..1b4c4b66 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -135,7 +135,7 @@ pub fn create_storage(_app_name: &str) -> Option> { None } -#[expect(clippy::unnecessary_wraps)] +#[allow(clippy::allow_attributes, clippy::unnecessary_wraps)] pub fn create_storage_with_file(_file: impl Into) -> Option> { #[cfg(feature = "persistence")] return Some(Box::new( @@ -168,7 +168,7 @@ pub struct EpiIntegration { } impl EpiIntegration { - #[expect(clippy::too_many_arguments)] + #[allow(clippy::allow_attributes, clippy::too_many_arguments)] pub fn new( egui_ctx: egui::Context, window: &winit::window::Window, @@ -325,13 +325,15 @@ impl EpiIntegration { } } - #[allow(clippy::unused_self, clippy::allow_attributes)] - pub fn save(&mut self, _app: &mut dyn epi::App, _window: Option<&winit::window::Window>) { + pub fn save(&mut self, app: &mut dyn epi::App, window: Option<&winit::window::Window>) { + #[cfg(not(feature = "persistence"))] + let _ = (self, app, window); + #[cfg(feature = "persistence")] if let Some(storage) = self.frame.storage_mut() { profiling::function_scope!(); - if let Some(window) = _window + if let Some(window) = window && self.persist_window { profiling::scope!("native_window"); @@ -341,14 +343,14 @@ impl EpiIntegration { &WindowSettings::from_window(self.egui_ctx.zoom_factor(), window), ); } - if _app.persist_egui_memory() { + if app.persist_egui_memory() { profiling::scope!("egui_memory"); self.egui_ctx .memory(|mem| epi::set_value(storage, STORAGE_EGUI_MEMORY_KEY, mem)); } { profiling::scope!("App::save"); - _app.save(storage); + app.save(storage); } profiling::scope!("Storage::flush"); diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index b037ce7d..03b46b65 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -2497,6 +2497,7 @@ impl ContextImpl { if self.memory.options.repaint_on_widget_change { profiling::scope!("compare-widget-rects"); + #[allow(clippy::allow_attributes, clippy::collapsible_if)] // false positive on wasm if viewport.prev_pass.widgets != viewport.this_pass.widgets { repaint_needed = true; // Some widget has moved }