Skip to content

[rustdoc] Correctly handle "conflict" between markdown case insensitive link definitions - #161785

Open
GuillaumeGomez wants to merge 2 commits into
rust-lang:mainfrom
GuillaumeGomez:md-case-sensitivity
Open

GuillaumeGomez wants to merge 2 commits into
rust-lang:mainfrom
GuillaumeGomez:md-case-sensitivity

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #80882.

The bug itself was pretty straightforward to fix: in case there is no matching (with case-sensitive check) link definition, we first look if it's an intra-doc link, and if not we fall back to the original (case insensitive) markdown handling (which pulldown-cmark does for us).

The tricky part was to make sure that the intra-doc resolution would not emit warnings in this case, which forced me to add a new emit_error field to a few types to handle it.

r? @lolbinarycat

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Aug 25, 2026
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Fixed typo.

@camelid camelid added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Aug 26, 2026
@camelid

camelid commented Aug 26, 2026

Copy link
Copy Markdown
Member

I think this behavior is likely not straightforward to fix. I'd like us to discuss in our team meeting before we move forward with the PR. Or at least I'd like to take a closer look myself first.

@camelid camelid self-assigned this Aug 26, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

We can do both. ;)

@rust-bors

This comment has been minimized.

@camelid camelid added S-waiting-on-t-rustdoc Status: Awaiting decision from T-rustdoc and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 24, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

It was discussed in today's rustdoc meeting and team seems ok with it.

@rustbot

rustbot commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Let's start the FCP then.

@rfcbot fcp merge

@GuillaumeGomez GuillaumeGomez removed the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Nov 10, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

@rfcbot fcp merge

@rust-rfcbot

rust-rfcbot commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

@GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. and removed needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Nov 10, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

As discussed in the last rustdoc team meeting.

@notriddle

Copy link
Copy Markdown
Contributor

@rfcbot concern overloads-an-explicit-link

While I agree that there is a problem worth solving here, the solution in this PR can give results that seem blatantly wrong. Here's an example, written as a rustdoc-html test:

#![crate_name="foo"]

//! Link to a [third-party file][file] and the standard library [macro named file](file).
//!
//! [file]: https://en.wikipedia.org/wiki/File

//@ has 'foo/index.html' '//a[@href="https://en.wikipedia.org/wiki/File"]' 'third-party file'
//@ has 'foo/index.html' '//a[@href="{{channel}}/core/macro.file.html"]' 'macro named file'

This passes on the current version of rustdoc. It fails if I run it on the PR's branch.

7: has check failed
        `XPATH PATTERN` did not match
        //@ has 'foo/index.html' '//a[@href="https://en.wikipedia.org/wiki/File"]' 'third-party file'

Encountered 1 errors

There are two solutions I'm exploring:

  • I've opened a PR against pulldown-cmark to just bite the bullet and add a way to willfully violate commonmark here. That way, we don't have to play games with partial case-sensitivity. It's just case-sensitive.
  • We could, alternatively, write a lint that warns on links that have mismatched case with their refdef, but not actually change the parser. You can always use [inline](intra-doc link) syntax, which doesn't have any special commonmark case folding, to work around this.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-t-rustdoc Status: Awaiting decision from T-rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustdoc: Link references are case-insensitive

7 participants