Skip to content

[WIP]#3049

Closed
joshlf wants to merge 1 commit intoG4uato76xa2ezceilkolqtzoxhlxmxbg2from
Gr5hnlfzgkxvo5cdwir7s5hxfhlji6xjd
Closed

[WIP]#3049
joshlf wants to merge 1 commit intoG4uato76xa2ezceilkolqtzoxhlxmxbg2from
Gr5hnlfzgkxvo5cdwir7s5hxfhlji6xjd

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Feb 12, 2026


This PR is on branch hermes.

Latest Update: v3 — Compare vs v2

📚 Full Patch History

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

Version v2 v1 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/Gr5hnlfzgkxvo5cdwir7s5hxfhlji6xjd && git checkout -b pr-Gr5hnlfzgkxvo5cdwir7s5hxfhlji6xjd FETCH_HEAD

Checkout

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

Cherry Pick

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

Pull

git pull origin refs/heads/Gr5hnlfzgkxvo5cdwir7s5hxfhlji6xjd

Stacked PRs enabled by GHerrit.

gherrit-pr-id: Gr5hnlfzgkxvo5cdwir7s5hxfhlji6xjd
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @joshlf, 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 refactors the internal representation of parsed Rust items within the hermes tool, introducing dedicated enums for functions and types. It also implements a robust system for parsing and associating custom Hermes attributes from documentation comments with these items, enhancing the tool's ability to interpret and act upon specific annotations in the source code. This change aims to provide a more structured and extensible foundation for future attribute-driven analysis.

Highlights

  • Refactored Item Representation: The ParsedItem enum was refactored into more granular FunctionItem and TypeItem enums, improving the organization and clarity of how different Rust constructs are represented.
  • Attribute Parsing Logic: New logic was introduced to parse custom HermesAttr (e.g., spec, unsafe(axiom)) from doc comments, allowing for more specific annotations on functions and other items.
  • Updated Item Processing: The process_item function in the Visitor trait was updated to handle the new item structure and to extract and process associated Hermes attributes.
  • Attribute Rejection Mechanism: A new helper function, try_from_raw_reject_attr, was added to enforce that certain item types (like structs, enums, unions, traits, and impl blocks) do not carry specific Hermes attributes, preventing invalid annotations.

🧠 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/hermes/src/parse.rs
    • Refactored ParsedItem enum into FunctionItem, TypeItem, and a new ParsedItem enum.
    • Added name() and attrs() methods to FunctionItem and TypeItem for consistent access.
    • Modified ParsedItem to include Function, Type, Trait, and Impl variants, with Function now holding HermesBlock attributes.
    • Updated name() and attrs() implementations for ParsedItem to reflect the new structure.
    • Introduced try_from_raw_reject_attr helper function to validate attribute usage on items.
    • Modified process_item function signature and implementation to accept attributes and a closure for item creation.
    • Updated visit_item_fn, visit_item_struct, visit_item_enum, visit_item_union, visit_item_trait, visit_item_impl, visit_impl_item_fn, and visit_trait_item_fn to use the new process_item and ParsedItem structure.
    • Added a new attr module containing HermesAttr enum, HermesBlock struct, and associated functions (parse_hermes_info_string, extract_doc_line, extract_hermes_block) for parsing Hermes-specific attributes from doc comments.
Activity
  • The pull request is currently marked as 'Work In Progress' ([WIP]), indicating that it is not yet ready for final review.
  • No specific human activity (comments, reviews) has been recorded on this pull request yet, as it appears to be in an early stage of development.
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.

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

The pull request introduces a refactoring of the parsing logic to support Hermes-specific attributes. However, the current state of the code contains several critical issues that prevent it from compiling and adhering to the project's guidelines. Specifically, there are mismatches between function signatures and their call sites, logic errors where closure results are discarded, and type mismatches in enum variant construction. Furthermore, the use of todo! macros and TODO comments violates the repository's coding guidelines (as specified in AGENTS.md) and will cause CI failures.

Comment on lines +270 to +279
fn process_item<
T,
F: FnOnce(T, Option<attr::HermesAttr>) -> Result<ParsedItem, HermesError>,
>(
&mut self,
item: T,
attrs: &[Attribute],
span: Span,
f: F,
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The signature of process_item has been updated to include an attrs parameter, but all call sites (e.g., lines 377, 385, 393, etc.) are still passing only three arguments. This will result in a compilation error. Additionally, the generic parameter T lacks a trait bound that provides the attrs() method used on line 307.

Comment on lines +280 to +281
let attr = attr::parse_hermes_attr(attrs).unwrap();
f(item, attr);
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There are multiple issues here:

  1. attr::parse_hermes_attr is not defined in the attr module.
  2. The use of unwrap() will cause the tool to panic on malformed attributes; this should be handled gracefully.
  3. The result of the closure f(item, attr) is discarded, but it is needed to produce the ParsedItem used later in the function.

trace!("Visiting Fn {}", node.sig.ident);
self.process_item(ParsedItem::Fn(node.clone()), node.span());
self.process_item(node.clone(), node.span(), |item, attr| {
Ok(ParsedItem::Function { item: FunctionItem::Free(item), attribute: attr })
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The construction of ParsedItem::Function is incorrect:

  1. The field name is hermes, not attribute.
  2. The type of attr (likely Option<HermesAttr>) does not match the expected HermesBlock<HermesAttr> type defined for this variant.

f: F,
) -> Result<ParsedItem, HermesError> {
if attr.is_some() {
return Err(todo!("unsupported attribute on item"));
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The use of the todo! macro will cause a runtime panic and violates the project's coding guidelines. According to AGENTS.md, TODO markers (including the todo! macro) should only be used if you explicitly intend to block the PR, as CI is configured to fail on them. Consider using a proper error variant or a FIXME if this is intended to be non-blocking.

References
  1. Guidelines in AGENTS.md prohibit the use of TODO comments/macros unless intended to block the PR, as they trigger CI failures. (link)

UnsafeAxiom,
}

// TODO: We need to "unfold" this type – we unconditionally need `content`,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This TODO comment will cause CI to fail. Per the guidelines in AGENTS.md, please use FIXME for non-blocking issues.

Suggested change
// TODO: We need to "unfold" this type – we unconditionally need `content`,
// FIXME: We need to "unfold" this type – we unconditionally need `content`,
References
  1. AGENTS.md specifies that TODO comments should be avoided as they block CI; FIXME should be used for non-blocking issues. (link)

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (G4uato76xa2ezceilkolqtzoxhlxmxbg2@92a5536). Learn more about missing BASE report.

Additional details and impacted files
@@                         Coverage Diff                          @@
##             G4uato76xa2ezceilkolqtzoxhlxmxbg2    #3049   +/-   ##
====================================================================
  Coverage                                     ?   91.87%           
====================================================================
  Files                                        ?       20           
  Lines                                        ?     6057           
  Branches                                     ?        0           
====================================================================
  Hits                                         ?     5565           
  Misses                                       ?      492           
  Partials                                     ?        0           

☔ 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.

@joshlf
Copy link
Member Author

joshlf commented Feb 13, 2026

Squashed into #3051

@joshlf joshlf closed this Feb 13, 2026
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.

2 participants