Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rust: move body skipping logic to code generation #19559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: aibaars/rust-extract-libs
Choose a base branch
Loading
from

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented May 22, 2025

It also contains a refactoring where FieldInfo{ name: "xxx".to_string(), ty: FieldType::Optional("Yyy".to_string() } can now be written more succintly FieldInfo::optional("xxx", "Yyy"), and similarly for other field types.

@Copilot Copilot AI review requested due to automatic review settings May 22, 2025 12:49
@redsun82 redsun82 requested a review from a team as a code owner May 22, 2025 12:49
@github-actions github-actions bot added the Rust Pull requests that update Rust code label May 22, 2025
Copy link
Contributor

@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 refactors how body-skipping logic is applied by moving it from the Rust extractor’s translator into the AST code generator, so that function/const/static bodies (and other designated “body” fields) are conditionally omitted during code generation for library crates.

  • Remove translator-level node exclusion and introduce a simple should_skip_bodies() check
  • Update the extractor.mustache template to wrap “body” fields with should_skip_bodies()
  • Extend the AST generator to mark specific fields (e.g., function body) as Body and generalize FieldInfo

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
rust/extractor/src/translate/base.rs Deleted the complex should_be_excluded(&AstNode) fn and added should_skip_bodies(); renamed should_be_excluded_attrs to should_be_excluded
rust/ast-generator/templates/extractor.mustache Moved node-level exclusion into attribute-only block and added template logic to skip “body” fields
rust/ast-generator/src/main.rs Introduced FieldType::Body, helper constructors, and wired up Body fields in get_additional_fields and get_fields
Comments suppressed due to low confidence (2)

rust/extractor/src/translate/base.rs:630

  • [nitpick] The name should_be_excluded only applies to attribute-based exclusion now. Consider renaming to should_be_excluded_by_attrs or similar for clarity and to avoid confusion if a future node-level exclusion is needed.
pub(crate) fn should_be_excluded(&self, item: &impl ast::HasAttrs) -> bool {

rust/ast-generator/templates/extractor.mustache:38

  • The global node exclusion check was moved inside the has_attrs block, so nodes without attributes no longer respect should_be_excluded. Reintroduce the unconditional check before handling attributes to preserve prior behavior.
if self.should_be_excluded(node) { return None; }

rust/ast-generator/src/main.rs Show resolved Hide resolved
@redsun82 redsun82 requested a review from aibaars May 22, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.