Add cargo-machete prek hook#165
Merged
Merged
Conversation
Roger-luo
approved these changes
Jun 30, 2026
There was a problem hiding this comment.
Pull request overview
Adds an unused-dependency check to the repo’s local/CI hook suite by introducing a cargo-machete prek hook (provisioned via mise), updates the developer guide to describe the new check, and prunes a few now-unused Rust dependencies. The PR also adds two Python demo scripts under ppvm-python/demo/.
Changes:
- Add a workspace-wide
cargo-machetehook toprek.tomland install the binary viamise.toml. - Document the new unused-dependency check in
docs/src/pages/develop.astro. - Remove unused Rust dependencies from several manifests / lockfile; add Python demo scripts.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
prek.toml |
Adds a new local cargo-machete hook invoked via mise exec -- …. |
mise.toml |
Adds cargo-machete to the mise-managed toolchain. |
docs/src/pages/develop.astro |
Documents the new unused-dependency check and adds a code-style bullet. |
ppvm-python/demo/squin_kernel.py |
Adds a squin-based demo using GeneralizedTableauSimulator. |
ppvm-python/demo/hello_world.py |
Adds a demo that encodes/decodes “Hello, world!” via GeneralizedTableau. |
crates/ppvm-tableau-sum/Cargo.toml |
Removes an unused crate dependency (ppvm-pauli-word). |
crates/ppvm-python-native/Cargo.toml |
Removes an unused crate dependency (num). |
Cargo.toml |
Removes unused top-level dependencies (fxhash, num). |
Cargo.lock |
Updates lockfile to reflect removed dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+62
to
+63
| pass_filenames = false | ||
| types = ["rust"] |
Comment on lines
+11
to
+14
| sim = GeneralizedTableauSimulator(2) | ||
| task = sim.task(main) | ||
| task.run() | ||
| print(task.state) |
Comment on lines
+10
to
+32
| MESSAGE = "Hello, world!" | ||
|
|
||
| # ASCII bytes -> bit list, MSB first within each byte. | ||
| data = MESSAGE.encode("ascii") | ||
| bits = [(byte >> (7 - i)) & 1 for byte in data for i in range(8)] | ||
|
|
||
| # One qubit per bit; flip every qubit whose target bit is 1. | ||
| tab = GeneralizedTableau(n_qubits=len(bits)) | ||
| for q, bit in enumerate(bits): | ||
| if bit: | ||
| tab.x(q) | ||
|
|
||
| # Measure all qubits and decode the outcomes back into a string. | ||
| measured = [int(tab.measure(q)) for q in range(len(bits))] | ||
| decoded = bytes( | ||
| int("".join(str(b) for b in measured[i : i + 8]), 2) | ||
| for i in range(0, len(measured), 8) | ||
| ).decode("ascii") | ||
|
|
||
| print(f"qubits: {len(bits)}") | ||
| print(f"decoded: {decoded!r}") | ||
| assert decoded == MESSAGE, f"round-trip failed: {decoded!r}" | ||
| print("round-trip OK") |
| <ul> | ||
| <li>Run <code>cargo fmt --all</code> before committing Rust.</li> | ||
| <li>Run <code>cargo clippy --workspace --all-targets</code>; fix or justify all warnings.</li> | ||
| <li>Run <code>cargo machete</code> to catch unused dependencies; it's also a <code>prek</code> hook, run on commit and in CI.</li> |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds cargo machete prek hook to detect unused dependency. This will run locally and as part of the CI. Also, removed some unused dependencies and pushed some (completely unrelated) python demo scripts I had lying around.