Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalKey's methods are incorrectly documented as unstable. #132440

Closed
zachs18 opened this issue Nov 1, 2024 · 1 comment
Closed

LocalKey's methods are incorrectly documented as unstable. #132440

zachs18 opened this issue Nov 1, 2024 · 1 comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@zachs18
Copy link
Contributor

zachs18 commented Nov 1, 2024

Location

https://doc.rust-lang.org/nightly/std/thread/struct.LocalKey.html#method.get

Summary

LocalKey's methods have incorrect stability documentation in beta and nightly docs

Expected: Stable 1.82.0 docs: "Since 1.73.0"
Image

Actual: Beta 1.83.0-beta.2 docs: "nightly-only experimental API"
Image

LocalKey is itself stable, and defined in std::thread, but these methods are defined in the private std::thread::local module that has #![unstable(feature = "thread_local_internals")]


(cc #130798 @lukas-code ) Inherent methods probably shouldn't inherit their parent module's stability, since they are callable without needing to reach the module they are defined in, only their Self type need be reachable.


Bisection:

Regression in rust-lang-ci@7f0a4c9
The PR introducing the regression in this rollup is #130798: rustdoc: inherit parent's stability where applicable

searched nightlies: from nightly-2024-09-02 to nightly-2024-11-01
regressed nightly: nightly-2024-09-26
searched commit range: https://github.com/rust-lang/rust/
compare/363ae4188316b8b22cf6c1890bc73d84d05f70a4...9e394f5
regressed commit: 1b5aa96

bisected with cargo-bisect-rustc v0.6.9

Host triple: x86_64-unknown-linux-gnu

Reproduce with:

cargo bisect-rustc --script=script.sh --start=2024-09-02 

script.sh is this, where I looked at the doc output and answered "yes" if it had "since 1.2.0" for StableStruct::method, and "no" if it had "nightly-only" (zenity is a dialog box program that exits successfully for "yes" and unsuccessfully for "no" in --question mode.

#!/bin/bash
cargo doc --open
zenity --question --text="is it right?"

crate source is this:

// src/lib.rs
#![allow(internal_features)]
#![feature(staged_api)]
#![stable(feature = "crate_stability", since = "1.0.0")]

#[stable(feature = "struct_stability", since = "1.1.0")]
#[non_exhaustive]
pub struct StableStruct;

mod module;
// src/module.rs
#![unstable(feature = "module_stability", issue = "none")]

impl super::StableStruct {
    #[stable(feature = "method_stability", since = "1.2.0")]
    pub fn method(&self) {}
}

"good" result:
Image

"bad" result:
Image

@zachs18 zachs18 added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Nov 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 1, 2024
@jieyouxu jieyouxu added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 1, 2024
@lukas-code lukas-code added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Nov 1, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 1, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 2, 2024
…omez

rustdoc: skip stability inheritance for some item kinds

For some item kinds it's incorrect to inherit their parent's stability, because they might be accessible without referring to the parent directly -- This PR removes the stability inheritance for these items and reverts their displayed stability to that before rust-lang#130798.

Impl items, both inherent and trait impls, have a stability, but it is ignored when checking for enabled features. However, impl items are automatically unstable if they're nested inside an unstable module -- this caused the children of impl to inherit the instability and lead to rust-lang#132440.

Furthermore, for associated items only the stability of the associated item itself is checked and not that of its parent impl. This is true even for trait impls and we have [relied on this behavior in the standard library in the past](https://doc.rust-lang.org/1.37.0/std/slice/trait.SliceConcatExt.html#tymethod.concat), so these also shouldn't inherit the impl's stability.

I've also removed the stability inheritance for primitives and keywords so that viewing e.g. [the `i32` docs on `core`](https://doc.rust-lang.org/nightly/core/primitive.i32.html) will no longer show "since 1.6.0". Note that we currently don't annotate stability for the keyword docs, but if we start doing so in the future then this is probably more correct.

fixes (after backport) rust-lang#132440
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 2, 2024
Rollup merge of rust-lang#132481 - lukas-code:doc-stab3, r=GuillaumeGomez

rustdoc: skip stability inheritance for some item kinds

For some item kinds it's incorrect to inherit their parent's stability, because they might be accessible without referring to the parent directly -- This PR removes the stability inheritance for these items and reverts their displayed stability to that before rust-lang#130798.

Impl items, both inherent and trait impls, have a stability, but it is ignored when checking for enabled features. However, impl items are automatically unstable if they're nested inside an unstable module -- this caused the children of impl to inherit the instability and lead to rust-lang#132440.

Furthermore, for associated items only the stability of the associated item itself is checked and not that of its parent impl. This is true even for trait impls and we have [relied on this behavior in the standard library in the past](https://doc.rust-lang.org/1.37.0/std/slice/trait.SliceConcatExt.html#tymethod.concat), so these also shouldn't inherit the impl's stability.

I've also removed the stability inheritance for primitives and keywords so that viewing e.g. [the `i32` docs on `core`](https://doc.rust-lang.org/nightly/core/primitive.i32.html) will no longer show "since 1.6.0". Note that we currently don't annotate stability for the keyword docs, but if we start doing so in the future then this is probably more correct.

fixes (after backport) rust-lang#132440
@jieyouxu jieyouxu removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 8, 2024
@zachs18
Copy link
Contributor Author

zachs18 commented Nov 11, 2024

Beta docs and nightly docs now list the correct stabilization version for these methods. (nightly from #132481, and on beta from #132733).

@zachs18 zachs18 closed this as completed Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants