cargo-semver-checks icon indicating copy to clipboard operation
cargo-semver-checks copied to clipboard

New lints: item that was previously public API is now `#[doc(hidden)]` i.e. no longer public API

Open obi1kenobi opened this issue 1 year ago • 1 comments

For example, uncommenting the #[doc(hidden)] line is a breaking change since the struct is no longer considered public API, even though it is public. This is because some non-public API may need to be accessible from outside its crate, for example in macro-heavy crates like pyo3.

// #[doc(hidden)]
pub struct Example;

We need lints for this kind of situation for:

  • [x] structs: #587
  • [x] enums: #593
  • [x] unions: #679
  • [x] functions: #594
  • [x] traits: #595
  • [x] statics: #712
  • [x] module-level constants: #690, #703
  • [x] ImplOwner (struct/enum/union) inherent associated functions / methods: #821
  • [x] ImplOwner associated constants: #820
  • [x] struct fields (#649)
  • [x] union fields (#844)
  • [x] #596
  • [x] enum tuple variant fields: #685
  • [x] enum struct variant fields: #687
  • [x] trait associated functions / methods: #684
  • [x] trait associated types: #776
  • [x] trait associated constants: #779
  • [ ] macros (declarative, proc macro, etc.), tracked in detail by #946

Remaining work item

We should figure out what are the appropriate semantics of marking an impl block #[doc(hidden)] with respect to the block's contents. Are the contents considered not public API anymore? Is #[doc(hidden)] simply ignored on that impl block?

The action items here are:

  • [ ] Figure out how rustdoc itself treats items defined inside a #[doc(hidden)] impl block. Does it think they are hidden, or no?
  • [ ] Adjust all affected lints accordingly (e.g. #820, #821)

obi1kenobi avatar Nov 07 '23 22:11 obi1kenobi