filter out derive helper attributes during ast lowering but keeping them for rustdoc#157896
filter out derive helper attributes during ast lowering but keeping them for rustdoc#157896kantnero wants to merge 2 commits into
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
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 (
|
|
|
||
| if self.sess.opts.actually_rustdoc | ||
| || self.tools.is_some_and(|t| t.iter().any(|i| i.name == parts[0])) | ||
| // FIXME: this can be removed once #152369 has been merged. |
There was a problem hiding this comment.
hm, can you link the actual pr to make it less confusing then
There was a problem hiding this comment.
(i think Kivooeo meant "edit the commit and change 152369 -> 155691" so the comment + link are up to date)
|
This isn't enough. Rustdoc isn't the only tool relying on derive helper attributes. Any rustc driver does. None of them stable or course, so we could choose to ignore that. But we should be aware that by landing this PR that's a choice were making: rustdoc is more special than other rustc drivers and you can only look at derive helper attributes when using rusdoc-json and not other tools like stable mir, Charon, etc. |
|
I understand |
|
I've talked to @Nadrieril, the author of Charon, and for nadri it doesn't matter, and we all thought predicating it on rustdoc is the right way forward |
|
so from my POV we should merge this :) |
|
Sounds good 👍 |
|
What is the goal of doing this, in the first place?
|
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