Skip to content

Commit 2fa9362

Browse files
committed
Auto merge of rust-lang#7281 - camsteffen:has-doc-fp, r=flip1995
Fix missing_docs_in_private_items false negative changelog: Fix [`missing_docs_in_private_items`] false negative when the item has any `#[name = "value"]` attribute Closes rust-lang#7247 (decided not to use the rustc method since it calls `Session::check_name`, which is for rustc only)
2 parents 8066f83 + c21b965 commit 2fa9362

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

clippy_lints/src/missing_doc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ impl MissingDoc {
9393
return;
9494
}
9595

96-
let has_doc = attrs.iter().any(|a| {
97-
a.is_doc_comment() || a.doc_str().is_some() || a.value_str().is_some() || Self::has_include(a.meta())
98-
});
96+
let has_doc = attrs
97+
.iter()
98+
.any(|a| a.doc_str().is_some() || Self::has_include(a.meta()));
9999
if !has_doc {
100100
span_lint(
101101
cx,

tests/ui/missing-doc-impl.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ impl PubFoo {
6767
pub fn foo() {}
6868
/// dox
6969
pub fn foo1() {}
70-
fn foo2() {}
70+
#[must_use = "yep"]
71+
fn foo2() -> u32 {
72+
1
73+
}
7174
#[allow(clippy::missing_docs_in_private_items)]
7275
pub fn foo3() {}
7376
}

tests/ui/missing-doc-impl.stderr

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ LL | pub fn foo() {}
9494
| ^^^^^^^^^^^^^^^
9595

9696
error: missing documentation for an associated function
97-
--> $DIR/missing-doc-impl.rs:70:5
97+
--> $DIR/missing-doc-impl.rs:71:5
9898
|
99-
LL | fn foo2() {}
100-
| ^^^^^^^^^^^^
99+
LL | / fn foo2() -> u32 {
100+
LL | | 1
101+
LL | | }
102+
| |_____^
101103

102104
error: aborting due to 15 previous errors
103105

0 commit comments

Comments
 (0)