diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-19 19:12:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-19 19:12:43 -0700 |
| commit | e8fc9934097e67c3f3fe11874ad2a89694a80bf2 (patch) | |
| tree | 38ae37336d64597206b06f114752027ecc6d5387 | |
| parent | 42273f6537ebf9f0cf35a7281789bb7eb50a59fd (diff) | |
| parent | e24a0172b0df21b0bc17f3c9a16773d8889dd2b1 (diff) | |
| download | rust-e8fc9934097e67c3f3fe11874ad2a89694a80bf2.tar.gz rust-e8fc9934097e67c3f3fe11874ad2a89694a80bf2.zip | |
Rollup merge of #74534 - Mark-Simulacrum:rustdoc-stability, r=Manishearth
Only skip impls of foreign unstable traits Previously unstable impls were skipped, which meant that any impl with an unstable method would get skipped. Fixes #74531.
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 8 | ||||
| -rw-r--r-- | src/test/rustdoc/auxiliary/unstable-trait.rs | 26 | ||||
| -rw-r--r-- | src/test/rustdoc/hide-unstable-trait.rs | 11 |
3 files changed, 42 insertions, 3 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 491daa80e5c..1f576a17dd9 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -346,9 +346,11 @@ pub fn build_impl( // such. This helps prevent dependencies of the standard library, for // example, from getting documented as "traits `u32` implements" which // isn't really too helpful. - if let Some(stab) = cx.tcx.lookup_stability(did) { - if stab.level.is_unstable() { - return; + if let Some(trait_did) = associated_trait { + if let Some(stab) = cx.tcx.lookup_stability(trait_did.def_id) { + if stab.level.is_unstable() { + return; + } } } } diff --git a/src/test/rustdoc/auxiliary/unstable-trait.rs b/src/test/rustdoc/auxiliary/unstable-trait.rs new file mode 100644 index 00000000000..6f06a6e2656 --- /dev/null +++ b/src/test/rustdoc/auxiliary/unstable-trait.rs @@ -0,0 +1,26 @@ +#![feature(staged_api)] +#![stable(feature = "private_general", since = "1.0.0")] + +#[unstable(feature = "private_trait", issue = "none")] +pub trait Bar {} + +#[stable(feature = "private_general", since = "1.0.0")] +pub struct Foo { + // nothing +} + +impl Foo { + #[stable(feature = "private_general", since = "1.0.0")] + pub fn stable_impl() {} +} + +impl Foo { + #[unstable(feature = "private_trait", issue = "none")] + pub fn bar() {} + + #[stable(feature = "private_general", since = "1.0.0")] + pub fn bar2() {} +} + +#[stable(feature = "private_general", since = "1.0.0")] +impl Bar for Foo {} diff --git a/src/test/rustdoc/hide-unstable-trait.rs b/src/test/rustdoc/hide-unstable-trait.rs new file mode 100644 index 00000000000..c30d6ed7b52 --- /dev/null +++ b/src/test/rustdoc/hide-unstable-trait.rs @@ -0,0 +1,11 @@ +// aux-build:unstable-trait.rs + +#![crate_name = "foo"] +#![feature(private_trait)] + +extern crate unstable_trait; + +// @has foo/struct.Foo.html 'bar' +// @has foo/struct.Foo.html 'bar2' +#[doc(inline)] +pub use unstable_trait::Foo; |
