From d494c5a1ea641fb0be1fa6c82f9277a7b105ecbf Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Tue, 2 Dec 2025 19:54:11 +0100 Subject: [PATCH] remove more unused dependencies, add cargo-machete --- .github/workflows/ci.yml | 35 ++++++++++++++++------------------- Cargo.lock | 33 ++------------------------------- Cargo.toml | 7 +++---- build.rs | 19 ------------------- justfiles/testing.just | 14 +++++++++++++- src/lib.rs | 7 ------- 6 files changed, 34 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 020764c2c..153e1eb7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,9 @@ jobs: steps: - uses: actions/checkout@v6 - - name: install `just` - run: sudo snap install --edge --classic just - - - uses: cargo-bins/cargo-binstall@main + - uses: taiki-e/install-action@v2 + with: + tool: just,sqlx-cli - name: restore build & cargo cache uses: Swatinem/rust-cache@v2 @@ -33,9 +32,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: install SQLX CLI - run: cargo binstall sqlx-cli - - name: run sqlx migration up & down run: | just sqlx-migrate-run \ @@ -51,8 +47,9 @@ jobs: steps: - uses: actions/checkout@v6 - - name: install `just` - run: sudo snap install --edge --classic just + - uses: taiki-e/install-action@v2 + with: + tool: just - name: restore build & cargo cache uses: Swatinem/rust-cache@v2 @@ -77,8 +74,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: install `just` - run: sudo snap install --edge --classic just + - uses: taiki-e/install-action@v2 + with: + tool: just - name: Run GUI tests run: just run-gui-tests @@ -94,18 +92,16 @@ jobs: steps: - uses: actions/checkout@v6 - - name: install `just` - run: sudo snap install --edge --classic just + - uses: taiki-e/install-action@v2 + with: + tool: just,fd-find,cargo-machete - name: restore build & cargo cache uses: Swatinem/rust-cache@v2 with: prefix-key: ${{ env.RUST_CACHE_KEY }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - run: just lint + - run: just lint lint-dependencies lint-js: name: js linters @@ -115,8 +111,9 @@ jobs: - uses: denoland/setup-deno@v2 - - name: install `just` - run: sudo snap install --edge --classic just + - uses: taiki-e/install-action@v2 + with: + tool: just - run: just lint-js diff --git a/Cargo.lock b/Cargo.lock index e134bc516..59a57c71e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2009,8 +2009,6 @@ dependencies = [ "serde_with", "slug", "sqlx", - "string_cache 0.9.0", - "string_cache_codegen 0.6.1", "strum", "syntect", "sysinfo", @@ -2028,7 +2026,6 @@ dependencies = [ "tracing-log", "tracing-subscriber", "url", - "uuid", "walkdir", "zip", "zstd", @@ -4857,8 +4854,8 @@ dependencies = [ "log", "phf 0.10.1", "phf_codegen 0.10.0", - "string_cache 0.8.9", - "string_cache_codegen 0.5.4", + "string_cache", + "string_cache_codegen", "tendril", ] @@ -7368,19 +7365,6 @@ dependencies = [ "serde", ] -[[package]] -name = "string_cache" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" -dependencies = [ - "new_debug_unreachable", - "parking_lot", - "phf_shared 0.13.1", - "precomputed-hash", - "serde", -] - [[package]] name = "string_cache_codegen" version = "0.5.4" @@ -7393,18 +7377,6 @@ dependencies = [ "quote", ] -[[package]] -name = "string_cache_codegen" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69" -dependencies = [ - "phf_generator 0.13.1", - "phf_shared 0.13.1", - "proc-macro2", - "quote", -] - [[package]] name = "stringprep" version = "0.1.5" @@ -8249,7 +8221,6 @@ version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ - "getrandom 0.3.4", "js-sys", "serde", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index f9d6c6600..21cda216c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,6 @@ strum = { version = "0.27.0", features = ["derive"] } lol_html = "2.0.0" font-awesome-as-a-crate = { path = "crates/font-awesome-as-a-crate" } dashmap = "6.0.0" -string_cache = "0.9.0" zip = {version = "6.0.0", default-features = false, features = ["bzip2"]} bzip2 = "0.6.0" getrandom = "0.3.1" @@ -75,8 +74,6 @@ aws-config = { version = "1.0.0", default-features = false, features = ["rt-toki aws-sdk-s3 = "1.3.0" aws-smithy-types-convert = { version = "0.60.0", features = ["convert-chrono"] } http = "1.0.0" -uuid = { version = "1.1.2", features = ["v4"]} - # Data serialization and deserialization serde = { version = "1.0", features = ["derive"] } @@ -125,13 +122,15 @@ pretty_assertions = "1.4.0" [build-dependencies] time = "0.3" md5 = "0.8.0" -string_cache_codegen = "0.6.1" phf_codegen = "0.13" walkdir = "2" anyhow = { version = "1.0.42", features = ["backtrace"] } grass = { version = "0.13.1", default-features = false } syntect = { version = "5.0.0", default-features = false, features = ["parsing", "dump-create", "yaml-load", "regex-onig"] } +[package.metadata.cargo-machete] +ignored = ["phf"] + [[bench]] name = "compression" harness = false diff --git a/build.rs b/build.rs index 63c781fd0..beabb7ea4 100644 --- a/build.rs +++ b/build.rs @@ -78,7 +78,6 @@ fn main() -> Result<()> { let mut etag_map: ETagMap = ETagMap::new(); compile_sass(out_dir, &mut etag_map)?; - write_known_targets(out_dir)?; compile_syntax(out_dir).context("could not compile syntax files")?; calculate_static_etags(&mut etag_map)?; @@ -226,24 +225,6 @@ fn calculate_static_etags(etag_map: &mut ETagMap) -> Result<()> { Ok(()) } -fn write_known_targets(out_dir: &Path) -> Result<()> { - use std::io::BufRead; - - let targets: Vec = std::process::Command::new("rustc") - .args(["--print", "target-list"]) - .output()? - .stdout - .lines() - .filter(|s| s.as_ref().map_or(true, |s| !s.is_empty())) - .collect::>()?; - - string_cache_codegen::AtomType::new("target::TargetAtom", "target_atom!") - .atoms(&targets) - .write_to_file(&out_dir.join("target_atom.rs"))?; - - Ok(()) -} - fn compile_syntax(out_dir: &Path) -> Result<()> { use syntect::{ dumps::dump_to_uncompressed_file, diff --git a/justfiles/testing.just b/justfiles/testing.just index bca7e24eb..785f948ec 100644 --- a/justfiles/testing.just +++ b/justfiles/testing.just @@ -54,7 +54,7 @@ clippy-fix: # run all linters, for local development & CI [group('testing')] -lint: format +lint: format lint-dependencies #!/usr/bin/env bash set -euo pipefail @@ -64,6 +64,18 @@ lint: format just clippy-fix fi +[group('testing')] +lint-dependencies: + # check unused deps with cargo machete is fast, + # but has many false positives. + # While it can also recurse into subdirs, it would + # also stumble onto our broken crates in `/tests/crates/*`, + # where I also don't want to add machete-metadata. + @fd \ + --glob 'Cargo.toml' \ + --type file \ + --exclude tests \ + -X cargo machete {} [group('testing')] lint-js *args: diff --git a/src/lib.rs b/src/lib.rs index 2de789a13..09f6873d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,13 +33,6 @@ mod test; pub mod utils; mod web; -#[allow(dead_code)] -mod target { - //! [`crate::target::TargetAtom`] is an interned string type for rustc targets, such as - //! `x86_64-unknown-linux-gnu`. See the [`string_cache`] docs for usage examples. - include!(concat!(env!("OUT_DIR"), "/target_atom.rs")); -} - use web::page::GlobalAlert; // Warning message shown in the navigation bar of every page. Set to `None` to hide it.