Skip to content

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Jul 2, 2025

#6723

WIP demo showing miri-cleanliness of zerovec, using pointer metadata APIs.

Currently it is not possible to fix VarZeroCow

Copy link

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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

@Manishearth Manishearth force-pushed the zerovec-miri-clean branch from 7dc5dc6 to 85f5be2 Compare July 2, 2025 20:09
@robertbastian robertbastian changed the title Make ZeroVec miri-clean iwth stacked borrows Make ZeroVec miri-clean with stacked borrows Jul 9, 2025
@sffc sffc requested a review from Copilot August 26, 2025 21:35
@sffc
Copy link
Member

sffc commented Aug 26, 2025

/gemini review

Copy link

@Copilot 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

This PR updates the ZeroVec library to be Miri-clean with stacked borrows by adopting the stable pointer metadata APIs instead of unsafe transmute operations. The changes eliminate undefined behavior when converting between different pointer types by properly preserving pointer metadata.

  • Replaces unsafe transmute operations with stable ptr::metadata and ptr::from_raw_parts APIs
  • Removes ManuallyDrop wrappers in favor of direct Box::into_raw operations
  • Enables the ptr_metadata feature flag across affected components

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
utils/zerovec/src/ule/mod.rs Updates to_boxed_var_ule to use pointer metadata APIs
utils/zerovec/src/ule/encode.rs Updates encode_varule_to_box to use pointer metadata APIs
utils/zerovec/src/lib.rs Enables ptr_metadata feature flag
utils/zerovec/src/cow.rs Updates pointer conversion logic in new_owned
utils/zerovec/derive/src/varule.rs Replaces transmute with pointer metadata APIs
components/*/src/lib.rs Enables ptr_metadata feature flag in various components

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

#![cfg(ptr_metadata)]
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

This should be #![feature(ptr_metadata)] to enable the feature, not #![cfg(ptr_metadata)] which is a conditional compilation attribute.

Suggested change
#![cfg(ptr_metadata)]
#![feature(ptr_metadata)]

Copilot uses AI. Check for mistakes.

Comment on lines +190 to +192
// disallowed?
// let raw_u8: *mut u8 = raw_v as *mut [u8] as *mut u8;
let raw_u8: *mut u8 = raw_v as *mut () as *mut u8;
Copy link
Preview

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The commented-out line and the current cast through *mut () suggest uncertainty about the correct approach. This should be clarified with a proper explanation or the commented code should be removed.

Suggested change
// disallowed?
// let raw_u8: *mut u8 = raw_v as *mut [u8] as *mut u8;
let raw_u8: *mut u8 = raw_v as *mut () as *mut u8;
// SAFETY: `V: VarULE` guarantees that the memory layout of `V` is a valid byte slice,
// and `Box<V>` is heap-allocated, so it is safe to treat its pointer as a pointer to bytes.
let raw_u8: *mut u8 = raw_v as *mut u8;

Copilot uses AI. Check for mistakes.

Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@sffc
Copy link
Member

sffc commented Aug 26, 2025

/gemini review

Copy link

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@CLAassistant
Copy link

CLAassistant commented Sep 29, 2025

CLA assistant check
All committers have signed the CLA.

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