missing_docs does not trigger for types only used in exported fields of enumerations

662284b
Opened by Ben Boeckel at 2025-03-01 12:26:23

IMO, this should be a compilation failure because although Foo is not explicitly exported, it is publicly visible via the Bar::A variant:

lib.rs:

#![deny(missing_docs)]

mod types;

pub use types::Bar;

types.rs:

pub struct Foo;

/// A bar.
pub enum Bar {
    /// A `Bar` variant.
    A(Foo),
}

Oddly enough, it seems to also be happy with the missing crate-level docs…

Using 1.14.0 (from Fedora's repository).

  1. Hmm, even documenting it does not make it hyperlinked in the generated docs. What is the expected behavior here?

    Ben Boeckel at 2017-01-18 20:25:35

  2. You need to make the types module public.

    Alex Burka at 2017-01-18 22:06:14

  3. Yeah, that makes the errors appear (as does re-exporting Foo from lib.rs). I'm not in front of a compiler right now, but IIRC, removing the pub from Foo is a compiler error; why is it not also a doc error?

    Ben Boeckel at 2017-01-19 01:31:37

  4. Yep, removing the pub from Foo makes it error out that it can't leak private types. So, should the same behavior apply for missing_docs (since this is "leaking an undocumented public type")?

    Ben Boeckel at 2017-01-19 14:25:16

  5. Updated description to include ! in #![deny(missing_docs)], which made the lint error on the crate documentation, but still no errors about Foo itself.

    Mark Rousskov at 2017-05-20 01:41:10

  6. It was a bit of a surprise when I realized an important type that users are exposed to in one of my libraries was not properly documented, despite the crate specifying #![deny(missing_docs)]. My use case looked a bit like this.

    Tyler Neely at 2018-01-07 21:35:46