Repository navigation
improve doc attr span tracking for proc-macro - #17678
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. |
This comment has been minimized.
This comment has been minimized.
0fcb239 to
ff99bf7
Compare
|
Lintcheck changes for 1b55172
This comment will be updated if you push new changes |
ff99bf7 to
a14ea79
Compare
There was a problem hiding this comment.
(follow on from #16713 (comment))
Only some of these item kinds produced the 'missing backticks' clippy::doc_markdown lint due to a very specific requirement in order to resolve a Span from a markdown string:
- Since these doc comments are within a macro invocation, they are turned into
DocFragmentKind::Raw - Before emitting the backtick lint on a word (eg.
foreign_mod), it's span is resolved - This resolution is performed by
source_span_for_markdown_range_inner(viaFragments), which cannot disambiguate between multiple instances of a match within a markdown block.
All that being said, I feel that properly backticking these item kinds is appropriate.
a14ea79 to
02eac0e
Compare
|
(also if you are nice, make sure to include an |
Good idea, thanks!
These issues occur when doc comments are in the |
Yes, but adding test coverage for the other form would be nice to have too, even if just to confirm that we don't regress on this one. So the combination of As I alured, this one is for bonus points and not something that is required 😉 |
|
r? @blyxyas rustbot has assigned @blyxyas for the project review. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
02eac0e to
6302650
Compare
|
This PR was rebased onto a different master 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. |
6302650 to
17964ca
Compare
| let (_, kind) = attr.doc_str_and_fragment_kind()?; | ||
| let (is_raw, doc_str_span) = match kind { | ||
| DocFragmentKind::Sugared(_) => (false, attr.span()), | ||
| DocFragmentKind::Raw(span) => (true, span), | ||
| }; | ||
| let from_include_str_macro = is_raw | ||
| && !attr.span().in_external_macro(cx.sess().source_map()) | ||
| && originated_from_include_str_macro(cx, doc_str_span); | ||
| (from_include_str_macro || !doc_str_span.in_external_macro(cx.sess().source_map())).then_some((attr, None)) |
There was a problem hiding this comment.
Much better! ❤️
17964ca to
1b55172
Compare
|
@blyxyas Thank you for the review! Commits have been squashed, let me know if there's anything else that's needed. |
Resolves #16317
Resolves #16382
Resolves #16713
Largely based on #16713.
Lint documentation is contained within doc-comments within a macro invocation. Therefore, any lints were not applied to them up until now. A separate commit addresses these problems.
changelog: [
empty_docs]: lint user-provided doc on proc-macro expanded codeschangelog: [
missing_safety_doc]: lint user-provided doc on proc-macro expanded codeschangelog: [
missing_panics_doc]: lint user-provided doc on proc-macro expanded codes