-
Notifications
You must be signed in to change notification settings - Fork 13.5k
get rid of some false negatives in rustdoc::broken_intra_doc_links #132748
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
base: master
Are you sure you want to change the base?
Changes from all commits
ca4b042
53cb8b0
cee9e0a
a20414f
ddd7540
f330a98
e20ff19
6747e21
333f802
5485535
b3fda87
f5df571
32a73bf
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -931,13 +931,20 @@ fn preprocess_link( | |||||||||||||
ori_link: &MarkdownLink, | ||||||||||||||
dox: &str, | ||||||||||||||
) -> Option<Result<PreprocessingInfo, PreprocessingError>> { | ||||||||||||||
// certain link kinds cannot have their path be urls, | ||||||||||||||
// so they should not be ignored, no matter how much they look like urls. | ||||||||||||||
// e.g. [https://example.com/] is not a link to example.com. | ||||||||||||||
let can_be_url = ori_link.kind != LinkType::ShortcutUnknown | ||||||||||||||
&& ori_link.kind != LinkType::CollapsedUnknown | ||||||||||||||
&& ori_link.kind != LinkType::ReferenceUnknown; | ||||||||||||||
|
||||||||||||||
// [] is mostly likely not supposed to be a link | ||||||||||||||
if ori_link.link.is_empty() { | ||||||||||||||
return None; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// Bail early for real links. | ||||||||||||||
if ori_link.link.contains('/') { | ||||||||||||||
if can_be_url && ori_link.link.contains('/') { | ||||||||||||||
return None; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
@@ -962,7 +969,7 @@ fn preprocess_link( | |||||||||||||
Ok(None) => (None, link, link), | ||||||||||||||
Err((err_msg, relative_range)) => { | ||||||||||||||
// Only report error if we would not have ignored this link. See issue #83859. | ||||||||||||||
if !should_ignore_link_with_disambiguators(link) { | ||||||||||||||
if !(can_be_url && should_ignore_link_with_disambiguators(link)) { | ||||||||||||||
let disambiguator_range = match range_between_backticks(&ori_link.range, dox) { | ||||||||||||||
MarkdownLinkRange::Destination(no_backticks_range) => { | ||||||||||||||
MarkdownLinkRange::Destination( | ||||||||||||||
|
@@ -979,7 +986,25 @@ fn preprocess_link( | |||||||||||||
} | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
if should_ignore_link(path_str) { | ||||||||||||||
// If there's no backticks, be lenient revert to old behavior. | ||||||||||||||
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.
Suggested change
I think? |
||||||||||||||
// This is to prevent churn by linting on stuff that isn't meant to be a link. | ||||||||||||||
// only shortcut links have simple enough syntax that they | ||||||||||||||
// are likely to be written accidentlly, collapsed and reference links | ||||||||||||||
// need 4 metachars, and reference links will not usually use | ||||||||||||||
// backticks in the reference name. | ||||||||||||||
// therefore, only shortcut syntax gets the lenient behavior. | ||||||||||||||
// | ||||||||||||||
// here's a truth table for how link kinds that cannot be urls are handled: | ||||||||||||||
// | ||||||||||||||
// |-------------------------------------------------------| | ||||||||||||||
// | | is shortcut link | not shortcut link | | ||||||||||||||
// |--------------|--------------------|-------------------| | ||||||||||||||
// | has backtick | never ignore | never ignore | | ||||||||||||||
// | no backtick | ignore if url-like | never ignore | | ||||||||||||||
// |-------------------------------------------------------| | ||||||||||||||
let ignore_urllike = | ||||||||||||||
can_be_url || (ori_link.kind == LinkType::ShortcutUnknown && !ori_link.link.contains('`')); | ||||||||||||||
if ignore_urllike && should_ignore_link(path_str) { | ||||||||||||||
Comment on lines
+999
to
+1007
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. It looks like the complete truth table is:
Assuming I'm understanding the logic correctly (the difference is to things 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. That is correct. Technically I do explicitly define the scope of the existing table with the line "here's a truth table for how link kinds that cannot be urls are handled:" the line is currently 66 chars long, i should be able to fit in the other case without upsetting tidy (100 char limit), do you want me to? 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. You're right. I should've read it more closely. |
||||||||||||||
return None; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
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.
maybe?