chore: silence clippy 1.94 errors so CI -D warnings stays green #105
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/clippy-1.94-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes the gap that made the CI clippy step red while local
just checkpassed green: CI runs clippy on Rust 1.94 with-D warnings; the local./dev/cargowrapper is still pinned torust:1.88-slim-bookwormand the justfile clippy recipes do not pass-- -D warnings. Rust 1.94's clippy ships lints that did not exist in 1.88 (manual_repeat_n, refreshedshould_implement_traitmatching, etc.) and the strict-flags difference promotes the rest of the existing warnings to errors. This PR fixes the source side; a follow-up will sync the local image + recipes so the next drift surfaces locally before push.What changed
Library
bg.rs,views/room.rs:std::iter::repeat("?").take(n)->std::iter::repeat_n("?", n).views/room.rs::excerpt_for_quote: collapse the consecutive\r/\nstr::replaceintoreplace(['\r','\n'], " ")and switch the manualcountaccumulator tochars().enumerate().ws/hub.rs::Hub: addimpl Default for Hub(the inherentnew()is otherwise the sole constructor).models/enclave.rs::EnclaveRole: replace the inherentfrom_strwithimpl std::str::FromStr for EnclaveRole. Callers indb/enclave.rsandtests/db_enclave.rspick up ause std::str::FromStr;so the existingEnclaveRole::from_str(...)call shape still resolves.routes/email_verification.rs,routes/password_reset.rs: drop the inner#![cfg(feature = "standalone")]. The outer#[cfg(feature = "standalone")] mod ...;inroutes/mod.rsalready gates compilation.format!("...{}", x)/println!("...{}", x)site: inlined into the captured-identifier form viacargo clippy --fix.Tests
tests/db_uploads.rs:map.get(&m3).is_none()->!map.contains_key(&m3).tests/routes_broadcast_mentions.rs::TestApp.push_client: field-level#[allow(dead_code)](some test cases swap in a counting mock and observe it; not every binary in the file reads it).tests/routes_enclave.rs,tests/db_dm_mute.rs,tests/db_mentions.rs: residual inlined-format-args and&val->valfromcargo clippy --fix --all-targets.Test plan
./dev/cargo clippy -p lets-chat-server --all-targets -- -D warningsis clean../dev/cargo clippy -p lets-chat-server --no-default-features --features saas --all-targets -- -D warningsis clean../dev/cargo-desktop clippy -p lets-chat-desktop -- -D warningsis clean../dev/cargo fmt --checkis clean../dev/cargo test -p lets-chat-server --no-runcompiles every test binary.A follow-up PR will bump
./dev/cargotorust:1.94-slim-bookwormand add-- -D warningsto the justfile clippy recipes so this kind of drift surfaces locally before CI catches it.CI runs clippy on Rust 1.94 with `-D warnings`, which surfaces a handful of lints that local `just check` (currently pinned to Rust 1.88, no `-D warnings`) only reports as informational warnings. Bringing the source in line with both layers: Library - `bg.rs`, `views/room.rs`: `std::iter::repeat("?").take(n)` -> `std::iter::repeat_n("?", n)` (clippy::manual_repeat_n, added in 1.82). - `views/room.rs::excerpt_for_quote`: collapse two consecutive `str::replace` calls into `replace(['\\r','\\n'], " ")` and switch the manual `count` accumulator to `chars().enumerate()` (clippy::collapsible_str_replace, clippy::explicit_counter_loop). - `ws/hub.rs::Hub`: add `impl Default for Hub` so the inherent `new()` is not flagged as the sole construction path (clippy::new_without_default). - `models/enclave.rs::EnclaveRole`: replace the inherent `from_str` with a proper `impl FromStr for EnclaveRole` (clippy::should_implement_trait). Callers in `db/enclave.rs` and `tests/db_enclave.rs` get a `use std::str::FromStr;` so the existing `EnclaveRole::from_str(...)` call sites resolve unchanged. - `routes/email_verification.rs`, `routes/password_reset.rs`: drop the inner `#![cfg(feature = "standalone")]`. The outer `#[cfg(feature = "standalone")] mod foo;` in `routes/mod.rs` already gates compilation, so the file-scope attribute is redundant (clippy::duplicated_attributes). - Build scripts (`server/build.rs`, `desktop/build.rs`) and the rest of the lib + tests: inlined every `format!("...{}", x)` / `println!("...{}", x)` into the captured-identifier form `{x}` (clippy::uninlined_format_args, fully mechanical, applied via `cargo clippy --fix`). Tests - `tests/db_uploads.rs`: `map.get(&m3).is_none()` -> `!map.contains_key(&m3)` (clippy::redundant_pattern_matching variant). - `tests/routes_broadcast_mentions.rs`: `TestApp.push_client` is set by some test cases and read by others but not by every binary in this file, so add a field-level `#[allow(dead_code)]` rather than gating every individual test with `#[cfg(...)]` (clippy::dead_code in test binaries). - `tests/routes_enclave.rs`, `tests/db_dm_mute.rs`, `tests/db_mentions.rs`: residual inlined-format-args and `&val` -> `val` cleanups picked up by `cargo clippy --fix --all-targets`. Verification - `./dev/cargo clippy -p lets-chat-server --all-targets -- -D warnings` is clean. - `./dev/cargo clippy -p lets-chat-server --no-default-features --features saas --all-targets -- -D warnings` is clean. - `./dev/cargo-desktop clippy -p lets-chat-desktop -- -D warnings` is clean. - `./dev/cargo fmt --check` is clean. - `./dev/cargo test -p lets-chat-server --no-run` compiles every test binary. The `just check` recipe is intentionally not changed in this commit so the diff stays scoped to source fixes; bumping the local Rust image to 1.94 and adding `-- -D warnings` to the clippy recipes (so the local check matches what CI enforces) lands as a separate change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>