Skip to content

Comments

refactor: centralize comment generation checks#3330

Merged
emilio merged 1 commit intorust-lang:mainfrom
naoNao89:refactor/issue-445-comment-generation
Feb 21, 2026
Merged

refactor: centralize comment generation checks#3330
emilio merged 1 commit intorust-lang:mainfrom
naoNao89:refactor/issue-445-comment-generation

Conversation

@naoNao89
Copy link
Contributor

hi, this my first pr which refactor. eliminates duplicate generate_comments checks from codegen. types now handle check themselves, centralized decision logic per type, cleaner code. FieldData::doc_comment() and EnumVariant::doc_comment() make it idiomatic.

Hope receive feedback

fixes #445

- Add doc_comment() method to FieldData that checks generate_comments flag
- Add doc_comment() method to EnumVariant that checks generate_comments flag
- Remove redundant generate_comments checks from field codegen
- Remove redundant generate_comments checks from enum variant codegen

This makes the code more idiomatic by having types that generate comments
handle the flag check themselves, eliminating duplication and centralizing
the decision logic.
@naoNao89 naoNao89 force-pushed the refactor/issue-445-comment-generation branch from b9b425b to 751920e Compare December 15, 2025 21:48
Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

r=me

return None;
}

self.comment
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be a bit more concise with:

Some(ctx.options().process_comment(self.comment.as_deref()?))

But this is fine as well of course.

@emilio emilio added this pull request to the merge queue Feb 21, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 21, 2026
@emilio emilio added this pull request to the merge queue Feb 21, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 21, 2026
@emilio emilio added this pull request to the merge queue Feb 21, 2026
Merged via the queue into rust-lang:main with commit 0408333 Feb 21, 2026
51 checks passed
@naoNao89 naoNao89 deleted the refactor/issue-445-comment-generation branch February 21, 2026 14:15
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.

Figure out a more idiomatic way to check if we should generate comments.

2 participants