Skip to content
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
12 changes: 5 additions & 7 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2025,13 +2025,11 @@ fn render_impl(
let mut methods = Vec::new();

if !impl_.is_negative_trait_impl() {
for trait_item in &impl_.items {
match trait_item.kind {
clean::MethodItem(..) | clean::RequiredMethodItem(_) => {
methods.push(trait_item)
}
for impl_item in &impl_.items {
match impl_item.kind {
clean::MethodItem(..) | clean::RequiredMethodItem(_) => methods.push(impl_item),
clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) => {
assoc_types.push(trait_item)
assoc_types.push(impl_item)
}
clean::RequiredAssocConstItem(..)
| clean::ProvidedAssocConstItem(_)
Expand All @@ -2041,7 +2039,7 @@ fn render_impl(
&mut default_impl_items,
&mut impl_items,
cx,
trait_item,
impl_item,
if trait_.is_some() { &i.impl_item } else { parent },
link,
render_mode,
Expand Down
12 changes: 4 additions & 8 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,18 +568,14 @@ impl TypeAliasPart {
if let Some(ret) = &mut ret {
ret.aliases.push(type_alias_fqp);
} else {
let target_did = impl_
.inner_impl()
.trait_
.as_ref()
.map(|trait_| trait_.def_id())
.or_else(|| impl_.inner_impl().for_.def_id(&cx.shared.cache));
let target_trait_did =
impl_.inner_impl().trait_.as_ref().map(|trait_| trait_.def_id());
let provided_methods;
let assoc_link = if let Some(target_did) = target_did {
let assoc_link = if let Some(target_trait_did) = target_trait_did {
provided_methods =
impl_.inner_impl().provided_trait_methods(cx.tcx());
AssocItemLink::GotoSource(
ItemId::DefId(target_did),
ItemId::DefId(target_trait_did),
&provided_methods,
)
} else {
Expand Down
10 changes: 10 additions & 0 deletions tests/rustdoc-gui/src/test_docs/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,13 @@ pub mod tooltips {
Vec::new()
}
}

pub mod tyalias {
pub struct X<T>(pub T);

impl<T: std::fmt::Debug> X<T> {
pub fn blob(&self) {}
}

pub type Y = X<u8>;
}
7 changes: 7 additions & 0 deletions tests/rustdoc-gui/type-alias.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This test ensures that we correctly generate links to methods on type aliases.
go-to: "file://" + |DOC_PATH| + "/test_docs/tyalias/type.Y.html"

// It's generated with JS so we need to wait for it to be done generating.
wait-for: "#implementations"
// We check that it's "#method." and not "#tymethod.".
assert-text: ('#method\.blob a.fn[href="#method.blob"]', "blob")
Loading