[rustdoc] Check doc(cfg()) even of private/hidden items
This commit is contained in:
@@ -95,11 +95,11 @@ pub(crate) const DEFAULT_PASSES: &[ConditionalPass] = &[
|
|||||||
ConditionalPass::always(CHECK_DOC_TEST_VISIBILITY),
|
ConditionalPass::always(CHECK_DOC_TEST_VISIBILITY),
|
||||||
ConditionalPass::always(CHECK_DOC_CFG),
|
ConditionalPass::always(CHECK_DOC_CFG),
|
||||||
ConditionalPass::always(STRIP_ALIASED_NON_LOCAL),
|
ConditionalPass::always(STRIP_ALIASED_NON_LOCAL),
|
||||||
|
ConditionalPass::always(PROPAGATE_DOC_CFG),
|
||||||
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
|
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
|
||||||
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
|
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
|
||||||
ConditionalPass::new(STRIP_PRIV_IMPORTS, WhenDocumentPrivate),
|
ConditionalPass::new(STRIP_PRIV_IMPORTS, WhenDocumentPrivate),
|
||||||
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
|
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
|
||||||
ConditionalPass::always(PROPAGATE_DOC_CFG),
|
|
||||||
ConditionalPass::always(PROPAGATE_STABILITY),
|
ConditionalPass::always(PROPAGATE_STABILITY),
|
||||||
ConditionalPass::always(RUN_LINTS),
|
ConditionalPass::always(RUN_LINTS),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,3 +2,20 @@
|
|||||||
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
|
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
|
||||||
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
|
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
|
||||||
pub struct S {}
|
pub struct S {}
|
||||||
|
|
||||||
|
// We check it also fails on private items.
|
||||||
|
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
|
||||||
|
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
|
||||||
|
struct X {}
|
||||||
|
|
||||||
|
// We check it also fails on hidden items.
|
||||||
|
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
|
||||||
|
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub struct Y {}
|
||||||
|
|
||||||
|
// We check it also fails on hidden AND private items.
|
||||||
|
#[doc(cfg = "x")] //~ ERROR not followed by parentheses
|
||||||
|
#[doc(cfg(x, y))] //~ ERROR multiple `cfg` predicates
|
||||||
|
#[doc(hidden)]
|
||||||
|
struct Z {}
|
||||||
|
|||||||
@@ -10,5 +10,41 @@ error: multiple `cfg` predicates are specified
|
|||||||
LL | #[doc(cfg(x, y))]
|
LL | #[doc(cfg(x, y))]
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: `cfg` is not followed by parentheses
|
||||||
|
--> $DIR/invalid-cfg.rs:7:7
|
||||||
|
|
|
||||||
|
LL | #[doc(cfg = "x")]
|
||||||
|
| ^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
|
||||||
|
|
||||||
|
error: multiple `cfg` predicates are specified
|
||||||
|
--> $DIR/invalid-cfg.rs:8:14
|
||||||
|
|
|
||||||
|
LL | #[doc(cfg(x, y))]
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: `cfg` is not followed by parentheses
|
||||||
|
--> $DIR/invalid-cfg.rs:12:7
|
||||||
|
|
|
||||||
|
LL | #[doc(cfg = "x")]
|
||||||
|
| ^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
|
||||||
|
|
||||||
|
error: multiple `cfg` predicates are specified
|
||||||
|
--> $DIR/invalid-cfg.rs:13:14
|
||||||
|
|
|
||||||
|
LL | #[doc(cfg(x, y))]
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: `cfg` is not followed by parentheses
|
||||||
|
--> $DIR/invalid-cfg.rs:18:7
|
||||||
|
|
|
||||||
|
LL | #[doc(cfg = "x")]
|
||||||
|
| ^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
|
||||||
|
|
||||||
|
error: multiple `cfg` predicates are specified
|
||||||
|
--> $DIR/invalid-cfg.rs:19:14
|
||||||
|
|
|
||||||
|
LL | #[doc(cfg(x, y))]
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ Default passes for rustdoc:
|
|||||||
check_doc_test_visibility
|
check_doc_test_visibility
|
||||||
check-doc-cfg
|
check-doc-cfg
|
||||||
strip-aliased-non-local
|
strip-aliased-non-local
|
||||||
|
propagate-doc-cfg
|
||||||
strip-hidden (when not --document-hidden-items)
|
strip-hidden (when not --document-hidden-items)
|
||||||
strip-private (when not --document-private-items)
|
strip-private (when not --document-private-items)
|
||||||
strip-priv-imports (when --document-private-items)
|
strip-priv-imports (when --document-private-items)
|
||||||
collect-intra-doc-links
|
collect-intra-doc-links
|
||||||
propagate-doc-cfg
|
|
||||||
propagate-stability
|
propagate-stability
|
||||||
run-lints
|
run-lints
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user