Add guard to check for local core crate

This commit is contained in:
Seth Pellegrino 2020-07-06 08:46:44 -07:00
parent 81fbfc4059
commit ee3a0f867e

View file

@ -649,14 +649,16 @@ impl Attributes {
if let Some(ref fragment) = *fragment {
let cache = cache();
let url = match cache.extern_locations.get(krate) {
Some(&(_, _, ExternalLocation::Local)) => {
Some(&(ref krate_name, _, ExternalLocation::Local))
if krate_name == "core" =>
{
let depth = CURRENT_DEPTH.with(|l| l.get());
"../".repeat(depth)
}
Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(),
Some(&(_, _, ExternalLocation::Unknown)) | None => {
String::from("https://doc.rust-lang.org/nightly")
}
Some(&(_, _, ExternalLocation::Local))
| Some(&(_, _, ExternalLocation::Unknown))
| None => String::from("https://doc.rust-lang.org/nightly"),
};
// This is a primitive so the url is done "by hand".
let tail = fragment.find('#').unwrap_or_else(|| fragment.len());