Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only skip impls of foreign unstable traits #74534

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/test/rustdoc/auxiliary/unstable-trait.rs
Original file line number Diff line number Diff line change
@@ -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 {}
11 changes: 11 additions & 0 deletions src/test/rustdoc/hide-unstable-trait.rs
Original file line number Diff line number Diff line change
@@ -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;