Rollup merge of #147676 - jdonszelmann:span-is-doc-comment, r=GuillaumeGomez

Return spans out of `is_doc_comment` to reduce reliance on `.span()` on attributes

r? `@GuillaumeGomez`
This commit is contained in:
Matthias Krüger
2025-10-15 23:41:03 +02:00
committed by GitHub
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
.tcx
.hir_attrs(item.hir_id())
.iter()
.filter(|i| i.is_doc_comment())
.filter(|i| i.is_doc_comment().is_some())
.fold(item.span.shrink_to_lo(), |span, attr| span.to(attr.span()));
let (Some(file), _, _, end_line, _) = sm.span_to_location_info(span) else {
return;
@@ -475,7 +475,7 @@ fn block_has_safety_comment(cx: &LateContext<'_>, span: Span) -> bool {
fn include_attrs_in_span(cx: &LateContext<'_>, hir_id: HirId, span: Span) -> Span {
span.to(cx.tcx.hir_attrs(hir_id).iter().fold(span, |acc, attr| {
if attr.is_doc_comment() {
if attr.is_doc_comment().is_some() {
return acc;
}
acc.to(attr.span())