Skip to content
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

Clippy tells me to put # Error section on doc comments for #[doc(hidden)] function #11501

Closed
Robbepop opened this issue Sep 14, 2023 · 5 comments · Fixed by rust-lang/rust#115851
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@Robbepop
Copy link

Summary

Clippy tells me to write an # Error doc section for a function that has hidden its documentation via #[doc(hidden)]. In my opinion this clippy warning thus does not make sense since docs are unavailable anyways.

This warning got introduced when I upgraded to the most recent clippy nightly. (clippy 0.1.74 (8142a319 2023-09-13))

Reproducer

I tried this code:

#![warn(clippy::missing_errors_doc)]

trait Foo {
    #[doc(hidden)]
    fn foo() -> Result<(), ()>;
}

I expected to see this happen: OK

Instead, this happened:

warning: docs for function returning `Result` missing `# Errors` section
  --> main.rs:5:5
   |
5  |     fn foo() -> Result<(), ()>;

Version

rustc 1.74.0-nightly (8142a319e 2023-09-13)
binary: rustc
commit-hash: 8142a319ed5c1d1f96e5a1881a6546e463b77c8f
commit-date: 2023-09-13
host: aarch64-apple-darwin
release: 1.74.0-nightly
LLVM version: 17.0.0

Additional Labels

No response

@Robbepop Robbepop added the C-bug Category: Clippy is not doing the correct thing label Sep 14, 2023
@Alexendoo Alexendoo self-assigned this Sep 14, 2023
@Alexendoo
Copy link
Member

Couldn't reproduce this, is that the full file?

@Robbepop
Copy link
Author

Robbepop commented Sep 14, 2023

Couldn't reproduce this, is that the full file?

@Alexendoo Oh I am extremely sorry! I assumed too much about this particular error. The code I pasted is actually not reproducing for me either. I just tried to come up with a minimal code sample of the offending code but I failed so far. The code that triggers this bug can be found here: https://github.com/paritytech/wasmi/blob/837bfdb7a0fc668b64a00ef56dd09187ef2ce7b8/crates/wasmi/src/func/into_func.rs#L98

In particular I encountered it in this branch: https://github.com/paritytech/wasmi/blob/9cc4fd7c28c2432082c9a2033c1d226ec819f235/crates/wasmi/src/func/into_func.rs#L98
However, from my knowledge the branch does not really modify the associated file.

@Alexendoo
Copy link
Member

Thanks! That reproduces for me as well

@Alexendoo
Copy link
Member

The reproducer in the original post needed just one extra thing for it to lint - for it to be pub trait Foo { .. }

@Robbepop
Copy link
Author

Robbepop commented Sep 14, 2023

The reproducer in the original post needed just one extra thing for it to lint - for it to be pub trait Foo { .. }

yeah that actually makes sense since otherwise it won't be included in the public docs of a crate anyways. 🤦 glad you figured it out!

flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Sep 25, 2023
Ignore `#[doc(hidden)]` functions in clippy doc lints

Fixes rust-lang#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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants