about summary refs log tree commit diff
path: root/tests/rustdoc-ui/doc-cfg-check-cfg.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-03-23 14:59:30 -0400
committerGitHub <noreply@github.com>2025-03-23 14:59:30 -0400
commit856ba39bd969a70f8451ed9d33055a54ddc70fb4 (patch)
tree0439d421d88ea099741aaba4a724a91a55bed04d /tests/rustdoc-ui/doc-cfg-check-cfg.rs
parentd7c5f5f3196c568c3b5fb3426abe79507a6a0349 (diff)
parent85b1116a18595794da07c53642eefd81ff775faf (diff)
downloadrust-856ba39bd969a70f8451ed9d33055a54ddc70fb4.tar.gz
rust-856ba39bd969a70f8451ed9d33055a54ddc70fb4.zip
Rollup merge of #138293 - clubby789:doc-cfg-gate, r=GuillaumeGomez
rustdoc: Gate unstable `doc(cfg())` predicates

Fixes #138113

Since the extraction process treats `cfg(true)` as having no cfg attribute, we have to do the gating during parsing; so we remove the unused `features` arg from `Cfg::matches`
Diffstat (limited to 'tests/rustdoc-ui/doc-cfg-check-cfg.rs')
-rw-r--r--tests/rustdoc-ui/doc-cfg-check-cfg.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/doc-cfg-check-cfg.rs b/tests/rustdoc-ui/doc-cfg-check-cfg.rs
new file mode 100644
index 00000000000..e3420dc0789
--- /dev/null
+++ b/tests/rustdoc-ui/doc-cfg-check-cfg.rs
@@ -0,0 +1,16 @@
+// Ensure that `doc(cfg())` respects `check-cfg`
+// Currently not properly working
+#![feature(doc_cfg)]
+#![deny(unexpected_cfgs)]
+
+//@revisions: no_check cfg_empty cfg_foo
+//@[cfg_empty] compile-flags: --check-cfg cfg()
+//@[cfg_foo] compile-flags: --check-cfg cfg(foo)
+
+//@[no_check] check-pass
+//@[cfg_empty] check-pass
+//@[cfg_empty] known-bug: #138358
+//@[cfg_foo] check-pass
+
+#[doc(cfg(foo))]
+pub fn foo() {}