ty
);
// Fast path: if this is a primitive simple `==` will work
- let saw_impl = impl_type == ty;
+ // NOTE: the `match` is necessary; see #92662.
+ // this allows us to ignore generics because the user input
+ // may not include the generic placeholders
+ // e.g. this allows us to match Foo (user comment) with Foo<T> (actual type)
+ let saw_impl = impl_type == ty
+ || match (impl_type.kind(), ty.kind()) {
+ (ty::Adt(impl_def, _), ty::Adt(ty_def, _)) => {
+ debug!("impl def_id: {:?}, ty def_id: {:?}", impl_def.did, ty_def.did);
+ impl_def.did == ty_def.did
+ }
+ _ => false,
+ };
if saw_impl { Some(trait_) } else { None }
})
--- /dev/null
+#![deny(rustdoc::broken_intra_doc_links)]
+
+// Test intra-doc links on trait implementations with generics
+
+use std::marker::PhantomData;
+
+pub trait Bar<T> {
+ fn bar(&self);
+}
+
+pub struct Foo<U>(PhantomData<U>);
+
+impl<T, U> Bar<T> for Foo<U> {
+ fn bar(&self) {}
+}
+
+// @has generic_trait_impl/fn.main.html '//a[@href="struct.Foo.html#method.bar"]' 'Foo::bar'
+/// link to [`Foo::bar`]
+pub fn main() {}