Preserve doc comment when type alias is hidden#3122
Preserve doc comment when type alias is hidden#3122jschwe wants to merge 3 commits intorust-lang:mainfrom
Conversation
27ec386 to
f9984d7
Compare
bindgen/codegen/mod.rs
Outdated
| } | ||
| let type_alias_comment = ctx | ||
| .items() | ||
| .filter(|(_id, alias)| { |
There was a problem hiding this comment.
Iterating over all items seems not really fine, performance wise. Can we avoid it somehow?
There was a problem hiding this comment.
Hmm - I think since we are using this fallback for the case where typedef and struct declaration are at the same time, a potential type alias should always be at item_id + 1. I don't think we currently have a way to access the "next" item or do arithmetic on item ids, but this would avoid iterating through all items.
There was a problem hiding this comment.
Maybe we can do it the other way around? During the clang phase, go peek at the typedef's comment? Haven't tried it tho.
There was a problem hiding this comment.
I got back to this and the new approach should resolve this concern.
If a type is not documented, but a type alias with the same canonical path is, then generate the documentation of the typealias onto the type, since otherwise it would be lost.
f9984d7 to
6843b03
Compare
6843b03 to
20ceeeb
Compare
If a type is not documented, but a type alias with the same canonical path is, then preserve the
documentation of the type alias onto the type, since otherwise it would be lost.
Fixes #3119