diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index e6a10c47497b..a70160754072 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -867,10 +867,10 @@ fn render_assoc_item(
ItemType::TyMethod
};
- match href(did.expect_def_id(), cx) {
- Ok(p) => Some(format!("{}#{}.{}", p.0, ty, name)),
- Err(HrefError::DocumentationNotBuilt) => None,
- Err(_) => Some(format!("#{}.{}", ty, name)),
+ match (href(did.expect_def_id(), cx), ty) {
+ (Ok(p), ty) => Some(format!("{}#{}.{}", p.0, ty, name)),
+ (Err(HrefError::DocumentationNotBuilt), ItemType::TyMethod) => None,
+ (Err(_), ty) => Some(format!("#{}.{}", ty, name)),
}
}
};