Fix broken handling of primitive items

- Fix broken handling of primitive associated items
- Remove fragment hack

  Fixes 83083

- more logging
- Update CrateNum hacks

  The CrateNum has no relation to where in the dependency tree the crate
  is, only when it's loaded. Explicitly special-case core instead of
  assuming it will be the first DefId.

- Update and add tests
- Cache calculation of primitive locations

  This could possibly be avoided by passing a Cache into
  collect_intra_doc_links; but that's a much larger change, and doesn't
  seem valuable other than for this.
This commit is contained in:
Joshua Nelson 2021-07-10 22:25:36 -04:00
parent f78acaee03
commit cb7e527692
16 changed files with 144 additions and 165 deletions

View file

@ -509,7 +509,11 @@ crate fn href_with_root_path(
if shortty == ItemType::Module { fqp } else { &fqp[..fqp.len() - 1] }
}
if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private {
if !did.is_local()
&& !cache.access_levels.is_public(did)
&& !cache.document_private
&& !cache.primitive_locations.values().any(|&id| id == did)
{
return Err(HrefError::Private);
}
@ -517,6 +521,7 @@ crate fn href_with_root_path(
let (fqp, shortty, mut url_parts) = match cache.paths.get(&did) {
Some(&(ref fqp, shortty)) => (fqp, shortty, {
let module_fqp = to_module_fqp(shortty, fqp);
debug!(?fqp, ?shortty, ?module_fqp);
href_relative_parts(module_fqp, relative_to)
}),
None => {
@ -548,6 +553,7 @@ crate fn href_with_root_path(
url_parts.insert(0, root);
}
}
debug!(?url_parts);
let last = &fqp.last().unwrap()[..];
let filename;
match shortty {