Skip to content

Conversation

notriddle
Copy link
Contributor

This is the lint described at rust-lang/rust#136308 (comment) that recommends using HTML to nest links inside code.

changelog: [doc_link_code]: warn when a link with code and a code span are back-to-back

@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2025

r? @Centri3

rustbot has assigned @Centri3.
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 Jan 30, 2025
This is the lint described at
rust-lang/rust#136308 (comment)
that recommends using HTML to nest links inside code.
@notriddle
Copy link
Contributor Author

cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

Seems surprising to make it a clippy lint. Why not a rustdoc lint instead?

@notriddle
Copy link
Contributor Author

Implementing it in Clippy gives us a chance to shake out any unforeseen corner cases before uplifting it in Rustdoc.

@Centri3
Copy link
Member

Centri3 commented Feb 8, 2025

Oh gosh, I don't feel qualified for this PR at all. @GuillaumeGomez you're free to review this as you know rustdoc well, otherwise I'll reroll.

@GuillaumeGomez
Copy link
Member

I'll review soon. I'm done on my more pressing stuff. ;)

let mut events = events.peekable();

while let Some((event, range)) = events.next() {
code_cluster = match (code_cluster, &event) {
Copy link
Member

@GuillaumeGomez GuillaumeGomez Feb 10, 2025

Choose a reason for hiding this comment

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

Sorry to say but this but is absolutely unreadable. ^^'

Can't you check the tag instead and see if more than one code (even if embedded into an intra-doc link) instead? Code might be a bit longer but I also expect it to be much simpler to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The simpler way I could come up with to implement this requires the checker to be able to "skip" a Code event.

To do that, I need an entirely separate loop just for this lint. But the code is a lot more readable that way.

By using a separate loop, I can just skip nodes that I don't want
to process twice, instead of having to hand-build a state machine
with an enum.
@GuillaumeGomez
Copy link
Member

This looks much better, thanks!

Looks all good to me @Centri3. :)

@Centri3
Copy link
Member

Centri3 commented Feb 14, 2025

Thanks for reviewing!

@Centri3 Centri3 added this pull request to the merge queue Feb 14, 2025
Merged via the queue into rust-lang:master with commit 50ecb6e Feb 14, 2025
11 checks passed
@notriddle notriddle deleted the codecluster branch February 14, 2025 16:01
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.

4 participants