Skip to content

Commit

Permalink
Auto merge of #7281 - camsteffen:has-doc-fp, r=flip1995
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
bors committed May 27, 2021
2 parents 8066f83 + c21b965 commit 2fa9362
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ impl MissingDoc {
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,
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/missing-doc-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/missing-doc-impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2fa9362

Please sign in to comment.