From db87c712a1c02e6f1577c682b4f90fb926482364 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 13 Apr 2026 17:48:43 +0200 Subject: [PATCH] Replace `cargo machete` with `cargo shear` (#8094) We've had good experiences with `cargo shear` at Rerun --- .github/workflows/cargo_machete.yml | 19 -------------- .github/workflows/cargo_shear.yml | 25 +++++++++++++++++++ Cargo.lock | 2 -- crates/egui-winit/Cargo.toml | 3 +++ crates/egui_demo_app/Cargo.toml | 4 +-- crates/egui_demo_lib/Cargo.toml | 3 +++ crates/egui_glow/Cargo.toml | 4 --- examples/custom_style/Cargo.toml | 4 +-- examples/hello_world_par/Cargo.toml | 2 +- examples/images/Cargo.toml | 2 +- examples/puffin_profiler/Cargo.toml | 2 +- tests/egui_tests/Cargo.toml | 3 +++ tests/test_egui_extras_compilation/Cargo.toml | 2 +- 13 files changed, 42 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/cargo_machete.yml create mode 100644 .github/workflows/cargo_shear.yml diff --git a/.github/workflows/cargo_machete.yml b/.github/workflows/cargo_machete.yml deleted file mode 100644 index 1dc162e56..000000000 --- a/.github/workflows/cargo_machete.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Cargo Machete - -on: [push, pull_request] - -jobs: - cargo-machete: - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: 1.92 - - name: Machete install - ## The official cargo-machete action - uses: bnjbvr/cargo-machete@v0.9.1 - - name: Checkout - uses: actions/checkout@v4 - - name: Machete Check - run: cargo machete diff --git a/.github/workflows/cargo_shear.yml b/.github/workflows/cargo_shear.yml new file mode 100644 index 000000000..734abacb5 --- /dev/null +++ b/.github/workflows/cargo_shear.yml @@ -0,0 +1,25 @@ +# Looks for unused crates. +name: Cargo Shear + +on: + push: + branches: + - "main" + pull_request: + types: [opened, synchronize] + +jobs: + cargo-shear: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Cargo Shear + uses: taiki-e/install-action@v2.48.7 + with: + tool: cargo-shear@1.11.2 + + - name: Run Cargo Shear + run: | + cargo shear diff --git a/Cargo.lock b/Cargo.lock index 6efed68d0..caac14876 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1375,8 +1375,6 @@ dependencies = [ "log", "memoffset", "profiling", - "wasm-bindgen", - "web-sys", "winit", ] diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index dd4aa8f9d..7fea2341b 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -20,6 +20,9 @@ workspace = true all-features = true rustdoc-args = ["--generate-link-to-definition"] +[package.metadata.cargo-shear] +ignored = ["wayland-cursor"] # TODO(emilk): remove when we update winit + [features] default = ["clipboard", "links", "wayland", "winit/default", "x11"] diff --git a/crates/egui_demo_app/Cargo.toml b/crates/egui_demo_app/Cargo.toml index 5bb093ced..3b4de53e6 100644 --- a/crates/egui_demo_app/Cargo.toml +++ b/crates/egui_demo_app/Cargo.toml @@ -8,8 +8,8 @@ rust-version.workspace = true publish = false default-run = "egui_demo_app" -[package.metadata.cargo-machete] -ignored = ["profiling"] +[package.metadata.cargo-shear] +ignored = ["image", "profiling", "wasm-bindgen-futures"] [lints] workspace = true diff --git a/crates/egui_demo_lib/Cargo.toml b/crates/egui_demo_lib/Cargo.toml index dc57fb092..d2586fa11 100644 --- a/crates/egui_demo_lib/Cargo.toml +++ b/crates/egui_demo_lib/Cargo.toml @@ -20,6 +20,9 @@ workspace = true all-features = true rustdoc-args = ["--generate-link-to-definition"] +[package.metadata.cargo-shear] +ignored = ["image"] # We need the png feature + [lib] diff --git a/crates/egui_glow/Cargo.toml b/crates/egui_glow/Cargo.toml index c5ff714b3..d5a9f3716 100644 --- a/crates/egui_glow/Cargo.toml +++ b/crates/egui_glow/Cargo.toml @@ -66,10 +66,6 @@ document-features = { workspace = true, optional = true } # Native: winit = { workspace = true, optional = true, default-features = false, features = ["rwh_06"] } -# Web: -[target.'cfg(target_arch = "wasm32")'.dependencies] -web-sys = { workspace = true, features = ["console"] } -wasm-bindgen.workspace = true [dev-dependencies] glutin = { workspace = true, default-features = true } # examples/pure_glow diff --git a/examples/custom_style/Cargo.toml b/examples/custom_style/Cargo.toml index 83174df40..3352aa474 100644 --- a/examples/custom_style/Cargo.toml +++ b/examples/custom_style/Cargo.toml @@ -10,8 +10,8 @@ publish = false workspace = true -[package.metadata.cargo-machete] -ignored = ["image"] # We need the .png feature +[package.metadata.cargo-shear] +ignored = ["image"] # We need the png feature [dependencies] diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index ef719b742..04a3c0e25 100644 --- a/examples/hello_world_par/Cargo.toml +++ b/examples/hello_world_par/Cargo.toml @@ -11,7 +11,7 @@ publish = false workspace = true -[package.metadata.cargo-machete] +[package.metadata.cargo-shear] ignored = ["winit"] # Just enable some features of it; see below diff --git a/examples/images/Cargo.toml b/examples/images/Cargo.toml index 7c3b77b7c..adac2a540 100644 --- a/examples/images/Cargo.toml +++ b/examples/images/Cargo.toml @@ -11,7 +11,7 @@ publish = false workspace = true -[package.metadata.cargo-machete] +[package.metadata.cargo-shear] ignored = ["image"] # We only use the dependency to add more features to it diff --git a/examples/puffin_profiler/Cargo.toml b/examples/puffin_profiler/Cargo.toml index 49e6598db..ed8ce3aa0 100644 --- a/examples/puffin_profiler/Cargo.toml +++ b/examples/puffin_profiler/Cargo.toml @@ -7,7 +7,7 @@ edition = "2024" rust-version = "1.92" publish = false -[package.metadata.cargo-machete] +[package.metadata.cargo-shear] ignored = ["profiling"] [lints] diff --git a/tests/egui_tests/Cargo.toml b/tests/egui_tests/Cargo.toml index 8c09042b1..44a7b9c8f 100644 --- a/tests/egui_tests/Cargo.toml +++ b/tests/egui_tests/Cargo.toml @@ -5,6 +5,9 @@ license.workspace = true rust-version.workspace = true version.workspace = true +[package.metadata.cargo-shear] +ignored = ["image"] # We need the png feature + [dev-dependencies] egui = { workspace = true, default-features = true } egui_kittest = { workspace = true, features = ["snapshot", "wgpu"] } diff --git a/tests/test_egui_extras_compilation/Cargo.toml b/tests/test_egui_extras_compilation/Cargo.toml index 3598362a9..3e1d166f7 100644 --- a/tests/test_egui_extras_compilation/Cargo.toml +++ b/tests/test_egui_extras_compilation/Cargo.toml @@ -9,7 +9,7 @@ publish = false [lints] workspace = true -[package.metadata.cargo-machete] +[package.metadata.cargo-shear] ignored = ["eframe", "egui_extras"] # We don't use them, just check that things compile [dependencies]