]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Link to local reexportations of items
authorAlex Crichton <alex@alexcrichton.com>
Sat, 24 May 2014 02:41:24 +0000 (19:41 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 25 May 2014 08:18:11 +0000 (01:18 -0700)
Within the documentation for a crate, all hyperlinks to reexported items don't
go across crates, but rather to the items in the crate itself. This will allow
references to Option in the standard library to link to the standard library's
Option, instead of libcore's.

This does mean that other crate's links for Option will still link to libcore's
Option.

src/librustdoc/html/format.rs
src/librustdoc/html/render.rs

index e14be8ac6fda2465df0cd489d0aed5d09ba54cc3..d60fe3c03884cbc68f9567daacc5995f94a61e49 100644 (file)
@@ -150,7 +150,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path,
                  print_all: bool) -> fmt::Result {
     path(w, p, print_all,
         |cache, loc| {
-            if ast_util::is_local(did) {
+            if ast_util::is_local(did) || cache.paths.contains_key(&did) {
                 Some(("../".repeat(loc.len())).to_strbuf())
             } else {
                 match *cache.extern_locations.get(&did.krate) {
index 93bd5249a2f71459a074c3e0ccbfa43e71482575..6d6736eac3f31fa56ea02e16c97665ee28683eb4 100644 (file)
@@ -797,6 +797,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                 // not a public item.
                 let id = item.def_id.node;
                 if !self.paths.contains_key(&item.def_id) ||
+                   !ast_util::is_local(item.def_id) ||
                    self.public_items.contains(&id) {
                     self.paths.insert(item.def_id,
                                       (self.stack.clone(), shortty(&item)));