|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then; |
| 2 | +use rustc_ast::attr::AttributeExt as _; |
2 | 3 | use rustc_ast::token::CommentKind; |
3 | 4 | use rustc_errors::Applicability; |
4 | 5 | use rustc_hir::{AttrStyle, Attribute}; |
@@ -43,13 +44,19 @@ pub fn check(cx: &LateContext<'_>, doc: &str, range: Range<usize>, fragments: &F |
43 | 44 | "looks like a footnote ref, but has no matching footnote", |
44 | 45 | |diag| { |
45 | 46 | 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 |
47 | 48 | .iter() |
48 | 49 | .filter(|attr| attr.span().overlaps(this_fragment.span)) |
49 | 50 | .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 | + }) |
51 | 58 | .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) { |
53 | 60 | (CommentKind::Line, AttrStyle::Outer) => ("\n///\n/// ", ""), |
54 | 61 | (CommentKind::Line, AttrStyle::Inner) => ("\n//!\n//! ", ""), |
55 | 62 | (CommentKind::Block, AttrStyle::Outer) => ("\n/** ", " */"), |
|
0 commit comments