Skip to content

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

Closed
@zachs18

Description

@zachs18

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions