Skip to content

filter out derive helper attributes during ast lowering but keeping them for rustdoc#157896

Open
kantnero wants to merge 1 commit into
rust-lang:mainfrom
kantnero:fix-derive-helper-rustdoc-guard
Open

filter out derive helper attributes during ast lowering but keeping them for rustdoc#157896
kantnero wants to merge 1 commit into
rust-lang:mainfrom
kantnero:fix-derive-helper-rustdoc-guard

Conversation

@kantnero

@kantnero kantnero commented Jun 14, 2026

Copy link
Copy Markdown

Relands #153102 with an actually_doc guard so that derive helper attributes are preserved in rustdoc JSON output. When running normally, they are dropped into dropped_attributes as before

The problem: @scrabsha 's original implementation dropped derive helper attributes during AST lowering, which is correct for normal compilation. However, rustdoc json relies on these attributes to expose them to tooling (BuFFI). This caused a regression reported in #157107 which was fixed by reverting PR in #157150

The fix: Before dropping an attribute into dropped_attributes, check self.sess.opts.actually_rustdoc. If rustdoc is running, keep the attribute so it appears in the JSON output. Otherwise drop it as before.

r? @JonathanBrouwer
cc @scrabsha

@rustbot

rustbot commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 14, 2026
@rustbot

rustbot commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JonathanBrouwer (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants