Skip to content

Apply rustfmt to test vectors and use static slices instead of vec#122

Merged
nuttycom merged 3 commits into
masterfrom
rustfmt-vectors
Apr 2, 2026
Merged

Apply rustfmt to test vectors and use static slices instead of vec#122
nuttycom merged 3 commits into
masterfrom
rustfmt-vectors

Conversation

@nuttycom
Copy link
Copy Markdown
Contributor

@nuttycom nuttycom commented Apr 1, 2026

Fixes #66

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Rust test-vector generation/CI pipeline to enforce consistent formatting and shifts generated Rust test-vector types from heap-allocated Vec to 'static slice references.

Changes:

  • Switches several generator schemas from Vec<...> / Option<Vec<...>> to &'static [...] / Option<&'static [...].
  • Updates the Rust emission logic to print slice literals (&[...]) and adds a slice-based bool emitter.
  • Runs rustfmt during Rust test-vector regeneration and adds Rust toolchain setup + a compile check in CI.

Reviewed changes

Copilot reviewed 34 out of 44 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
zcash_test_vectors/zip_0244.py Updates Rust field types to 'static slices for ZIP-0244 vectors.
zcash_test_vectors/zip_0243.py Updates Rust field types to 'static slices for ZIP-0243 vectors.
zcash_test_vectors/zip_0233.py Updates Rust field types to 'static slices for ZIP-0233 vectors.
zcash_test_vectors/zip_0143.py Updates Rust field types to 'static slices for ZIP-0143 vectors.
zcash_test_vectors/unified_incoming_viewing_keys.py Converts bytes fields to Option<&'static [u8]> / &'static [u8].
zcash_test_vectors/unified_full_viewing_keys.py Converts bytes fields to Option<&'static [u8]> / &'static [u8].
zcash_test_vectors/unified_address.py Converts bytes fields to Option<&'static [u8]> / &'static [u8].
zcash_test_vectors/output.py Adjusts Rust emission to prefer slice literals and slice-bool formatting.
zcash_test_vectors/orchard/sinsemilla.py Converts domain/msg types to slice-based Rust types (&[u8], &[bool]).
zcash_test_vectors/orchard/group_hash.py Converts domain/msg Rust types to &'static [u8].
zcash_test_vectors/f4jumble.py Converts Rust types to &'static [u8].
test-vectors/rust/zip_0320.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/zip_0316.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/zip_0032_registered.rs Rustfmt reflow of hard-coded test vectors (incl. &[] cleanup).
test-vectors/rust/zip_0032_arbitrary.rs Rustfmt reflow of hard-coded test vectors (incl. &[] cleanup).
test-vectors/rust/sapling_generators.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/orchard_zip32.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/orchard_poseidon_hash.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/orchard_map_to_curve.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/orchard_generators.rs Rustfmt reflow of hard-coded test vectors.
test-vectors/rust/orchard_empty_roots.rs Rustfmt reflow of hard-coded test vectors (multi-line array formatting).
test-vectors/rust/f4jumble_long.rs Rustfmt reflow of hard-coded test vectors.
regenerate.sh Pipes Rust generation through rustfmt when producing .rs vectors.
.github/workflows/test_vectors.yml Installs rustfmt in the Rust matrix job and compiles generated Rust vector files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread zcash_test_vectors/output.py Outdated
Comment thread zcash_test_vectors/output.py Outdated
Comment thread regenerate.sh
Pipe Rust test vector output through rustfmt in regenerate.sh so
that generated code follows standard Rust formatting conventions.

Closes #66

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nuttycom and others added 2 commits April 2, 2026 08:48
Replace Vec<u8>, Vec<bool>, Vec<i64>, and Vec<Vec<u8>> with their
static slice equivalents (&'static [u8], &'static [bool], etc.)
in all generators and the output renderer. The use of vec![] was a
holdover from a period where static slices weren't usable in const
contexts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Install Rust toolchain in CI for rustfmt during regeneration.
Add a compilation step that verifies all generated Rust test vectors
compile successfully. Use a temp dir for rustc output since -o
/dev/null creates temp files in the output directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nuttycom nuttycom requested review from daira and nullcopy April 2, 2026 14:57
Copy link
Copy Markdown

@nullcopy nullcopy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK f0cfe15

@nuttycom nuttycom merged commit 42fd6fa into master Apr 2, 2026
7 checks passed
@nuttycom nuttycom deleted the rustfmt-vectors branch April 2, 2026 20:39
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.

Add rustfmt to CI workflow

3 participants