rust/library/alloc/src
Matthias Krüger 6c8001b85c
Rollup merge of #96008 - fmease:warn-on-useless-doc-hidden-on-assoc-impl-items, r=lcnr
Warn on unused `#[doc(hidden)]` attributes on trait impl items

[Zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.E2.9C.94.20Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60).

Whether an associated item in a trait impl is shown or hidden in the documentation entirely depends on the corresponding item in the trait declaration. Rustdoc completely ignores `#[doc(hidden)]` attributes on impl items. No error or warning is emitted:

```rust
pub trait Tr { fn f(); }
pub struct Ty;
impl Tr for Ty { #[doc(hidden)] fn f() {} }
//               ^^^^^^^^^^^^^^ ignored by rustdoc and currently
//                              no error or warning issued
```

This may lead users to the wrong belief that the attribute has an effect. In fact, several such cases are found in the standard library (I've removed all of them in this PR).
There does not seem to exist any incentive to allow this in the future either: Impl'ing a trait for a type means the type *fully* conforms to its API. Users can add `#[doc(hidden)]` to the whole impl if they want to hide the implementation or add the attribute to the corresponding associated item in the trait declaration to hide the specific item. Hiding an implementation of an associated item does not make much sense: The associated item can still be found on the trait page.

This PR emits the warn-by-default lint `unused_attribute` for this case with a future-incompat warning.

`@rustbot` label T-compiler T-rustdoc A-lint
2022-05-09 18:45:36 +02:00
..
alloc Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
boxed Add ThinBox type for 1 stack pointer sized heap allocated trait objects 2022-04-08 09:00:16 -07:00
collections Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
ffi Fix targets not supporting target_has_atomic = "ptr" 2022-04-14 21:53:11 +03:00
raw_vec Add a unit test for zero-sized types in RawVec. 2021-11-26 19:30:45 +11:00
rc Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
sync Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
vec Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
alloc.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
borrow.rs Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPC 2022-04-26 13:22:26 +02:00
boxed.rs Add a dedicated length-prefixing method to Hasher 2022-05-06 00:03:38 -07:00
fmt.rs std::fmt: Improved list of formatting macros 2022-05-01 15:27:41 +02:00
lib.rs Add a dedicated length-prefixing method to Hasher 2022-05-06 00:03:38 -07:00
macros.rs alloc: make vec! unavailable under no_global_oom_handling 2022-04-16 06:31:41 +02:00
raw_vec.rs formatting 2022-04-06 01:36:46 +05:30
rc.rs Rollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se 2022-05-05 15:43:02 +02:00
slice.rs Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
str.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
string.rs Clarify docs for from_raw_parts 2022-04-19 21:12:55 +01:00
sync.rs Auto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu 2022-05-06 14:53:24 +00:00
task.rs Document From implementations for Waker and RawWaker 2021-04-22 14:16:33 -07:00
tests.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00