Description
Consider the following MWE:
pub trait Foo { fn root(); }
impl Foo for Option<usize> {
fn root() {}
}
Compiling, and navigating to doc/lib/index.html?search=root
shows a clickable core::option::Option::root
result. Clicking on it takes you to doc/core/option/enum.Option.html#method.root
-- the page doesn't exist, however if you've copied in the docs like Servo does, you'll get the following search page and result — the actual trait is here.
Since crates are compiled by rustdoc individually, a cross-crate trait implementation can't show up on the type it is implemented on. However, it still is part of the search results, which is confusing. Removing it from search results isn't an option either — there still is the problem that a doc comment for methods in this impl will not be shown anywhere.
Perhaps cross crate trait implementations should go in the crate of origin of the impl, not the type1? . This will make search results work.
We'd need a new type of doc page for this though -- one that displays a single trait implementation; or alternatively all the trait impls for a type defined outside of a crate. Some sort of "addendum" page.
1. Crate of origin of trait doesn't work either since we can have trait A<T>
from crate a
, type B
from crate b
, and type C
from crate c
, with an impl A<C> for B
in crate c
, which we encounter while compiling crate c
and can no longer touch the docs for crate a
, which is the crate of origin of the trait.