Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass doc cfg to rustc when running cargo doc #12533

Closed
Fryuni opened this issue Aug 20, 2023 · 4 comments
Closed

Pass doc cfg to rustc when running cargo doc #12533

Fryuni opened this issue Aug 20, 2023 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@Fryuni
Copy link

Fryuni commented Aug 20, 2023

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:

@Fryuni Fryuni added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Aug 20, 2023
@Fryuni
Copy link
Author

Fryuni commented Aug 20, 2023

I learned about this on a mostly unrelated issue, but this inconsistency on when and where the doc config is present causes problems when you make a crate re-exporting something using the exact intended, and documented, use case for this cfg.

@fmease
Copy link
Member

fmease commented Aug 29, 2023

I pretty sure that this issue is a duplicate of #8811 which you have already linked. Would you agree?

@Fryuni
Copy link
Author

Fryuni commented Aug 29, 2023

I might be wrong, but it seems to me like it is two different use cases that could be solved by the same solution (passing --cfg doc to rustc).

That one seems to be about dependencies breaking because they behave differently when generating docs while this issue is about the dependent crate breaking (or having incorrect docs) due to a difference in the configs passed to it and its dependencies.

If I understood that incorrectly and they are actually the same problem than sure, we can close this one as duplicate.

@ehuss
Copy link
Contributor

ehuss commented Sep 25, 2023

These do appear to be the same issue to me, so closing in favor of #8811.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants