Skip to content

Pass doc cfg to rustc when running cargo doc #12533

Closed as not planned
Closed as not planned
@Fryuni

Description

@Fryuni

Problem

From the issue originally reported to rustdoc by @notriddle:

I tried this code:

// crate a
pub struct MyStruct;
#[cfg(doc)]
impl MyStruct {
    pub fn doc_only_method() {}
}

// crate b
#[doc(inline)]
pub use a::MyStruct;

I expected to see this happen: I expected doc_only_method to appear in crate b

Instead, this happened: It didn't.


Proposed Solution

Rustdoc adds the doc cfg before generating the docs for a crate (here), but the metadata from dependencies are generated using rustc without such flag, causing the problem above.

cargo doc should add the cfg to the rustc calls that generate the metadata passed to rustdoc.

Notes

A few possibly related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions