diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 26afd705740b2..bfaadc38763c3 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -2471,7 +2471,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
fn render_implementor(
cx: &Context<'_>,
implementor: &Impl,
- parent: &clean::Item,
+ trait_: &clean::Item,
w: &mut Buffer,
implementor_dups: &FxHashMap,
aliases: &[String],
@@ -2491,11 +2491,11 @@ fn render_implementor(
w,
cx,
implementor,
- parent,
+ trait_,
AssocItemLink::Anchor(None),
RenderMode::Normal,
- implementor.impl_item.stable_since(cx.tcx()).as_deref(),
- implementor.impl_item.const_stable_since(cx.tcx()).as_deref(),
+ trait_.stable_since(cx.tcx()).as_deref(),
+ trait_.const_stable_since(cx.tcx()).as_deref(),
false,
Some(use_absolute),
false,
@@ -2934,34 +2934,25 @@ fn render_stability_since_raw(
containing_ver: Option<&str>,
containing_const_ver: Option<&str>,
) {
- let ver = ver.and_then(|inner| if !inner.is_empty() { Some(inner) } else { None });
-
- let const_ver = const_ver.and_then(|inner| if !inner.is_empty() { Some(inner) } else { None });
+ let ver = ver.filter(|inner| !inner.is_empty());
+ let const_ver = const_ver.filter(|inner| !inner.is_empty());
- if let Some(v) = ver {
- if let Some(cv) = const_ver {
- if const_ver != containing_const_ver {
- write!(
- w,
- "{0} (const: {1})",
- v, cv
- );
- } else if ver != containing_ver {
- write!(
- w,
- "{0}",
- v
- );
- }
- } else {
- if ver != containing_ver {
- write!(
- w,
- "{0}",
- v
- );
- }
+ match (ver, const_ver) {
+ (Some(v), Some(cv)) if const_ver != containing_const_ver => {
+ write!(
+ w,
+ "{0} (const: {1})",
+ v, cv
+ );
+ }
+ (Some(v), _) if ver != containing_ver => {
+ write!(
+ w,
+ "{0}",
+ v
+ );
}
+ _ => {}
}
}
diff --git a/src/test/rustdoc/implementor-stable-version.rs b/src/test/rustdoc/implementor-stable-version.rs
new file mode 100644
index 0000000000000..0a065d8095bf2
--- /dev/null
+++ b/src/test/rustdoc/implementor-stable-version.rs
@@ -0,0 +1,19 @@
+#![crate_name = "foo"]
+
+#![feature(staged_api)]
+
+#[stable(feature = "bar", since = "OLD 1.0")]
+pub trait Bar {}
+
+#[stable(feature = "baz", since = "OLD 1.0")]
+pub trait Baz {}
+
+pub struct Foo;
+
+// @has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' 'NEW 2.0'
+#[stable(feature = "foobar", since = "NEW 2.0")]
+impl Bar for Foo {}
+
+// @!has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' 'OLD 1.0'
+#[stable(feature = "foobaz", since = "OLD 1.0")]
+impl Baz for Foo {}