[rustdoc] Add support new bang macro kinds #145458
Open
+455
−224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements #145153 in rustdoc. This PR voluntarily doesn't touch anything related to intra-doc links, I'll send a follow-up if needed.
So now about the implementation itself: this is a weird case where a macro can be different things at once but still only gets one file generated. I saw two ways to implement this:
ItemKind::Macro
differently and iter through itsMacroKinds
values.ItemKind
enum, which means that when we encounter them in rendering, we need to ignore them. It also makes theItemKind
enum bigger (and also needs more code to be handled). Another downside is that it needs to be handled in the JSON output.I implemented 1. in the first commit and 2. in the third commit so if we don't to keep 2., I can simply remove it. I personally have no preference for one or the other since the first is "simpler" but it's easy to forget to go through the macro kinds whereas the second needs a lot more code.
Now there was an interesting improvement that came with this PR in the
html::render::print_item::item_module
function: I simplified its implementation and split the different parts in aHashMap
where the key is the item type. So then, we can just iterate through the keys and open/close the section at each iteration instead of keeping anOption<section>
around.cc @joshtriplett