rust/library/core/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 Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
array Remove use of #[rustc_deprecated] 2022-04-14 01:33:13 -04:00
async_iter Add Stream alias for AsyncIterator 2022-03-15 20:59:13 -07:00
char No need to check the assert all the time. 2022-04-16 19:30:23 +01:00
convert Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
ffi generalize "incoherent impls" impl for custom types 2022-05-05 10:53:00 +02:00
fmt Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
future Rename IntoFuture::Future to IntoFuture::IntoFuture 2022-03-10 20:51:52 +01:00
hash Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
iter Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
macros Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
mem Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
num Rollup merge of #95483 - golddranks:improve_float_docs, r=joshtriplett 2022-05-09 18:45:35 +02:00
ops Add do yeet expressions to allow experimentation in nightly 2022-04-30 17:40:27 -07:00
panic Auto merge of #96348 - overdrivenpotato:inline-location, r=the8472 2022-04-30 16:33:12 +00:00
prelude Create 2024 edition 2022-04-02 02:45:49 -04:00
ptr Rollup merge of #96336 - Nilstrieb:link-to-correct-as_mut-in-ptr-as_ref, r=JohnTitor 2022-05-07 22:44:36 +02:00
slice Warn on unused doc(hidden) on trait impl items 2022-05-08 22:53:14 +02:00
str Rollup merge of #96008 - fmease:warn-on-useless-doc-hidden-on-assoc-impl-items, r=lcnr 2022-05-09 18:45:36 +02:00
sync Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
task Rollup merge of #89869 - kpreid:from-doc, r=yaahc 2022-02-17 06:29:57 +01:00
unicode Regenerate tables for Unicode 14.0.0 2021-10-06 17:49:33 -07:00
any.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00
ascii.rs Inline <EscapeDefault as Iterator>::next 2022-03-10 15:35:22 +01:00
bool.rs Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
borrow.rs Make Borrow and BorrowMut impls const 2021-12-04 21:57:39 +09:00
cell.rs Add tracking issue for sync_unsafe_cell. 2022-03-29 19:54:00 +02:00
clone.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
cmp.rs Derive Eq for std::cmp::Ordering, instead of using manual impl. 2022-03-16 11:36:31 -05:00
default.rs Add documentation 2022-04-07 20:03:24 -04:00
hint.rs Add core::hint::must_use 2022-03-08 10:58:03 -08:00
internal_macros.rs ignore a doctest for the non-exported macro 2022-05-03 18:33:56 +09:00
intrinsics.rs Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
lazy.rs Rollup merge of #89869 - kpreid:from-doc, r=yaahc 2022-02-17 06:29:57 +01:00
lib.rs Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko 2022-04-17 05:26:08 +00:00
marker.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
option.rs Add do yeet expressions to allow experimentation in nightly 2022-04-30 17:40:27 -07:00
panic.rs resolve the conflict in compiler/rustc_session/src/parse.rs 2022-03-16 20:12:30 +08:00
panicking.rs trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
pin.rs Fix formatting error in pin.rs docs 2022-04-10 12:41:31 -07:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
primitive_docs.rs Further refine the disclaimer about NaN bit patterns. 2022-03-31 18:18:10 +09:00
result.rs Add do yeet expressions to allow experimentation in nightly 2022-04-30 17:40:27 -07:00
time.rs Adjust feature names that disagree on const stabilization version 2022-03-31 12:34:48 -07:00
tuple.rs Implement tuples using recursion 2022-04-12 16:23:36 -03:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00