Skip to content

Don't emit rustdoc::broken_intra_doc_links for GitHub-flavored Markdown admonitions like [!NOTE] #144921

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

@lolbinarycat lolbinarycat commented Aug 4, 2025

fixes #141866

@rustbot
Copy link
Collaborator

rustbot commented Aug 4, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 4, 2025
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-gfm-141866 branch from 42afec6 to bfea0ee Compare August 4, 2025 19:24
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-gfm-141866 branch 2 times, most recently from a09b688 to fa095a8 Compare August 4, 2025 20:43
@fmease fmease assigned fmease and unassigned notriddle Aug 9, 2025
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some final nits.

@fmease fmease changed the title don't emit rustdoc::broken_intra_doc_links for stuff like [!NOTE] Don't emit rustdoc::broken_intra_doc_links for GitHub-flavored Markdown admonitions like [!NOTE] Aug 9, 2025
@fmease
Copy link
Member

fmease commented Aug 9, 2025

@GuillaumeGomez What do you think about this — frankly — compatibility hack? I'm not super happy that we need to this but that's the real world for you ^^'. Should we FCP this?

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 9, 2025
@GuillaumeGomez
Copy link
Member

We officially support commonmark, so I don't think it's a good idea here. We could however improve the warning to say "this is github-flavored markdown, which is different than the one used in rustdoc: commonmark".

@fmease
Copy link
Member

fmease commented Aug 9, 2025

The problem is that there's no workaround for the user as far as I can tell. There's nothing they could do to their repo README.md that would fix this warning. (Well, they could #![allow(rustdoc::broken_intra_doc_links)] at the … crate root? That's not desirable since it would disable that lint for the whole crate when they just wanted to disable it for their README)

@GuillaumeGomez
Copy link
Member

Oh I see. Hum... Should we make a specific lint for it? Like github_flavored_markdown? Or am I just too picky here and just going through with this PR is good enough?

@fmease
Copy link
Member

fmease commented Aug 9, 2025

Or am I just too picky here and just going through with this PR is good enough?

No, definitely not too picky. Your position is absolutely fair because it could open the floodgates to a never-ending stream of compatibility hacks for GitHub-flavored markdown (esp. since it keeps getting extended). I wonder if we already have hacks like this in rustdoc?

Should we make a specific lint for it? Like github_flavored_markdown?

That sounds like a good solution/compromise! I'm all for a new lint. We probably don't want to have github in its name since I don't think we want to tie ourselves to that platform like that (it might not exist in 10 years time / another platform might become the new 'default' platform with their own flavor of Markdown). Maybe other_flavored_markdown or differently_flavored_markdown (bikesheddable names)?

@GuillaumeGomez
Copy link
Member

non_commonmark_flavored_markdown? =D

@fmease
Copy link
Member

fmease commented Aug 9, 2025

Or simply rustdoc::nonstandard_markdown (borrowing the adjective from nonstandard_style, https://doc.rust-lang.org/rustc/lints/groups.html#lint-groups), maybe that's too vague tho.

Ok, enough of the bikeshedding. Let's wait for binarycat :)

@fmease
Copy link
Member

fmease commented Aug 9, 2025

Unfortunately, even a new lint wouldn't solve the "lint level issue":

#![allow(rustdoc::nonstandard_markdown)] // today: broken_intra_doc_links
#![doc = "> [!NOTE]"] // stand-in for `include_str!("path/to/README.md")`
                      // this one we want to allow
#![deny(rustdoc::nonstandard_markdown)] // today: broken_intra_doc_links
#![doc = "> [!NOTE]"] // this one we don't want to allow

The lower deny overwrites the upper allow because they're at the same module level, so we still flag both.

😩😖

Time for //! <!-- #![allow(rustdoc::nonstandard_markdown)] --> or #![doc(allow(rustdoc::nonstandard_markdown))] /s

@lolbinarycat
Copy link
Contributor Author

My reasoning for adding this logic is it is adding a simple heuristic to a lint that already uses a bunch of heuristics.

I have a number of problems with a nonstandard_markdown:

  1. the name is simply incorrect. rustdoc uses it's own flavor of markdown, from obvious domain-specific things like intra-doc lints, to benign things like footnotes that are not actually in the commonmark spec.
  2. this would be way more likely to lead to more logic for unsupported markdown being added, as people report "false negatives" for the lint.
  3. commonmark, similar to html5, is defined in such a way that every document has an interpretation, so it is not always clear what is intended as using non-standard features. * [x] y could either be a task list, or a reference link to x.

I think if any lint should be added, it should be rustdoc::broken_link_references, as that seems like something that would be desirable to deny in CI in order to make sure no typos slip through, and a decent number of issues get filed complaining about broken references not being denied. This would need to be an allow-by-default lint, at least initially, in order to not cause massive ecosystem churn.

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-gfm-141866 branch from fa095a8 to d2bfea2 Compare August 10, 2025 17:23
@lolbinarycat
Copy link
Contributor Author

addressed feedback from code review

@rustbot review

cc @fmease @GuillaumeGomez

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 10, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2025
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-gfm-141866 branch 2 times, most recently from 127d76f to cd9dad4 Compare August 10, 2025 20:29
@lolbinarycat
Copy link
Contributor Author

Just added a code comment that should hopefully clear up confusion.

The main point is that regardless of what github flavored markdown does, we probably shouldn't be considering these as intra-doc link candidates for the same reason we don't consider links containing spaces to be intra-doc link candidates: item paths will never contain a space or start with a ! (with the exception of the special never type syntax).

@lolbinarycat lolbinarycat force-pushed the rustdoc-intra-doc-gfm-141866 branch from 1c17003 to c022ed9 Compare August 11, 2025 15:50
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=fmease,GuillaumeGomez if GuillaumeGomez also approves of this unfortunate compatibility hack (round two).

Ofc we could also poll this but I'm not sure how long it would take to reach all members (also, I dislike rfcbot poll bc it doesn't discern between "disapprove" and "haven't seen yet").

@GuillaumeGomez
Copy link
Member

Well in this case it's not so much about markdown flavor but rather that we shouldn't try to resolve an intra-doc link starting with ! (and which isn't only !).

@GuillaumeGomez
Copy link
Member

Thanks everyone!

@bors r=fmease,GuillaumeGomez rollup

@bors
Copy link
Collaborator

bors commented Aug 11, 2025

📌 Commit c022ed9 has been approved by fmease,GuillaumeGomez

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 11, 2025
fmease added a commit to fmease/rust that referenced this pull request Aug 11, 2025
…-141866, r=fmease,GuillaumeGomez

Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`

fixes rust-lang#141866
fmease added a commit to fmease/rust that referenced this pull request Aug 12, 2025
…-141866, r=fmease,GuillaumeGomez

Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`

fixes rust-lang#141866
fmease added a commit to fmease/rust that referenced this pull request Aug 12, 2025
…-141866, r=fmease,GuillaumeGomez

Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`

fixes rust-lang#141866
fmease added a commit to fmease/rust that referenced this pull request Aug 12, 2025
…-141866, r=fmease,GuillaumeGomez

Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`

fixes rust-lang#141866
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 15 pull requests

Successful merges:

 - #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
 - #139806 (std: sys: pal: uefi: Overhaul Time)
 - #144386 (Extract TraitImplHeader in AST/HIR)
 - #144542 (Stabilize `sse4a` and `tbm` target features)
 - #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
 - #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
 - #145214 (fix: re-enable self-assignment)
 - #145216 (rustdoc: correct negative-to-implicit discriminant display)
 - #145238 (Tweak invalid builtin attribute output)
 - #145249 (Rename entered trace span variables from `_span` to  `_trace`)
 - #145251 (Support using #[unstable_feature_bound] on trait)
 - #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
 - #145260 (Make explicit guarantees about `Vec`’s allocator)
 - #145263 (Update books)
 - #145273 (Account for new `assert!` desugaring in `!condition` suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
fmease added a commit to fmease/rust that referenced this pull request Aug 12, 2025
…-141866, r=fmease,GuillaumeGomez

Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`

fixes rust-lang#141866
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 14 pull requests

Successful merges:

 - #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
 - #139806 (std: sys: pal: uefi: Overhaul Time)
 - #144210 (std: thread: Return error if setting thread stack size fails)
 - #144386 (Extract TraitImplHeader in AST/HIR)
 - #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
 - #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
 - #145214 (fix: re-enable self-assignment)
 - #145216 (rustdoc: correct negative-to-implicit discriminant display)
 - #145238 (Tweak invalid builtin attribute output)
 - #145249 (Rename entered trace span variables from `_span` to  `_trace`)
 - #145251 (Support using #[unstable_feature_bound] on trait)
 - #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
 - #145263 (Update books)
 - #145273 (Account for new `assert!` desugaring in `!condition` suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 12, 2025
…-141866, r=fmease,GuillaumeGomez

Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`

fixes rust-lang#141866
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 17 pull requests

Successful merges:

 - #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
 - #139806 (std: sys: pal: uefi: Overhaul Time)
 - #144210 (std: thread: Return error if setting thread stack size fails)
 - #144386 (Extract TraitImplHeader in AST/HIR)
 - #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
 - #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
 - #145214 (fix: re-enable self-assignment)
 - #145216 (rustdoc: correct negative-to-implicit discriminant display)
 - #145238 (Tweak invalid builtin attribute output)
 - #145249 (Rename entered trace span variables from `_span` to  `_trace`)
 - #145251 (Support using #[unstable_feature_bound] on trait)
 - #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
 - #145260 (Make explicit guarantees about `Vec`’s allocator)
 - #145263 (Update books)
 - #145273 (Account for new `assert!` desugaring in `!condition` suggestion)
 - #145283 (Make I-miscompile imply I-prioritize)
 - #145291 (bootstrap: Only warn about `rust.debug-assertions` if downloading rustc)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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 reports broken-intra-doc-links for Github-flavored Markdown admonitions like [!IMPORTANT]
7 participants