Fix invalid link generation for type alias methods
This commit is contained in:
parent
69408a877e
commit
a21affabf8
3 changed files with 21 additions and 8 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
tests/rustdoc-gui/type-alias.goml
Normal file
7
tests/rustdoc-gui/type-alias.goml
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue