Closed
Description
I tried this code:
#![feature(doc_auto_cfg)]
#[cfg(a)]
pub mod a {
pub use crate::b::B;
}
#[cfg(any(a, b))]
mod b {
pub struct B;
}
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))
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.