rustdoc: correctly propagate cfgs for glob reexports#157039
Conversation
67eb276 to
e1944da
Compare
e1944da to
028afca
Compare
|
This is the expected behaviour as described in the rustdoc book: https://doc.rust-lang.org/rustdoc/write-documentation/re-exports.html?highlight=glob#attributes Although I don't mind changing it. What do you think @rust-lang/rustdoc-internals ? |
|
This change absolutely makes sense to me. And I might be missing something, but it seems that according the rustdoc book, the current behaviour is wrong for glob re-exports?
(BTW, the book also has an instance where it says |
|
Oh you're right. Somehow I read the opposite... Sorry about that @lcian. And yeah, the book has a typo. Feel free to send a PR, otherwise I'll do it once I'm done with my current work. |
…r=yotamofek Fix `cfg` typo in rustdoc book Fixes typo spotted by @yotamofek [here](rust-lang#157039 (comment)). r? @yotamofek
|
Since the re-export's In general I think the default behavior should be the least surprise and this behavior (with/without |
…r=yotamofek Fix `cfg` typo in rustdoc book Fixes typo spotted by @yotamofek [here](rust-lang#157039 (comment)). r? @yotamofek
This fixes some cases of rustdoc not surfacing the correct required feature combination when using
#[cfg(feature = ...)]in combination with glob reexports.See the example cases included as tests.
Here's the generated HTML for those test cases before this change:

and after:

My understanding is that this was basically an off-by-one type of oversight.
We need to update
is_inlinebefore callingget_all_import_attributesto immediately reflect that the outermost import we're processing shall indeed be considered as inline, as it's a glob.Otherwise, we will end up calling
add_without_unwanted_attributeswithis_inline == falseon the "intermediate" re-export, which will skip propagating itscfgs.I believe this fixes #96166, even though the description there is not super clear on the exact test case they used (there's a snippet but the author says their code is actually different).
Refs #43781
@rustbot label +F-doc_cfg
@rustbot r? @GuillaumeGomez