Skip to content

Commit 953bf2b

Browse files
committed
All HIR attributes are outer
1 parent f027fc8 commit 953bf2b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

clippy_lints/src/doc/doc_suspicious_footnotes.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2+
use rustc_ast::attr::AttributeExt as _;
23
use rustc_ast::token::CommentKind;
34
use rustc_errors::Applicability;
45
use rustc_hir::{AttrStyle, Attribute};
@@ -43,13 +44,19 @@ pub fn check(cx: &LateContext<'_>, doc: &str, range: Range<usize>, fragments: &F
4344
"looks like a footnote ref, but has no matching footnote",
4445
|diag| {
4546
if this_fragment.kind == DocFragmentKind::SugaredDoc {
46-
let (doc_attr, (_, doc_attr_comment_kind)) = attrs
47+
let (doc_attr, (_, doc_attr_comment_kind), attr_style) = attrs
4748
.iter()
4849
.filter(|attr| attr.span().overlaps(this_fragment.span))
4950
.rev()
50-
.find_map(|attr| Some((attr, attr.doc_str_and_comment_kind()?)))
51+
.find_map(|attr| {
52+
Some((
53+
attr,
54+
attr.doc_str_and_comment_kind()?,
55+
attr.doc_resolution_scope()?,
56+
))
57+
})
5158
.unwrap();
52-
let (to_add, terminator) = match (doc_attr_comment_kind, doc_attr.style()) {
59+
let (to_add, terminator) = match (doc_attr_comment_kind, attr_style) {
5360
(CommentKind::Line, AttrStyle::Outer) => ("\n///\n/// ", ""),
5461
(CommentKind::Line, AttrStyle::Inner) => ("\n//!\n//! ", ""),
5562
(CommentKind::Block, AttrStyle::Outer) => ("\n/** ", " */"),

0 commit comments

Comments
 (0)