diff options
| author | bors <bors@rust-lang.org> | 2020-12-11 22:00:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-11 22:00:00 +0000 |
| commit | 9eb3a7ceafd1e2c1924177caa18c7cc0c25b413e (patch) | |
| tree | a68004e4e691ad675d5faa8ef2722ecfd13ba126 /src/test | |
| parent | 2225ee1b62ff089917434aefd9b2bf509cfa087f (diff) | |
| parent | d93f1d6c04fab017a24d868dd766a290321e636c (diff) | |
| download | rust-9eb3a7ceafd1e2c1924177caa18c7cc0c25b413e.tar.gz rust-9eb3a7ceafd1e2c1924177caa18c7cc0c25b413e.zip | |
Auto merge of #79349 - Nemo157:issue-79201, r=jyn514
Apply `doc(cfg)` from parent items while collecting trait impls Because trait impls bypass the standard `clean` hierarchy they do not participate in the `propagate_doc_cfg` pass, so instead we need to pre-collect all possible `doc(cfg)` attributes that will apply to them when cleaning. fixes #79201
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/rustdoc/doc-cfg.rs | 3 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-79201.rs | 41 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/test/rustdoc/doc-cfg.rs b/src/test/rustdoc/doc-cfg.rs index f86541cd118..51a58378299 100644 --- a/src/test/rustdoc/doc-cfg.rs +++ b/src/test/rustdoc/doc-cfg.rs @@ -25,12 +25,13 @@ pub mod unix_only { // @has doc_cfg/unix_only/trait.ArmOnly.html \ // '//*[@id="main"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'This is supported on Unix and ARM only.' - // @count - '//*[@class="stab portability"]' 2 + // @count - '//*[@class="stab portability"]' 1 #[doc(cfg(target_arch = "arm"))] pub trait ArmOnly { fn unix_and_arm_only_function(); } + #[doc(cfg(target_arch = "arm"))] impl ArmOnly for super::Portable { fn unix_and_arm_only_function() {} } diff --git a/src/test/rustdoc/issue-79201.rs b/src/test/rustdoc/issue-79201.rs new file mode 100644 index 00000000000..f95d79cd493 --- /dev/null +++ b/src/test/rustdoc/issue-79201.rs @@ -0,0 +1,41 @@ +#![feature(doc_cfg)] + +// @has 'issue_79201/trait.Foo.html' +// @count - '//*[@class="stab portability"]' 6 +// @matches - '//*[@class="stab portability"]' 'crate feature foo-root' +// @matches - '//*[@class="stab portability"]' 'crate feature foo-public-mod' +// @matches - '//*[@class="stab portability"]' 'crate feature foo-private-mod' +// @matches - '//*[@class="stab portability"]' 'crate feature foo-fn' +// @matches - '//*[@class="stab portability"]' 'crate feature foo-method' + +pub trait Foo {} + +#[doc(cfg(feature = "foo-root"))] +impl crate::Foo for usize {} + +#[doc(cfg(feature = "foo-public-mod"))] +pub mod public { + impl crate::Foo for u8 {} +} + +#[doc(cfg(feature = "foo-private-mod"))] +mod private { + impl crate::Foo for u16 {} +} + +#[doc(cfg(feature = "foo-const"))] +const _: () = { + impl crate::Foo for u32 {} +}; + +#[doc(cfg(feature = "foo-fn"))] +fn __() { + impl crate::Foo for u64 {} +} + +#[doc(cfg(feature = "foo-method"))] +impl dyn Foo { + fn __() { + impl crate::Foo for u128 {} + } +} |
