Skip to content

doc_suspicious_footnotes: lint text that looks like a footnote #14708

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 2 commits into
base: master
Choose a base branch
from

Conversation

notriddle
Copy link
Contributor

changelog: [doc_suspicious_footnotes]: lint for text that looks like a footnote reference but has no definition

This is an alternative to rust-lang/rust#137803, meant to address the concerns about false positives.

This lint only fires when the apparent footnote reference has a name that's made from pure ASCII digits. This choice is justified by running lintcheck on the top 200 crates, plus the clippy default set:

  1. I ran lintcheck with a modded version of this lint that didn't check for digits only. It produced a false positive warning on a line in mdbook that had a regex, and no true positives at all.
  2. I also ran lintcheck with a custom lint that fired on any valid footnote reference with a non-ascii-digit name. cargo uses one in its job_queue module, and that's all it found.

cc @GuillaumeGomez

@rustbot
Copy link
Collaborator

rustbot commented Apr 29, 2025

r? @blyxyas

rustbot has assigned @blyxyas.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 29, 2025
@notriddle notriddle force-pushed the doc_suspicious_footnotes branch from 9f74df2 to c56ef28 Compare April 29, 2025 23:48
@notriddle notriddle force-pushed the doc_suspicious_footnotes branch from c56ef28 to 1356e76 Compare April 29, 2025 23:50
@GuillaumeGomez
Copy link
Member

Looks good to me, thanks!

r? samueltardieu

@rustbot
Copy link
Collaborator

rustbot commented May 2, 2025

samueltardieu is on vacation.

Please choose another assignee.

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

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

Great initial patch (and a really good lint idea 👍)! I left some suggestions and some questions.

///
/// This is a footnote[^2].
///
/// [^2]: hello world
Copy link
Member

Choose a reason for hiding this comment

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

Could this also check for #![doc], //!, #[doc] and the include!s macros?

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels May 4, 2025
@notriddle
Copy link
Contributor Author

@blyxyas Okay, I've implemented variants on all your suggestions.

@notriddle notriddle force-pushed the doc_suspicious_footnotes branch from b0e3325 to 99b16ae Compare May 5, 2025 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants