Skip to content

Commit 3cd6fd1

Browse files
committed
fix [empty_docs] trigger in proc-macro
1 parent 10677d6 commit 3cd6fd1

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

clippy_lints/src/doc/mod.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_data_structures::fx::FxHashSet;
1414
use rustc_hir as hir;
1515
use rustc_hir::intravisit::{self, Visitor};
1616
use rustc_hir::{AnonConst, Expr};
17-
use rustc_lint::{LateContext, LateLintPass};
17+
use rustc_lint::{LateContext, LateLintPass, LintContext};
1818
use rustc_middle::hir::nested_filter;
1919
use rustc_middle::lint::in_external_macro;
2020
use rustc_middle::ty;
@@ -538,7 +538,16 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
538538

539539
suspicious_doc_comments::check(cx, attrs);
540540

541-
let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true);
541+
let (fragments, _) = attrs_to_doc_fragments(
542+
attrs.iter().filter_map(|attr| {
543+
if in_external_macro(cx.sess(), attr.span) {
544+
None
545+
} else {
546+
Some((attr, None))
547+
}
548+
}),
549+
true,
550+
);
542551
let mut doc = fragments.iter().fold(String::new(), |mut acc, fragment| {
543552
add_doc_fragment(&mut acc, fragment);
544553
acc

tests/ui/empty_docs.stderr

+1-19
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,5 @@ LL | ///
7373
|
7474
= help: consider removing or filling it
7575

76-
error: empty doc comment
77-
--> tests/ui/empty_docs.rs:77:5
78-
|
79-
LL | #[with_empty_docs]
80-
| ^^^^^^^^^^^^^^^^^^
81-
|
82-
= help: consider removing or filling it
83-
= note: this error originates in the attribute macro `with_empty_docs` (in Nightly builds, run with -Z macro-backtrace for more info)
84-
85-
error: empty doc comment
86-
--> tests/ui/empty_docs.rs:82:5
87-
|
88-
LL | #[with_empty_docs]
89-
| ^^^^^^^^^^^^^^^^^^
90-
|
91-
= help: consider removing or filling it
92-
= note: this error originates in the attribute macro `with_empty_docs` (in Nightly builds, run with -Z macro-backtrace for more info)
93-
94-
error: aborting due to 11 previous errors
76+
error: aborting due to 9 previous errors
9577

0 commit comments

Comments
 (0)