Uh oh!
There was an error while loading. Please reload this page.
Warn on unused #[doc(hidden)] attributes on trait impl items - #96008
Conversation
rust-highfive
commented
Apr 13, 2022
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
rust-highfive
commented
Apr 13, 2022
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
GuillaumeGomez
commented
Apr 13, 2022
For the bug you detected, please open an issue (and assign it to yourself) and fix it in another PR. Otherwise, this PR looks good to me, thanks! |
070aca7 to
8b19067Compare
This comment was marked as outdated.
This comment was marked as outdated.
8b19067 to
9c81d0cComparelcnr
commented
Apr 13, 2022
I personally think we should treat this similar to other, previously silently ignored attributes. E.g. structFoo(#[inline]());Imo this should be a Though that's for @rust-lang/lang @rust-lang/docs to decide. |
bors
commented
May 3, 2022
☔ The latest upstream changes (presumably #92566) made this pull request unmergeable. Please resolve the merge conflicts. |
fmease
commented
May 4, 2022
Since nobody else voiced their opinion, I will integrate the lint |
scottmcm
commented
May 4, 2022
👍 to treating it like the other attributes -- there have been a ton of these, like |
fmease
commented
May 6, 2022
@rustbot author |
9c81d0c to
02e490eCompare02e490e to
9d157adComparelcnr
commented
May 9, 2022
bors
commented
May 9, 2022
📌 Commit 9d157ad has been approved by |
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#95483 (Improve floating point documentation) - rust-lang#96008 (Warn on unused `#[doc(hidden)]` attributes on trait impl items) - rust-lang#96841 (Revert "Implement [OsStr]::join", which was merged without FCP.) - rust-lang#96844 (Actually fix ICE from rust-lang#96583) - rust-lang#96854 (Some subst cleanup) - rust-lang#96858 (Remove unused param from search.js::checkPath) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
scottmcm
commented
May 9, 2022
👍. So long as (like here) reverting it doesn't break people, it doesn't need a full FCP. |
dtolnay
commented
May 10, 2022
FWIW the rustdoc that shipped with 1.56.0 and older versions of Rust does look at A typical case looks like: pubtraitTrait{fnpublic_fn();#[doc(hidden)]fn__private_fn(){…}}implTraitforStruct{fnpublic_fn(){…}#[doc(hidden)]fn__private_fn(){…}}Without Rust 1.56.0 is only 6 months old so it's not unreasonable that libraries would want to support it. |
dtolnay
commented
May 10, 2022
I noticed in a different one of my crates that the I filed #96890 to follow up. |
Oh, I didn't know older versions of rustdoc behave differently in this scenario. Is 1.56 the last version where rustdoc behaved differently? (Well, for 1.62 I even extended the new behavior, see #95769) |
Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items Fixesrust-lang#97205 (embarrassing oversight from rust-lang#96008). `@rustbot` label A-lint
…t, r=GuillaumeGomez Remove the unused-`#[doc(hidden)]` logic from the `unused_attributes` lint Fixesrust-lang#96890. It was found out that `#[doc(hidden)]` on trait impl items does indeed have an effect on the generated documentation (see the linked issue). In my opinion and the one of [others](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60/near/281846219), rustdoc's output is actually a bit flawed in that regard but that should be tracked in a new issue I suppose (I will open an issue for that in the near future). The check was introduced in rust-lang#96008 which is marked to be part of version `1.62` (current `beta`). As far as I understand, this means that **this PR needs to be backported** to `beta` to fixrust-lang#96890 on time. Correct me if I am wrong. CC `@dtolnay` (in case you would like to agree or disagree with my decision to fully remove this check) `@rustbot` label A-lint T-compiler T-rustdoc r? `@rust-lang/compiler`
…t, r=GuillaumeGomez Remove the unused-`#[doc(hidden)]` logic from the `unused_attributes` lint Fixesrust-lang#96890. It was found out that `#[doc(hidden)]` on trait impl items does indeed have an effect on the generated documentation (see the linked issue). In my opinion and the one of [others](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Validy.20checks.20for.20.60.23.5Bdoc.28hidden.29.5D.60/near/281846219), rustdoc's output is actually a bit flawed in that regard but that should be tracked in a new issue I suppose (I will open an issue for that in the near future). The check was introduced in rust-lang#96008 which is marked to be part of version `1.62` (current `beta`). As far as I understand, this means that **this PR needs to be backported** to `beta` to fixrust-lang#96890 on time. Correct me if I am wrong. CC `@dtolnay` (in case you would like to agree or disagree with my decision to fully remove this check) `@rustbot` label A-lint T-compiler T-rustdoc r? `@rust-lang/compiler`
Zulip conversation.
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: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_attributefor this case with a future-incompat warning.@rustbot label T-compiler T-rustdoc A-lint