Skip to content

Ignore #[doc(hidden)] functions in clippy doc lints #115851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/tools/clippy/clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
Some(("fake".into(), "fake".into()))
}

if is_doc_hidden(attrs) {
return None;
}

let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true);
let mut doc = String::new();
for fragment in &fragments {
Expand Down
15 changes: 15 additions & 0 deletions src/tools/clippy/tests/ui/doc_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ impl Struct1 {
fn block_comment_leading_asterisks() -> Result<(), ()> {
unimplemented!();
}

#[doc(hidden)]
fn doc_hidden() -> Result<(), ()> {
unimplemented!();
}
}

pub trait Trait1 {
Expand All @@ -111,6 +116,11 @@ pub trait Trait1 {
/// # Errors
/// A description of the errors goes here.
fn trait_method_with_errors_header() -> Result<(), ()>;

#[doc(hidden)]
fn doc_hidden() -> Result<(), ()> {
unimplemented!();
}
}

impl Trait1 for Struct1 {
Expand All @@ -123,6 +133,11 @@ impl Trait1 for Struct1 {
}
}

#[doc(hidden)]
pub trait DocHidden {
fn f() -> Result<(), ()>;
}

fn main() -> Result<(), ()> {
Ok(())
}
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/doc_errors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ LL | pub async fn async_pub_method_missing_errors_header() -> Result<(), ()>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: docs for function returning `Result` missing `# Errors` section
--> $DIR/doc_errors.rs:108:5
--> $DIR/doc_errors.rs:113:5
|
LL | fn trait_method_missing_errors_header() -> Result<(), ()>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down