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?
|
|
The goal is to clean up unparsed derive helper attributes #153102. The rustdoc check preserves them only when they're actually needed. |
|
petrochenkov is asking why we're doing this, not what we're doing |
|
Oh okay #131229, it was proposed to filter out derived helper attributes during ast lowering. The issue was worked on by sasha but it was reverted caused some tooling like rustdoc depends on these attributes. The way forward was either to reland initial implementation with rustdoc guard or leave as is |
|
We had some very brief discussion in #t-compiler > attribute parsing rework @ 💬 but that is also pretty low on motivation other than being able to turn pub enum Attribute {
Parsed(AttributeKind),
Tool(...),
}
If derive helpers are encoded cross crate (I don't know?) then maybe? Anyway, let's see: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…try> filter out derive helper attributes during ast lowering but keeping them for rustdoc
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (616fb4f): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary 0.9%, secondary -3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 518.288s -> 520.628s (0.45%) |
View all comments
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