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

missing_docs false positive on re-export in module with #![allow(missing_docs)] #57533

Open
abonander opened this issue Jan 11, 2019 · 5 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@abonander
Copy link
Contributor

abonander commented Jan 11, 2019

This one might be a bit complex to solve. This affects both 2015 and 2018 editions on stable/nightly.

When a pub item from a private module in a crate with #![deny(missing_docs)] is reexported in a pub module marked #![allow(missing_docs)], the lint still fires.

2015 (Playground) (2018 just needs the crate:: prefix on the use path)

//! docs for crate
#![deny(missing_docs)]

#[allow(missing_docs)]
pub mod undoc {
    #[allow(missing_docs)] // no effect
    pub use nonpub::Foo;
}

mod nonpub {
    pub struct Foo;
    
    impl Foo {
        pub fn bar() {}
    }
}

Both report the same error. The lint marks the original definition point of the item; if it has associated items, those are hit too:

error: missing documentation for a struct
  --> src/lib.rs:11:5
   |
11 |     pub struct Foo;
   |     ^^^^^^^^^^^^^^^
   |
note: lint level defined here
  --> src/lib.rs:2:9
   |
2  | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for a method
  --> src/lib.rs:14:9
   |
14 |         pub fn bar() {}
   |         ^^^^^^^^^^^^

error: aborting due to 2 previous errors

Interestingly, marking the item's source module with #[allow(missing_docs)] silences the error: Playground

//! docs for crate
#![deny(missing_docs)]

#[allow(missing_docs)]
pub mod undoc {
    pub use nonpub::Foo;
}

#[allow(missing_docs)]
mod nonpub {
    pub struct Foo;
    
    impl Foo {
        pub fn bar() {}
    }
}
@estebank estebank added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 11, 2019
@abonander
Copy link
Contributor Author

@estebank this is a lint error, not a Rustdoc error

@estebank estebank added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 12, 2019
@estebank
Copy link
Contributor

@abonander good catch, I misread the ticket while grooming. Thanks for the correction!

@petrochenkov petrochenkov self-assigned this Jan 12, 2019
@petrochenkov
Copy link
Contributor

struct Foo and fn bar are 1) reachable from other crates, 2) have no doc comments and 3) are not in scope of #[allow(missing_docs)].
So they are reported by the missing doc lint.

Looks like everything is working correctly to me.

@petrochenkov petrochenkov removed their assignment Jan 12, 2019
@GuillaumeGomez
Copy link
Member

I'm the one who wrote this lint and it seems to be working correctly to me as well...

@abonander
Copy link
Contributor Author

Except that they're reexported from a module marked #[allow(missing_docs)] which I would expect not to require documentation on items reachable inside it.

Moreover, #[allow(missing_docs)] on the reexport does nothing but is not at least marked as an unused attribute.

@Enselic Enselic added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants