-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix dead link for method in trait of blanket impl from third party crate #86662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
53447d8
fc97fbe
afb5b21
441a350
a75e629
c6ae96d
450c28a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -472,15 +472,27 @@ impl clean::GenericArgs { | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
crate fn href(did: DefId, cx: &Context<'_>) -> Option<(String, ItemType, Vec<String>)> { | ||||||||||||||
// Possible errors when computing href link source for a `DefId` | ||||||||||||||
crate enum HrefError { | ||||||||||||||
/// This item is known to rustdoc, but from a crate that does not have documentation generated. | ||||||||||||||
/// | ||||||||||||||
/// This can only happen for non-local items. | ||||||||||||||
DocumentationNotBuilt, | ||||||||||||||
/// This can only happen for non-local items when `--document-private-items` is not passed. | ||||||||||||||
Private, | ||||||||||||||
// Not in external cache, href link should be in same page | ||||||||||||||
NotInExternalCache, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
crate fn href(did: DefId, cx: &Context<'_>) -> Result<(String, ItemType, Vec<String>), HrefError> { | ||||||||||||||
let cache = &cx.cache(); | ||||||||||||||
let relative_to = &cx.current; | ||||||||||||||
fn to_module_fqp(shortty: ItemType, fqp: &[String]) -> &[String] { | ||||||||||||||
if shortty == ItemType::Module { &fqp[..] } else { &fqp[..fqp.len() - 1] } | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So,
Suggested change
(I know this is unrelated to your change - I can make a separate PR for this if you like.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding this assert made the following tests fail:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahhhh of course it did :( I'll open an issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I was just confused: the proper assert is
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, there was a bug after all: #87048 |
||||||||||||||
return None; | ||||||||||||||
return Err(HrefError::Private); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
let (fqp, shortty, mut url_parts) = match cache.paths.get(&did) { | ||||||||||||||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
@@ -489,22 +501,25 @@ crate fn href(did: DefId, cx: &Context<'_>) -> Option<(String, ItemType, Vec<Str | |||||||||||||
href_relative_parts(module_fqp, relative_to) | ||||||||||||||
}), | ||||||||||||||
None => { | ||||||||||||||
let &(ref fqp, shortty) = cache.external_paths.get(&did)?; | ||||||||||||||
let module_fqp = to_module_fqp(shortty, fqp); | ||||||||||||||
( | ||||||||||||||
fqp, | ||||||||||||||
shortty, | ||||||||||||||
match cache.extern_locations[&did.krate] { | ||||||||||||||
ExternalLocation::Remote(ref s) => { | ||||||||||||||
let s = s.trim_end_matches('/'); | ||||||||||||||
let mut s = vec![&s[..]]; | ||||||||||||||
s.extend(module_fqp[..].iter().map(String::as_str)); | ||||||||||||||
s | ||||||||||||||
} | ||||||||||||||
ExternalLocation::Local => href_relative_parts(module_fqp, relative_to), | ||||||||||||||
ExternalLocation::Unknown => return None, | ||||||||||||||
}, | ||||||||||||||
) | ||||||||||||||
if let Some(&(ref fqp, shortty)) = cache.external_paths.get(&did) { | ||||||||||||||
let module_fqp = to_module_fqp(shortty, fqp); | ||||||||||||||
( | ||||||||||||||
fqp, | ||||||||||||||
shortty, | ||||||||||||||
match cache.extern_locations[&did.krate] { | ||||||||||||||
ExternalLocation::Remote(ref s) => { | ||||||||||||||
let s = s.trim_end_matches('/'); | ||||||||||||||
let mut s = vec![&s[..]]; | ||||||||||||||
s.extend(module_fqp[..].iter().map(String::as_str)); | ||||||||||||||
s | ||||||||||||||
} | ||||||||||||||
ExternalLocation::Local => href_relative_parts(module_fqp, relative_to), | ||||||||||||||
ExternalLocation::Unknown => return Err(HrefError::DocumentationNotBuilt), | ||||||||||||||
}, | ||||||||||||||
) | ||||||||||||||
} else { | ||||||||||||||
return Err(HrefError::NotInExternalCache); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
}; | ||||||||||||||
let last = &fqp.last().unwrap()[..]; | ||||||||||||||
|
@@ -518,7 +533,7 @@ crate fn href(did: DefId, cx: &Context<'_>) -> Option<(String, ItemType, Vec<Str | |||||||||||||
url_parts.push(&filename); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
Some((url_parts.join("/"), shortty, fqp.to_vec())) | ||||||||||||||
Ok((url_parts.join("/"), shortty, fqp.to_vec())) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// Both paths should only be modules. | ||||||||||||||
|
@@ -567,7 +582,7 @@ fn resolved_path<'a, 'cx: 'a>( | |||||||||||||
write!(w, "{}{:#}", &last.name, last.args.print(cx))?; | ||||||||||||||
} else { | ||||||||||||||
let path = if use_absolute { | ||||||||||||||
if let Some((_, _, fqp)) = href(did, cx) { | ||||||||||||||
if let Ok((_, _, fqp)) = href(did, cx) { | ||||||||||||||
format!( | ||||||||||||||
"{}::{}", | ||||||||||||||
fqp[..fqp.len() - 1].join("::"), | ||||||||||||||
|
@@ -675,7 +690,7 @@ crate fn anchor<'a, 'cx: 'a>( | |||||||||||||
) -> impl fmt::Display + 'a { | ||||||||||||||
let parts = href(did.into(), cx); | ||||||||||||||
display_fn(move |f| { | ||||||||||||||
if let Some((url, short_ty, fqp)) = parts { | ||||||||||||||
if let Ok((url, short_ty, fqp)) = parts { | ||||||||||||||
write!( | ||||||||||||||
f, | ||||||||||||||
r#"<a class="{}" href="{}" title="{} {}">{}</a>"#, | ||||||||||||||
|
@@ -907,7 +922,7 @@ fn fmt_type<'cx>( | |||||||||||||
// look at). | ||||||||||||||
box clean::ResolvedPath { did, .. } => { | ||||||||||||||
match href(did.into(), cx) { | ||||||||||||||
Some((ref url, _, ref path)) if !f.alternate() => { | ||||||||||||||
Ok((ref url, _, ref path)) if !f.alternate() => { | ||||||||||||||
write!( | ||||||||||||||
f, | ||||||||||||||
"<a class=\"type\" href=\"{url}#{shortty}.{name}\" \ | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![crate_name = "issue_86620_1"] | ||
|
||
pub trait VZip { | ||
fn vzip() -> usize; | ||
} | ||
|
||
impl<T> VZip for T { | ||
fn vzip() -> usize { | ||
0 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// aux-build:issue-86620-1.rs | ||
|
||
extern crate issue_86620_1; | ||
|
||
use issue_86620_1::*; | ||
|
||
// @!has issue_86620/struct.S.html '//div[@id="method.vzip"]//a[@class="fnname"]/@href' #tymethod.vzip | ||
// @has issue_86620/struct.S.html '//div[@id="method.vzip"]//a[@class="anchor"]/@href' #method.vzip | ||
pub struct S; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would help quite a lot with #82014 I think :) good idea.
(So I remember: the perma-link for this is 8f19606)