You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(doc_auto_cfg)]#[cfg(a)]pubmod a {pubusecrate::b::B;}#[cfg(any(a, b))]mod b {pubstructB;}
I expected to see this happen: The docs show that a::B requires the cfg a only.
Instead, this happened: The docs show that a::B requires the cfg a and (a or b).
Reasoning: When re-exporting things with different cfgs like this there are two things that can happen:
The re-export uses a subset of cfgs like the example, this subset is sufficient so that the item will appear exactly with the subset
The re-export uses a non-subset of cfgs (e.g. cfg(any(a, c)) on mod a above), if the non-subset cfgs are active (--cfg=c) then this will be a compile error as the item doesn't exist to re-export, if the subset cfgs are active it behaves like 1.
This only applies to non-glob inlined re-exports, for glob re-exports the item may or may not exist to be re-exported (potentially the cfgs on the path up until the glob can be removed, and only cfgs on the globbed item itself matter, but I haven't thought through all the details), for non-inlined re-exports see #85043.
The text was updated successfully, but these errors were encountered:
Rollup merge of rust-lang#113091 - GuillaumeGomez:prevent-cfg-merge-reexport, r=rustdoc
Don't merge cfg and doc(cfg) attributes for re-exports
Fixesrust-lang#112881.
## Explanations
When re-exporting things with different `cfg`s there are two things that can happen:
* The re-export uses a subset of `cfg`s, this subset is sufficient so that the item will appear exactly with the subset
* The re-export uses a non-subset of `cfg`s (e.g. like the example I posted just above where the re-export is ungated), if the non-subset `cfg`s are active (e.g. compiling that example on windows) then this will be a compile error as the item doesn't exist to re-export, if the subset `cfg`s are active it behaves like 1.
### Glob re-exports?
**This only applies to non-glob inlined re-exports.** For glob re-exports the item may or may not exist to be re-exported (potentially the `cfg`s on the path up until the glob can be removed, and only `cfg`s on the globbed item itself matter), for non-inlined re-exports see rust-lang#85043.
cc `@Nemo157`
r? `@notriddle`
I tried this code:
I expected to see this happen: The docs show that
a::B
requires the cfga
only.Instead, this happened: The docs show that
a::B
requires the cfga and (a or b)
.Reasoning: When re-exporting things with different cfgs like this there are two things that can happen:
cfg(any(a, c))
onmod a
above), if the non-subset cfgs are active (--cfg=c
) then this will be a compile error as the item doesn't exist to re-export, if the subset cfgs are active it behaves like 1.This only applies to non-glob inlined re-exports, for glob re-exports the item may or may not exist to be re-exported (potentially the cfgs on the path up until the glob can be removed, and only cfgs on the globbed item itself matter, but I haven't thought through all the details), for non-inlined re-exports see #85043.
The text was updated successfully, but these errors were encountered: