Fix four_forward_slashes false positive on inner doc comments#17448
Open
zakrad wants to merge 1 commit into
Open
Fix four_forward_slashes false positive on inner doc comments#17448zakrad wants to merge 1 commit into
four_forward_slashes false positive on inner doc comments#17448zakrad wants to merge 1 commit into
Conversation
Collaborator
|
Thanks for the pull request, and welcome! You should hear from one of our reviewers after this PR gets at least 2 reviews from the community. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
The lint computes the item's end line from a span folded over the item's doc-comment attributes, then scans the lines above for `////`. The fold previously included inner doc comments (`//!`); an inner doc inside the body lowers onto the item with `AttrStyle::Inner`, so folding its span pushed the end line down into the body and the upward scan flagged a regular `////` comment there — whose suggested fix (`///`) then fails to compile. Fold in outer doc comments only, mirroring the pattern in `doc/suspicious_doc_comments.rs`.
zakrad
force-pushed
the
fix-16168-inner-doc-comments
branch
from
July 23, 2026 22:06
baa9f90 to
4d9d3f8
Compare
DanielEScherzer
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
four_forward_slashesscans the lines above an item for////comments and suggests turning them into///. It derives the item's start line from a span folded over the item's doc-comment attributes, but that fold included inner doc comments (//!).An inner
//!inside a body lowers onto the item withAttrStyle::Inner; folding its span pushes the item's end line down into the body, so the upward scan then flags a regular////comment there. Applying the suggestion rewrites it to///, which documents nothing and fails to compile (E0585).Repro from the issue:
Fix: fold in outer doc comments only, mirroring the existing pattern in
clippy_lints/src/doc/suspicious_doc_comments.rs. A genuine////typo above an item still lints, and I added a regression test for the inner-doc case.Fixes #16168
changelog: [
four_forward_slashes]: no longer fires on////comments that sit above an inner doc comment (//!) in an item's bodyDisclosure: I used AI assistance to help diagnose the root cause and draft this change. It's a small, self-contained fix that I've reviewed, tested locally (
cargo uitest+cargo dev fmt), and can explain.