Skip to content
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

Rustdoc does not recognize broken reference definition if it contains a hyphen #77845

Closed
bugadani opened this issue Oct 12, 2020 · 2 comments
Closed
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@bugadani
Copy link
Contributor

bugadani commented Oct 12, 2020

Code in question: #77838 (comment)

Expected behaviour: some error pointing to this line, perhaps "no item named cosnt-link in ..."
Instead, nothing happens.

If the link label does not contain a hyphen (-), the expected error is reported.

//! Some broken [ref][link] //~ ERROR no item named
//! One more [broken][another-link] //~ ERROR no item named << this does not report an error currently

/// Some broken [ref][link] //~ ERROR no item named
/// One more [broken][another-link] //~ ERROR no item named << this does not report an error currently
mod something {}
@bugadani bugadani added the C-bug Category: This is a bug. label Oct 12, 2020
@bugadani bugadani changed the title Rustdoc does not report error on broken ref-links in inner doc comments Rustdoc does not recognize broken reference definition if it contains a hyphen Oct 12, 2020
@jonas-schievink jonas-schievink added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Oct 12, 2020
@bugadani
Copy link
Contributor Author

bugadani commented Oct 12, 2020

A brief diagnosis: broken reference-style links are currently (mistakenly?) assumed to be shortcut-links and are retried with the link label as the link itself. Some simpler links are considered by intra-doc-links and are then throws away because they don't point to anything, others, like cosnt-link in the original example are simply ignored, because paths can't contain -.

I believe the assumptions made in the broken link callback are too optimistic:

shortcut_links.push((link.reference.to_owned(), locate(link.reference)));

IMO this should immediately report an error. Shortcut links can only be reference-style, and should not be processed as links themselves.

@jyn514
Copy link
Member

jyn514 commented Oct 12, 2020

Duplicate of #77199

@jyn514 jyn514 marked this as a duplicate of #77199 Oct 12, 2020
@jyn514 jyn514 closed this as completed Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants