-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc: show struct field docs when inlined #16025
Conversation
@alexcrichton this is leaving docs like "/// Foo bar" on inlined structs. Where do we do the stripping of that stuff now? I can't find it anywhere... |
I think it's the collapse/unindent doc pass in I imagine that most use cases don't want the attributes of a field on the |
I have no idea. I'll look into it. |
So the comment stripping happens in libsyntax now. It wasn't getting stripped because we weren't encoding the |
Some minor changes to the compiler to expose this information. Very inconvenient since struct fields aren't an item. Adds (yet another) table to metadata. Closes #15739
The impl of Clean for Vec obsoleted these long, long ago.
I really dislike that rustdoc is abusing metadata like this, instead of processing its own JSON output from other crates as it was designed to do... regardless, r? @alexcrichton |
ebml_w: ebml_w | ||
}, krate, ()); | ||
ebml_w.end_tag(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to already be a encode_struct_fields
method which seems like this call to encode_attributes
should be placed inside (rather than having a separate section). Did you try that and end up having it fall short of what should happen? It may also allow hooking into the existing load_attrs
function instead of having to redefined the decode_*
variants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode_struct_fields
is only used when encoding complete structs. There's this weird index + custom hashmap that indexes actual items, and the interaction between struct fields and the rest of the struct is weird and I don't really understand it. In particular, struct fields themselves aren't considered items so load_attrs
would never see them. Short of sticking the attributes in the field_ty
, I don't really see how to handle that.
So yes, I did try that, you rejected it and I wrote this instead 🐈
Some minor changes to the compiler to expose this information. Very inconvenient since struct fields aren't an item.
Some minor changes to the compiler to expose this information. Very
inconvenient since struct fields aren't an item.