rustdoc: Fix a couple of issues with src links to external crates
- src links/redirects to extern fn from another crate had an extra '/'. - src links to `pub use` of a crate module had an extra '/'. - src links to renamed reexports from another crate used the new name for the link but should use the original name.
This commit is contained in:
parent
3313e50594
commit
ebfdd110c3
6 changed files with 83 additions and 8 deletions
|
@ -1519,20 +1519,23 @@ impl<'a> Item<'a> {
|
|||
// located, then we return `None`.
|
||||
} else {
|
||||
let cache = cache();
|
||||
let path = match cache.external_paths.get(&self.item.def_id) {
|
||||
let external_path = match cache.external_paths.get(&self.item.def_id) {
|
||||
Some(path) => path,
|
||||
None => return None,
|
||||
};
|
||||
let root = match cache.extern_locations.get(&self.item.def_id.krate) {
|
||||
let mut path = match cache.extern_locations.get(&self.item.def_id.krate) {
|
||||
Some(&(_, Remote(ref s))) => s.to_string(),
|
||||
Some(&(_, Local)) => self.cx.root_path.clone(),
|
||||
Some(&(_, Unknown)) => return None,
|
||||
None => return None,
|
||||
};
|
||||
Some(format!("{root}{path}/{file}?gotosrc={goto}",
|
||||
root = root,
|
||||
path = path[..path.len() - 1].join("/"),
|
||||
file = item_path(shortty(self.item), self.item.name.as_ref().unwrap()),
|
||||
for item in &external_path[..external_path.len() - 1] {
|
||||
path.push_str(item);
|
||||
path.push_str("/");
|
||||
}
|
||||
Some(format!("{path}{file}?gotosrc={goto}",
|
||||
path = path,
|
||||
file = item_path(shortty(self.item), external_path.last().unwrap()),
|
||||
goto = self.item.def_id.index.as_usize()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue