Skip to content

chore: silence clippy 1.95 lint regressions across workspace#18

Merged
inureyes merged 3 commits into
mainfrom
chore/clippy-lint-fixes-rust-1.95
May 18, 2026
Merged

chore: silence clippy 1.95 lint regressions across workspace#18
inureyes merged 3 commits into
mainfrom
chore/clippy-lint-fixes-rust-1.95

Conversation

@inureyes
Copy link
Copy Markdown
Member

Summary

Rust 1.95.0 promoted several clippy lints to default-warn, and our CI runs cargo clippy -- -D warnings on a self-hosted macOS runner. The result was that PR #17 (and any other unrelated PR) couldn't pass CI: 53 lint findings (25 errors in CI's stricter view) lit up across mlxcel-core and mlxcel-surgery despite no behavioural change.

This PR clears every one of them. The workspace is now lint-clean under -D warnings against rust 1.95.0.

What changed

Auto-fixed via cargo clippy --fix (8 files, 18 changes): manual_is_multiple_of, manual_div_ceil, unnecessary_cast, useless_conversion, double_parens.

Manually rewritten:

  • needless_range_loop → iterator + take/enumerate (utils, quant, quant3, sampling, boundary, turbo_tests).
  • field_reassign_with_default → struct-init form (generate, speculative).
  • doc_overindented_list_items → list-continuation indent normalised (mtp/generator).
  • doc_lazy_continuation → reworded a softmax + cold-V line so leading + no longer parses as a markdown list marker.
  • unusual_byte_groupings0xC0FF_EE42 (pack3, quant).
  • duplicated_attribute → drop inner #![cfg(test)] where the parent already gates with #[cfg(test)].
  • missing_safety_doc → added # Safety to attention_from_ptr.

Targeted #[allow(...)] (intentional shape, not worth restructuring):

  • too_many_arguments on attention-dispatch helpers in layers.rs and the attention_sparse_v_turbo4{,_fused} kernels — positional signatures intentionally mirror Metal/MLX call sites.
  • needless_range_loop on forward_batched — mixed indexing into input_ids slices and batch_caches[i] is clearer than enumerate.
  • large_enum_variant / result_large_err on the paged-cache adopt path — shrinking forces callers through Box for no runtime gain on a cold path.
  • type_complexity on the SyntheticTarget test fixture's rollback_events — one-off test type.

Verification

  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • cargo test --workspace — 2757 passed; matches the pre-existing baseline on main (same multimodal::video::tests::load_video_source_fd_variant_* failures occur on main too, due to ffmpeg policy mismatches unrelated to this change)

Why a separate PR

PR #17 (gpt-oss perf fix) cannot pass CI until main is lint-clean. Bundling the two would mix an architectural perf fix with mechanical lint janitorial work. This PR lands first; #17 will rebase onto the cleaned-up main and re-trigger CI.

Rust 1.95.0 promoted several lints to default-warn (and CI runs with
`-D warnings`), causing a cascade of build failures across mlxcel-core
and mlxcel-surgery that had nothing to do with their underlying logic.
This commit makes the workspace lint-clean again under the new toolchain.

Auto-fixed via `cargo clippy --fix`:

- `manual_is_multiple_of` → `.is_multiple_of()` (pack3, quant3, utils)
- `manual_div_ceil` → `.div_ceil()` (utils)
- `unnecessary_cast` (quant, codebook, generate, etc.)
- `useless_conversion` (generate)
- `double_parens` (mtp/tests)

Manually rewritten:

- `needless_range_loop` → iterator + take/enumerate where the conversion
  was clear (utils, quant, quant3, sampling, boundary, turbo_tests).
- `field_reassign_with_default` → struct-init form (generate, speculative).
- `doc_overindented_list_items` → list-continuation indent normalised
  (speculative/mtp/generator).
- `doc_lazy_continuation` → reworded the `softmax + cold-V` paragraph in
  turbo_tests so a leading `+` no longer parses as a markdown list marker.
- `unusual_byte_groupings` → `0xC0FF_EE42` (pack3, quant).
- `duplicated_attribute` → drop inner `#![cfg(test)]` where the parent
  module already gates with `#[cfg(test)]` (mlxcel-surgery).
- Added a `# Safety` section to `attention_from_ptr` (layers).

Targeted `#[allow(...)]` (intentional shape, not worth restructuring):

- `too_many_arguments` on the attention-dispatch helpers in `layers.rs`
  and the `attention_sparse_v_turbo4{,_fused}` kernels: positional
  signatures intentionally mirror Metal/MLX call sites.
- `needless_range_loop` on `forward_batched`: mixed indexing into
  `input_ids` slices and `batch_caches[i]` is clearer than enumerate.
- `large_enum_variant` / `result_large_err` on the paged-cache adopt
  path: shrinking the variant would force callers through `Box` for no
  runtime gain on a cold path.
- `type_complexity` on the `SyntheticTarget` test fixture's
  `rollback_events`: it is a one-off test type.

`cargo clippy --workspace --all-targets -- -D warnings` is clean and
`cargo test --workspace` matches the pre-existing baseline (the same two
`multimodal::video` fd-variant tests fail on `main` too, due to runtime
ffmpeg policy mismatches unrelated to this change).
@inureyes inureyes added status:review Under review type:chore Maintenance tasks (build, CI, etc.) priority:high High priority area:core mlxcel-core: MLX FFI, primitives, KV cache, layers labels May 18, 2026
inureyes added 2 commits May 18, 2026 20:07
The earlier sweep ran without `--features metal,accelerate`, so the CI
build (which uses that exact feature set) still tripped on two finds:

- `quant.rs:422` unnecessary `as usize` cast on an already-usize index
- `generate.rs:826` explicit `.into_iter()` inside `zip(...)` which
  already accepts any `IntoIterator`

`cargo clippy --workspace --all-targets --features metal,accelerate
-- -D warnings` is now clean.
server::batch::speculative_burst::zip already accepts IntoIterator, so
the explicit `.into_iter()` on rows_tokens is redundant. Missed in the
prior sweep because the local check ran against a cached clippy result
where this file was unchanged; `cargo clean` followed by a fresh
`cargo clippy --workspace --all-targets --features metal,accelerate --
-D warnings` confirms the workspace is now clean.
@inureyes inureyes merged commit f265209 into main May 18, 2026
5 checks passed
@inureyes inureyes deleted the chore/clippy-lint-fixes-rust-1.95 branch May 18, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core mlxcel-core: MLX FFI, primitives, KV cache, layers priority:high High priority status:review Under review type:chore Maintenance tasks (build, CI, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant