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

Add new lint doc_lazy_continuation #12770

Merged
merged 3 commits into from
May 11, 2024

Conversation

notriddle
Copy link
Contributor

changelog: [doc_lazy_continuation]: add lint that warns on so-called "lazy paragraph continuations"

This is a follow-up for rust-lang/rust#121659, since most cases of unintended block quotes are lazy continuations. The lint is designed to be more generally useful than that, though, because it will also catch unintended list items and unintended block quotes that didn't coincidentally hit a pulldown-cmark bug.

The second commit is the result of running cargo dev dogfood --fix, and manually fixing anything that seems wrong. NOTE: this lint's suggestions should never change the parser's interpretation of the markdown, but in many cases, it seems that doc comments in clippy were written without regard for this feature of Markdown (which, I suppose, is why this lint should exist).

@rustbot
Copy link
Collaborator

rustbot commented May 6, 2024

r? @llogiq

rustbot has assigned @llogiq.
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 May 6, 2024
@notriddle notriddle force-pushed the notriddle/doc-lazy-continuation branch from d0a9a7c to 0e67032 Compare May 6, 2024 22:57
This is a follow-up for rust-lang/rust#121659,
since most cases of unintended block quotes are lazy continuations.
The lint is designed to be more generally useful than that, though,
because it will also catch unintended list items and unintended
block quotes that didn't coincidentally hit a pulldown-cmark bug.
@notriddle notriddle force-pushed the notriddle/doc-lazy-continuation branch from 0e67032 to afedaf6 Compare May 6, 2024 23:31
Comment on lines +17 to +29
/// > nest here
/// >
/// > > nest here
/// > lazy continuation
//~^ ERROR: doc quote missing `>` marker
fn two() {}

/// > nest here
/// >
/// > > nest here
/// lazy continuation
//~^ ERROR: doc quote missing `>` marker
fn three() {}
Copy link
Member

Choose a reason for hiding this comment

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

I woud argue the applicability of these (and some other similar test cases below) being MachineAppilcable, maybe the lazy continuation was not a quote, but the user just forgot to add a newline before it, we would never know. Putting it in a nested quote automatically might cause confusion sometimes. 🤔

@llogiq
Copy link
Contributor

llogiq commented May 11, 2024

Thank you for writing this lint. I am usually quite wary when introducing new style (warn by default) lints, but this one positively has my vote of confidence, even if it might lead to some churn.

@bors r+

@bors
Copy link
Collaborator

bors commented May 11, 2024

📌 Commit 133549c has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented May 11, 2024

⌛ Testing commit 133549c with merge 0e5bded...

@bors
Copy link
Collaborator

bors commented May 11, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing 0e5bded to master...

@bors bors merged commit 0e5bded into rust-lang:master May 11, 2024
8 checks passed
@notriddle notriddle deleted the notriddle/doc-lazy-continuation branch May 11, 2024 15:18
@flip1995
Copy link
Member

This lint causes an ICE when checking fuchsia, which was discovered in the latest sync of Clippy in the CI integration test: rust-lang/rust#125202 (comment)

@notriddle can you please look into this?

@notriddle
Copy link
Contributor Author

Addressed by #12818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants