mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Fix invalid link generation for type alias methods
This commit is contained in:
@@ -568,18 +568,14 @@ fn get(
|
||||
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 fn bar() -> Vec<u8> {
|
||||
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>;
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
Reference in New Issue
Block a user