Skip to content

Conversation

sffc
Copy link
Member

@sffc sffc commented Aug 14, 2025

See it in use in #6852

@sffc sffc requested a review from a team as a code owner August 14, 2025 06:57
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 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.

@sffc
Copy link
Member Author

sffc commented Aug 14, 2025

/gemini review

Copy link

@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 adds a new delegate module containing a helper macro data_provider_to_field!. The overall approach is good, with clear documentation and tests. I've identified a significant limitation in the macro's implementation that restricts its usability to only direct fields of a struct. I've provided a suggestion to make the macro more flexible by allowing delegation to nested fields, which would greatly improve its utility.

Comment on lines +44 to +60
macro_rules! __data_provider_to_field {
($provider:path, $marker:path, &self.$field:tt.as_deserializing()) => {
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
let provider = $crate::icu_provider::prelude::AsDeserializingBufferProvider::as_deserializing(&self.$field);
$crate::icu_provider::DataProvider::<$marker>::load(&provider, req)
}
}
};
($provider:path, $marker:path, &self.$field:tt) => {
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
$crate::icu_provider::DataProvider::<$marker>::load(&self.$field, req)
}
}
};
}

Choose a reason for hiding this comment

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

high

The current macro implementation is very restrictive as it only allows delegating to a direct field of self. The use of $field:tt matches only a single token tree, so it won't work for nested fields like self.foo.bar.

To make the macro more flexible and support nested field access, you can change $field:tt to $($field:tt)+. This will match one or more token trees, allowing for expressions like self.a.b.c.

Suggested change
macro_rules! __data_provider_to_field {
($provider:path, $marker:path, &self.$field:tt.as_deserializing()) => {
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
let provider = $crate::icu_provider::prelude::AsDeserializingBufferProvider::as_deserializing(&self.$field);
$crate::icu_provider::DataProvider::<$marker>::load(&provider, req)
}
}
};
($provider:path, $marker:path, &self.$field:tt) => {
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
$crate::icu_provider::DataProvider::<$marker>::load(&self.$field, req)
}
}
};
}
macro_rules! __data_provider_to_field {
($provider:path, $marker:path, &self.$($field:tt)+.as_deserializing()) => {
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
let provider = $crate::icu_provider::prelude::AsDeserializingBufferProvider::as_deserializing(&self.$($field)+);
$crate::icu_provider::DataProvider::<$marker>::load(&provider, req)
}
}
};
($provider:path, $marker:path, &self.$($field:tt)+) => {
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
$crate::icu_provider::DataProvider::<$marker>::load(&self.$($field)+, req)
}
}
};
}

Comment on lines +54 to +58
impl $crate::icu_provider::DataProvider<$marker> for $provider {
fn load(&self, req: $crate::icu_provider::DataRequest) -> Result<$crate::icu_provider::DataResponse<$marker>, $crate::icu_provider::DataError> {
$crate::icu_provider::DataProvider::<$marker>::load(&self.$field, req)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

this is a very small implementation which I'm not sure is worth a macro that has to be special cased for different providers

Copy link
Member

Choose a reason for hiding this comment

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

I'm ambivalent on this. I think it's fine, but I'm not strongly in favor of adding such a macro.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see it less about the macro and more about blessing this pattern as one we want to encourage, with a docs page, etc.

Copy link
Member

Choose a reason for hiding this comment

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

so just write a docs page? the macro seems brittle and learning how to use the macro is more effort than writing the redirecting impl

@robertbastian robertbastian added the waiting-on-author PRs waiting for action from the author for >7 days label Sep 26, 2025
@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
waiting-on-author PRs waiting for action from the author for >7 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants