Repository navigation
doc_markdown: don't lint proc-macro doc text that reuses a user span - #17943
GauravPawar101 wants to merge 5 commits into
Conversation
|
Some changes occurred in clippy_lints/src/doc cc @notriddle |
|
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. |
|
@GauravPawar101 Have you used an LLM in the making of this pull request (including code or description)? You must disclose it |
|
@blyxyas check desc |
There was a problem hiding this comment.
I am relatively new to clippy (#17954 this is my first PR where I actually change the logic). I'm still learning the codebase, a maintainer should definitely take a final look!
| fn is_doc_text_source(cx: &LateContext<'_>, span: Span) -> bool { | ||
| const OPENERS: [&str; 5] = ["\"", "///", "//!", "/**", "/*!"]; | ||
| span.check_text(cx, |src| { | ||
| // r#foo is a raw identifier |
There was a problem hiding this comment.
can be dropped since the string matching is self-documenting.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
f020503 to
3e3d001
Compare
|
THank you @raushan728 |
There was a problem hiding this comment.
Looks good to me!
@blyxyas, could you please take another look?
@GauravPawar101, a small tip for future contributions try to keep commits scoped to one logical change.
|
Yeah, thanks. I will keep that in mind!! |
Fixes #17911
Problem
Currenlty,
doc_markdownlints a raw#[doc = ".."]whenever its literal's spanis in user code. Some proc macros (e.g. Leptos'
#[component]) builds the doc textthemselves but reuse the span of a user ident for the literal. The user can't
edit that text, so the lint can't be fixed where it's reported.
Fix
For raw
#[doc = ".."]attributes, the source at the literal's span must now startlike something that can hold doc text:
"..",r"..",r#".."#), or///,//!,/** */,/*! */).Doc comments are accepted because proc macros turn them into
#[doc = ".."]attributes whose literal keeps the comment's span. If the source is unavailable, the
lint stays silent. Raw identifiers (
r#type) are not mistaken for raw strings.Tests
cargo testchangelog: [
doc_markdown]: no longer lints doc text generated by proc macros thatreuse a user identifier's span
LLM discloser
Llm was used for strengthening tests and identifying fn or fp that might have been introduced