Fleshing out libstd "scenarios"

One thing that came up in the lang meeting: we can teach the compiler about items that have been cfg-ed out, including other definitions of the same item.

While cfg-polymorphic compilation would be difficult because the choices would have to end up in types and in the MIR, reasoning about the conditional existence of public definitions and tainting other public definitions which use them, transitively, would be a fairly routine analysis.

A tool like rustdoc could display all possible public definitions, and provide links to docs of different platform-specific configurations of the same crate. The cfg dependencies observed can be used to check that these docs aren’t missing.

For definitions that might not survive codegen / linking, but otherwise type-check fine, we could just not cfg them out, but keep some annotation around to prevent ever instantiating them accidentally (mostly thinking of imperfect compiler checks here).

3 Likes