Skip to content

Commit 837d4d8

Browse files
committed
rustdoc: Link to local reexportations of items
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.
1 parent a960670 commit 837d4d8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/librustdoc/html/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, p: &clean::Path,
150150
print_all: bool) -> fmt::Result {
151151
path(w, p, print_all,
152152
|cache, loc| {
153-
if ast_util::is_local(did) {
153+
if ast_util::is_local(did) || cache.paths.contains_key(&did) {
154154
Some(("../".repeat(loc.len())).to_strbuf())
155155
} else {
156156
match *cache.extern_locations.get(&did.krate) {

src/librustdoc/html/render.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ impl DocFolder for Cache {
797797
// not a public item.
798798
let id = item.def_id.node;
799799
if !self.paths.contains_key(&item.def_id) ||
800+
!ast_util::is_local(item.def_id) ||
800801
self.public_items.contains(&id) {
801802
self.paths.insert(item.def_id,
802803
(self.stack.clone(), shortty(&item)));

0 commit comments

Comments
 (0)