Encode cfg trace, not its early counterpart to fix cross-crate doc(auto_cfg)
This commit is contained in:
parent
bc1d7273df
commit
6419f9a9df
8 changed files with 69 additions and 29 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Test covering RFC 3631 features.
|
||||
// Basic tests covering RFC 3631 features.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
#![feature(doc_cfg)]
|
||||
|
|
|
|||
11
tests/rustdoc/inline_cross/auxiliary/doc-auto-cfg.rs
Normal file
11
tests/rustdoc/inline_cross/auxiliary/doc-auto-cfg.rs
Normal file
|
|
@ -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 }
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
pub use default_generic_args::*;
|
||||
53
tests/rustdoc/inline_cross/doc-auto-cfg.rs
Normal file
53
tests/rustdoc/inline_cross/doc-auto-cfg.rs
Normal file
|
|
@ -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: <https://github.com/rust-lang/rust/issues/141301>
|
||||
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: <https://github.com/rust-lang/rust/issues/113982>
|
||||
//@ 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;
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
#![crate_name = "colors"]
|
||||
|
||||
pub struct Color;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue