Auto merge of #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 #7247 (decided not to use the rustc method since it calls `Session::check_name`, which is for rustc only)
This commit is contained in:
bors 2021-05-27 08:37:08 +00:00
commit 2fa9362448
3 changed files with 12 additions and 7 deletions

View File

@ -93,9 +93,9 @@ fn check_missing_docs_attrs(
return;
}
let has_doc = attrs.iter().any(|a| {
a.is_doc_comment() || a.doc_str().is_some() || a.value_str().is_some() || Self::has_include(a.meta())
});
let has_doc = attrs
.iter()
.any(|a| a.doc_str().is_some() || Self::has_include(a.meta()));
if !has_doc {
span_lint(
cx,

View File

@ -67,7 +67,10 @@ impl PubFoo {
pub fn foo() {}
/// dox
pub fn foo1() {}
fn foo2() {}
#[must_use = "yep"]
fn foo2() -> u32 {
1
}
#[allow(clippy::missing_docs_in_private_items)]
pub fn foo3() {}
}

View File

@ -94,10 +94,12 @@ LL | pub fn foo() {}
| ^^^^^^^^^^^^^^^
error: missing documentation for an associated function
--> $DIR/missing-doc-impl.rs:70:5
--> $DIR/missing-doc-impl.rs:71:5
|
LL | fn foo2() {}
| ^^^^^^^^^^^^
LL | / fn foo2() -> u32 {
LL | | 1
LL | | }
| |_____^
error: aborting due to 15 previous errors