Skip to content

Commit 56e1aaa

Browse files
committed
Auto merge of #115851 - Alexendoo:clippy-doc-hidden-headers, r=flip1995
Ignore `#[doc(hidden)]` functions in clippy doc lints Fixes rust-lang/rust-clippy#11501 The implementation before #115689 had a check for unsugared doc comments that also happened to catch `#[doc(hidden)]`, this adds the check back in more explicitly https://github.com/rust-lang/rust/blob/852bf4e51bf260550cd1a280d2146f1c0641b1e8/src/tools/clippy/clippy_lints/src/doc.rs#L526-L529 r? `@flip1995`
2 parents 915c8af + 88f3f23 commit 56e1aaa

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/tools/clippy/clippy_lints/src/doc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
479479
Some(("fake".into(), "fake".into()))
480480
}
481481

482+
if is_doc_hidden(attrs) {
483+
return None;
484+
}
485+
482486
let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true);
483487
let mut doc = String::new();
484488
for fragment in &fragments {

src/tools/clippy/tests/ui/doc_errors.rs

+15
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ impl Struct1 {
101101
fn block_comment_leading_asterisks() -> Result<(), ()> {
102102
unimplemented!();
103103
}
104+
105+
#[doc(hidden)]
106+
fn doc_hidden() -> Result<(), ()> {
107+
unimplemented!();
108+
}
104109
}
105110

106111
pub trait Trait1 {
@@ -111,6 +116,11 @@ pub trait Trait1 {
111116
/// # Errors
112117
/// A description of the errors goes here.
113118
fn trait_method_with_errors_header() -> Result<(), ()>;
119+
120+
#[doc(hidden)]
121+
fn doc_hidden() -> Result<(), ()> {
122+
unimplemented!();
123+
}
114124
}
115125

116126
impl Trait1 for Struct1 {
@@ -123,6 +133,11 @@ impl Trait1 for Struct1 {
123133
}
124134
}
125135

136+
#[doc(hidden)]
137+
pub trait DocHidden {
138+
fn f() -> Result<(), ()>;
139+
}
140+
126141
fn main() -> Result<(), ()> {
127142
Ok(())
128143
}

src/tools/clippy/tests/ui/doc_errors.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ LL | pub async fn async_pub_method_missing_errors_header() -> Result<(), ()>
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939

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

0 commit comments

Comments
 (0)