Skip to content

Commit 27b0018

Browse files
authored
Rollup merge of #147809 - GuillaumeGomez:fix-rustdoc-passes, r=fmease
rustdoc: Fix passes order so intra-doc links are collected after stripping passes Fixes regression I introduced in #147153. This PR puts back the intra-doc link collecting pass after the stripping items pass, preventing lints to be emitted on non-visible items. Although, might be nice to add a way to change this behaviour. To be discussed later on. cc ``@ojeda`` r? ``@fmease``
2 parents 7fa2030 + b3bb750 commit 27b0018

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

src/librustdoc/passes/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ pub(crate) const DEFAULT_PASSES: &[ConditionalPass] = &[
9494
ConditionalPass::always(COLLECT_TRAIT_IMPLS),
9595
ConditionalPass::always(CHECK_DOC_TEST_VISIBILITY),
9696
ConditionalPass::always(CHECK_DOC_CFG),
97-
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
9897
ConditionalPass::always(STRIP_ALIASED_NON_LOCAL),
9998
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
10099
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
101100
ConditionalPass::new(STRIP_PRIV_IMPORTS, WhenDocumentPrivate),
101+
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
102102
ConditionalPass::always(PROPAGATE_DOC_CFG),
103103
ConditionalPass::always(PROPAGATE_STABILITY),
104104
ConditionalPass::always(RUN_LINTS),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test ensures that `doc(hidden)` items intra-doc links are checked whereas private
2+
// items are ignored.
3+
4+
//@ compile-flags: -Zunstable-options --document-hidden-items
5+
6+
#![deny(rustdoc::broken_intra_doc_links)]
7+
8+
/// [not::exist]
9+
//~^ ERROR unresolved link to `not::exist`
10+
#[doc(hidden)]
11+
pub struct X;
12+
13+
/// [not::exist]
14+
struct Y;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unresolved link to `not::exist`
2+
--> $DIR/hidden-check.rs:8:6
3+
|
4+
LL | /// [not::exist]
5+
| ^^^^^^^^^^ no item named `not` in scope
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/hidden-check.rs:6:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test ensures that private items intra-doc links are checked whereas `doc(hidden)`
2+
// items are ignored.
3+
4+
//@ compile-flags: -Zunstable-options --document-private-items
5+
6+
#![deny(rustdoc::broken_intra_doc_links)]
7+
8+
/// [not::exist]
9+
#[doc(hidden)]
10+
pub struct X;
11+
12+
/// [not::exist]
13+
//~^ ERROR unresolved link to `not::exist`
14+
struct Y;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unresolved link to `not::exist`
2+
--> $DIR/private-check.rs:12:6
3+
|
4+
LL | /// [not::exist]
5+
| ^^^^^^^^^^ no item named `not` in scope
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/private-check.rs:6:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+

tests/rustdoc-ui/issues/issue-91713.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ Default passes for rustdoc:
1616
collect-trait-impls
1717
check_doc_test_visibility
1818
check-doc-cfg
19-
collect-intra-doc-links
2019
strip-aliased-non-local
2120
strip-hidden (when not --document-hidden-items)
2221
strip-private (when not --document-private-items)
2322
strip-priv-imports (when --document-private-items)
23+
collect-intra-doc-links
2424
propagate-doc-cfg
2525
propagate-stability
2626
run-lints

0 commit comments

Comments
 (0)