diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index a2acac8b3045d..dddd1be9648bf 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -425,7 +425,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ List: &["predicate"], "https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute" ), - DuplicatesOk, EncodeCrossCrate::Yes + DuplicatesOk, EncodeCrossCrate::No ), ungated!( cfg_attr, Normal, @@ -433,7 +433,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ List: &["predicate, attr1, attr2, ..."], "https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute" ), - DuplicatesOk, EncodeCrossCrate::Yes + DuplicatesOk, EncodeCrossCrate::No ), // Testing: @@ -1100,7 +1100,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // can only be generated by the compiler. ungated!( cfg_trace, Normal, template!(Word /* irrelevant */), DuplicatesOk, - EncodeCrossCrate::No + EncodeCrossCrate::Yes ), ungated!( cfg_attr_trace, Normal, template!(Word /* irrelevant */), DuplicatesOk, diff --git a/tests/rustdoc/doc_auto_cfg.rs b/tests/rustdoc/doc_auto_cfg.rs index 19ef174c1778d..a1903e1a0ca3d 100644 --- a/tests/rustdoc/doc_auto_cfg.rs +++ b/tests/rustdoc/doc_auto_cfg.rs @@ -1,4 +1,4 @@ -// Test covering RFC 3631 features. +// Basic tests covering RFC 3631 features. #![crate_name = "foo"] #![feature(doc_cfg)] diff --git a/tests/rustdoc/inline_cross/auxiliary/doc-auto-cfg.rs b/tests/rustdoc/inline_cross/auxiliary/doc-auto-cfg.rs new file mode 100644 index 0000000000000..b494b701a2ffb --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/doc-auto-cfg.rs @@ -0,0 +1,11 @@ +//@ compile-flags: --cfg extension + +#[cfg(extension)] +pub fn compute() {} + +pub struct Type; + +impl Type { + #[cfg(extension)] + pub fn transform(self) -> Self { self } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs b/tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs deleted file mode 100644 index a742dd7d865f1..0000000000000 --- a/tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs +++ /dev/null @@ -1 +0,0 @@ -pub use default_generic_args::*; diff --git a/tests/rustdoc/inline_cross/doc-auto-cfg.rs b/tests/rustdoc/inline_cross/doc-auto-cfg.rs new file mode 100644 index 0000000000000..6e0f6e22f8c78 --- /dev/null +++ b/tests/rustdoc/inline_cross/doc-auto-cfg.rs @@ -0,0 +1,53 @@ +// Test that `doc(auto_cfg)` works with inlined cross-crate re-exports. +//@ compile-flags: --cfg feature="extra" --cfg feature="addon" + +#![feature(doc_cfg)] +#![crate_name = "it"] + +//@ aux-build: doc-auto-cfg.rs +extern crate doc_auto_cfg; + +// The cfg is on the reexported item. +// issue: +pub mod pre { + //@ has 'it/pre/index.html' '//*[@class="stab portability"]' 'extension' + //@ has 'it/pre/fn.compute.html' '//*[@class="stab portability"]' \ + // 'Available on extension only.' + pub use doc_auto_cfg::*; + + // Indeed, this reexport doesn't have a cfg badge! + // That's because this crate (`it`) wouldn't've compiled in the first place + // if `--cfg extension` wasn't passed when compiling the auxiliary crate + // contrary to the glob import above since `compute` wouldn't exist. + // + //@ !has 'it/pre/fn.calculate.html' '//*[@class="stab portability"]' \ + // 'Available on extension only.' + pub use doc_auto_cfg::compute as calculate; + + // FIXME(HtmlDocCk): Ideally I would've used the following XPath here: + // `*[@class="impl-items"][*[@id="method.transform"]]//*[@class="stab portability"]` + // + //@ has 'it/pre/struct.Kind.html' '//*[@id="method.transform"]' '' + //@ has - '//*[@class="impl-items"]//*[@class="stab portability"]' \ + // 'Available on extension only.' + pub use doc_auto_cfg::Type as Kind; +} + +// The cfg is on the reexport. +pub mod post { + // issue: + //@ has 'it/post/index.html' '//*[@class="stab portability"]' 'extra' + //@ has - '//*[@class="stab portability"]' 'extra and extension' + //@ has 'it/post/struct.Type.html' '//*[@class="stab portability"]' \ + // 'Available on crate feature extra only.' + //@ has 'it/post/fn.compute.html' '//*[@class="stab portability"]' \ + // 'Available on crate feature extra and extension only.' + #[cfg(feature = "extra")] + pub use doc_auto_cfg::*; + + //@ has 'it/post/index.html' '//*[@class="stab portability"]' 'addon' + //@ has 'it/post/struct.Addon.html' '//*[@class="stab portability"]' \ + // 'Available on crate feature addon only.' + #[cfg(feature = "addon")] + pub use doc_auto_cfg::Type as Addon; +} diff --git a/tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs deleted file mode 100644 index a1a716f5a41be..0000000000000 --- a/tests/rustdoc/reexport/auxiliary/issue-113982-doc_auto_cfg-reexport-foreign.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_name = "colors"] - -pub struct Color; diff --git a/tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs b/tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs deleted file mode 100644 index f8ec4afc0313e..0000000000000 --- a/tests/rustdoc/reexport/doc_auto_cfg-reexport-foreign-113982.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs - -// https://github.com/rust-lang/rust/issues/113982 -#![feature(no_core, doc_cfg)] -#![no_core] -#![crate_name = "foo"] - -extern crate colors; - -//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-colors' -//@ has 'foo/struct.Color.html' '//*[@class="stab portability"]' \ -// 'Available on non-crate feature colors only.' -#[cfg(not(feature = "colors"))] -pub use colors::*; - -//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-fruits' -//@ has 'foo/struct.Red.html' '//*[@class="stab portability"]' \ -// 'Available on non-crate feature fruits only.' -#[cfg(not(feature = "fruits"))] -pub use colors::Color as Red; diff --git a/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs b/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs index 0aed2b0c46208..b0f7df6f3e2d4 100644 --- a/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs +++ b/tests/rustdoc/reexport/glob-reexport-attribute-merge-doc-auto-cfg.rs @@ -1,4 +1,4 @@ -// This test ensures that non-glob reexports don't get their attributes merge with +// This test ensures that non-glob reexports don't get their attributes merged with // the reexported item whereas glob reexports do with the `doc_auto_cfg` feature. #![crate_name = "foo"]