Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustdoc/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ pub(crate) enum Condition {
pub(crate) const PASSES: &[Pass] = &[
CHECK_DOC_CFG,
CHECK_DOC_TEST_VISIBILITY,
PROPAGATE_DOC_CFG,
STRIP_ALIASED_NON_LOCAL,
STRIP_HIDDEN,
STRIP_PRIVATE,
STRIP_PRIV_IMPORTS,
PROPAGATE_DOC_CFG,
PROPAGATE_STABILITY,
COLLECT_INTRA_DOC_LINKS,
COLLECT_TRAIT_IMPLS,
Expand All @@ -94,11 +94,11 @@ pub(crate) const DEFAULT_PASSES: &[ConditionalPass] = &[
ConditionalPass::always(COLLECT_TRAIT_IMPLS),
ConditionalPass::always(CHECK_DOC_TEST_VISIBILITY),
ConditionalPass::always(CHECK_DOC_CFG),
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
ConditionalPass::always(STRIP_ALIASED_NON_LOCAL),
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
ConditionalPass::new(STRIP_PRIV_IMPORTS, WhenDocumentPrivate),
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
Copy link
Member

@fmease fmease Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisiting thus due to ojeda's comment. Moving the intra-doc link pass before the strippers seems very much like a mistake.

I believe this PR was a response to my review comment #138907 (comment) in which I requested to move the doc cfg propagation pass before the strippers.

I haven't tried it out yet but that review comment wasn't properly addressed then.

(You did also change the ordering in PASSES but that's only used in the --help usage output IIRC)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the added test also work before this PR?

ConditionalPass::always(PROPAGATE_DOC_CFG),
ConditionalPass::always(PROPAGATE_STABILITY),
ConditionalPass::always(RUN_LINTS),
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-ui/issues/issue-91713.stdout
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Available passes for running rustdoc:
check-doc-cfg - checks `#[doc(cfg(...))]` for stability feature and unexpected cfgs
check_doc_test_visibility - run various visibility-related lints on doctests
propagate-doc-cfg - propagates `#[doc(cfg(...))]` to child items
strip-aliased-non-local - strips all non-local private aliased items from the output
strip-hidden - strips all `#[doc(hidden)]` items from the output
strip-private - strips all private items from a crate which cannot be seen externally, implies strip-priv-imports
strip-priv-imports - strips all private import statements (`use`, `extern crate`) from a crate
propagate-doc-cfg - propagates `#[doc(cfg(...))]` to child items
propagate-stability - propagates stability to child items
collect-intra-doc-links - resolves intra-doc links
collect-trait-impls - retrieves trait impls for items in the crate
Expand All @@ -16,11 +16,11 @@ Default passes for rustdoc:
collect-trait-impls
check_doc_test_visibility
check-doc-cfg
collect-intra-doc-links
strip-aliased-non-local
strip-hidden (when not --document-hidden-items)
strip-private (when not --document-private-items)
strip-priv-imports (when --document-private-items)
collect-intra-doc-links
propagate-doc-cfg
propagate-stability
run-lints
Expand Down
16 changes: 16 additions & 0 deletions tests/rustdoc/doc-auto-cfg-public-in-private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This test ensures that even though private items are removed from generated docs,
// their `cfg`s will still impact their child items.

#![feature(doc_cfg)]
#![crate_name = "foo"]

pub struct X;

#[cfg(not(feature = "blob"))]
fn foo() {
impl X {
//@ has 'foo/struct.X.html'
//@ has - '//*[@class="stab portability"]' 'Available on non-crate feature blob only.'
pub fn bar() {}
}
}
Loading