Skip to content

chore: Adopt cargo-fixit, align clippy lints with crypto, clear cargo-shear warnings - #3479

Open
huitseeker wants to merge 14 commits into
nextfrom
chore/resolve-cargo-shear-warnings
Open

chore: Adopt cargo-fixit, align clippy lints with crypto, clear cargo-shear warnings#3479
huitseeker wants to merge 14 commits into
nextfrom
chore/resolve-cargo-shear-warnings

Conversation

@huitseeker

@huitseeker huitseeker commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

cargo-fixit

make xclippy-fix runs cargo fixit --clippy instead of cargo clippy --fix (TL;DR: a much faster cargo fix)

The xclippy cargo alias in .cargo/config.toml stays the single source for the lint set. fixit cannot take lint flags as trailing arguments, so the Makefile reads that list into CLIPPY_LINT_FLAGS and passes it through RUSTFLAGS. The check path reads the same alias, so check and fix cannot drift apart. The old xclippy-fix alias is removed. CONTRIBUTING.md uses cargo fixit.

If fixit is missing, the target prints the install command and skips. CI is unchanged.

Clippy lints

Six lints that the 0xmiden/crypto repo already enforced are now on, one per commit:

  • checked_conversions, debug_assert_with_mut_call, expl_impl_clone_on_copy, unimplemented: code fixed.
  • fn_params_excessive_bools on NodeFlags, option_option in build.rs: kept as-is with a scoped #[allow] and a reason.

cargo-shear

make shear goes from 6 warnings to 0.

  • Deleted air/src/constraints/decoder/tests.rs, an empty unlinked file.
  • Deleted crates/lib/core/tests/pcs/, 839 lines of winter-fri tests orphaned since the Plonky3 move. The full history is in the commit.
  • core/Cargo.toml adds ignored-paths for tests/ui/**, the trybuild fixtures loaded by path at runtime.
  • assembly-syntax-cst: dropped unused thiserror.
  • core-lib: dropped redundant optional miden-ace-codegen, already a
    dev-dependency.
  • mast-package: dropped stale ignored = ["serde_json"].

`make xclippy-fix` now runs `cargo +stable fixit --clippy` (a faster
drop-in for `cargo clippy --fix`) instead of the `xclippy-fix` cargo
alias.

The `xclippy` alias in .cargo/config.toml remains the single source of
truth for the lint set. The Makefile extracts those flags into
CLIPPY_LINT_FLAGS and passes them to fixit via RUSTFLAGS, since fixit
cannot take lint flags as trailing arguments. The check path reads the
same alias directly, so the two paths cannot drift apart.

The now-unused `xclippy-fix` cargo alias is removed. When cargo-fixit is
not installed the target prints the install command and skips rather than
falling back to clippy. CI is untouched (it never ran the fix step).
CONTRIBUTING.md uses `cargo fixit`.
Replace the manual `Copy`/`Clone` impls on `Span<T>` with a derive,
which matches the existing `T: Copy`/`T: Clone` bounds exactly.

Enable `clippy::expl_impl_clone_on_copy` in the project clippy aliases.
The `build_aux_trace` stub in the ACE codegen test AIR is never called;
use `unreachable!` instead of `unimplemented!`. (`todo!` would trip the
already-enabled `clippy::todo`.)

Enable `clippy::unimplemented` in the project clippy aliases.
Hoist the mutable iterator `.next()` calls out of `debug_assert!` in the
ACE and hasher chiplet traces. Calling `.next()` inside `debug_assert!`
means the iterator advances in debug builds but not in release builds;
evaluating the call unconditionally keeps behaviour consistent.

Enable `clippy::debug_assert_with_mut_call` in the project clippy aliases.
`reexport_target_docs` returns `Option<Option<String>>` to encode three
states the caller relies on: target not found (skip the re-export),
found without docs (emit the procedure with no docs), and found with
docs. Conflating the outer two would emit spurious doc entries for
unresolved re-exports, so the nesting is intentional; document it with
a scoped `#[allow]`.

Enable `clippy::option_option` in the project clippy aliases.
`NodeFlags` packs four independent booleans into the hasher state's
second word for END operations; there is no natural smaller grouping and
`fn_params_excessive_bools` has no configurable threshold, so scope an
`#[allow]` on the constructor with a justification, matching the
flag-bundle relaxation already in `.clippy.toml`.

Enable `clippy::fn_params_excessive_bools` in the project clippy aliases.
Replace the `x <= (T::MAX as U)` checked-cast guards with the
idiomatic `T::try_from(x).is_ok()` form across the seven remaining
sites (proof order, parser value shrinking, MAST serialization test,
parallel trace test, precompiles bench inputs).

Enable `clippy::checked_conversions` in the project clippy aliases.
`air/src/constraints/decoder/tests.rs` is a zero-byte file with no
corresponding `mod tests` declaration in `decoder/mod.rs`, so it is
never compiled. cargo-shear flagged it as unlinked. Delete it.
`core/tests/ui/mast_forest_immutable/index_node_mut.rs` is a trybuild
`compile_fail` fixture loaded by path at runtime in `public_api.rs`, so
cargo-shear cannot statically link it. Add a scoped `ignored-paths` entry
for `tests/ui/**` rather than deleting the fixture, which would remove a
real compile_fail test.
thiserror is a derive-only crate, and no code in
miden-assembly-syntax-cst uses `#[derive(thiserror::Error)]` or imports
it. Remove the dependency and the stale `"thiserror/std"` entry from the
`std` feature.
…re-lib

miden-ace-codegen was listed both as an optional `[dependencies]` entry
(enabled by the `constraints-tools` feature) and as a
`[dev-dependencies]` entry. No non-test code in miden-core-lib imports
it; the two test files that use it get the crate via the dev-dependency.
Remove the redundant optional declaration and the `dep:miden-ace-codegen`
reference from the `constraints-tools` feature.
cargo-shear flagged `ignored = ["serde_json"]` as redundant because
serde_json is used in the `#[cfg(test)]` deserialization tests in
`section.rs`. The dependency is already correctly declared in
`[dev-dependencies]`, so the ignore is stale. Remove it.
Delete crates/lib/core/tests/pcs/ (839 lines across four files), a
winter-fri based FRI PCS verifier test module that has not compiled or
run since the Plonky3 migration. cargo-shear flags it as an unlinked
file because no `mod pcs;` declaration exists in tests/main.rs.

How this directory became orphaned (commit-by-commit):

  1. #2365 (a13eea1, 2025-11-15) "chore: rename STARK MASM mod"
     The pcs/ test directory was created alongside a STARK MASM module
     rename.

  2. #2427 (fd2e580, 2025-12-05) "chore: rename miden-libcore to
     miden-core-lib"
     The crate rename added `mod pcs;` to tests/main.rs, wiring the
     directory into the compiled test suite.

  3. #2472 (0083f51) "refactor: migrate underlying proving system to
     Plonky3"
     The Plonky3 migration replaced winter-fri with p3-fri. The legacy
     FRI tests in pcs/ and stark/ broke against the new APIs, so both
     were gated behind a new empty `legacy-stark-tests` feature:
         #[cfg(feature = "legacy-stark-tests")]
         mod pcs;

  4. #2616 (972e98e, 2026-01-30) "chore: disable legacy tests"
     The `legacy-stark-tests` feature was removed entirely and both
     module declarations were commented out:
         // These tests are disabled until the recursive verifier is
         // updated to work with Plonky3 proofs
         // mod pcs;
         // mod stark;

  5. #2869 (e5af1b7, 2026-03-27) "Update the recursive verifier to
     work with p3-miden"
     This commit created the current orphaned state. It migrated the
     stark/ test module to p3-fri and re-enabled it with `mod stark;`,
     but removed the `// mod pcs;` line entirely instead of
     uncommenting it. The pcs/ tests use winter-fri APIs directly and
     were not migrated.

The stark/ test module now covers the p3-fri based PCS path. The pcs/
tests are dead and deleting them clears the last cargo-shear warning.
@huitseeker
huitseeker marked this pull request as ready for review August 5, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant