Skip to content

[cargo-zerocopy] Auto-install targets, more components#3118

Merged
joshlf merged 1 commit intomainfrom
Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr
Mar 14, 2026
Merged

[cargo-zerocopy] Auto-install targets, more components#3118
joshlf merged 1 commit intomainfrom
Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Mar 14, 2026

Auto-install any --target arguments. Auto-install all of the following
components: rust-src, rustfmt, clippy, miri (nightly only)


Latest Update: v4 — Compare vs v3

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v3 v2 v1 Base
v4 vs v3 vs v2 vs v1 vs Base
v3 vs v2 vs v1 vs Base
v2 vs v1 vs Base
v1 vs Base
⬇️ Download this PR

Branch

git fetch origin refs/heads/Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr && git checkout -b pr-Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr FETCH_HEAD

Checkout

git fetch origin refs/heads/Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr

Stacked PRs enabled by GHerrit.

@joshlf joshlf mentioned this pull request Mar 14, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the cargo-zerocopy utility by automating the setup of required Rust toolchain components and build targets. It introduces a more robust and user-friendly mechanism for ensuring that all necessary dependencies are present, reducing manual intervention and potential setup errors for developers working with different targets or requiring specific tools like clippy or miri.

Highlights

  • Automatic Target Installation: The cargo-zerocopy tool now automatically detects and installs any missing Rust targets specified via --target arguments or the CARGO_BUILD_TARGET environment variable, streamlining cross-compilation workflows.
  • Enhanced Toolchain Component Installation: The toolchain installation logic has been updated to automatically install essential components: rust-src, rustfmt, clippy, and miri (for nightly toolchains), ensuring a complete development environment.
  • Refactored Installation Logic: A new generic ensure_installed_or_exit function was introduced to centralize the logic for checking installation status, prompting the user for confirmation, and executing installations, improving code reusability and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tools/cargo-zerocopy/src/main.rs
    • Imported HashSet, BufRead, and Write for new functionality.
    • Removed the is_toolchain_installed function.
    • Introduced ensure_installed_or_exit to abstract common installation prompting and execution logic.
    • Modified install_toolchain_or_exit to use the new ensure_installed_or_exit function and to install rust-src, rustfmt, clippy, and miri (for nightly) components.
    • Added install_targets_or_exit to automatically detect and install missing Rust targets.
    • Updated delegate_cargo to parse --target arguments and CARGO_BUILD_TARGET environment variable, then call install_targets_or_exit.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@joshlf joshlf requested a review from jswrenn March 14, 2026 15:58
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the toolchain installation logic to be more generic and adds auto-installation for rustup components (rust-src, rustfmt, clippy, miri) and any specified --target arguments. The changes are well-structured, using a new ensure_installed_or_exit helper function to handle the installation prompt and logic. My review focuses on improving robustness by handling potential panics from I/O operations and invalid UTF-8 output from external commands, as well as a minor simplification to remove an unnecessary string allocation.

@joshlf joshlf force-pushed the Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr branch from 1410343 to 63a8820 Compare March 14, 2026 15:59
@joshlf joshlf removed the request for review from jswrenn March 14, 2026 16:01
@codecov-commenter
Copy link

codecov-commenter commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.87%. Comparing base (4212573) to head (09034d8).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3118   +/-   ##
=======================================
  Coverage   91.87%   91.87%           
=======================================
  Files          20       20           
  Lines        6057     6057           
=======================================
  Hits         5565     5565           
  Misses        492      492           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Auto-install any `--target` arguments. Auto-install all of the following
components: `rust-src`, `rustfmt`, `clippy`, `miri` (nightly only)

gherrit-pr-id: Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr
@joshlf joshlf force-pushed the Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr branch from 63a8820 to 09034d8 Compare March 14, 2026 16:12
@joshlf joshlf requested a review from jswrenn March 14, 2026 16:13
@joshlf joshlf enabled auto-merge March 14, 2026 16:16
@joshlf joshlf added this pull request to the merge queue Mar 14, 2026
Merged via the queue into main with commit ca496e3 Mar 14, 2026
105 checks passed
@joshlf joshlf deleted the Gj5ggnjidkmm6c3foelh4ou7sbi55y4qr branch March 14, 2026 16:54
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.

3 participants