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

runtime: fix stability feature flags for docs #6909

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

joshka
Copy link
Contributor

@joshka joshka commented Oct 18, 2024

Motivation

Fixes: #6907

Solution

Adds doc attribute noting the tokio_unstable requirements for various items

@github-actions github-actions bot added R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR labels Oct 18, 2024
Copy link
Contributor Author

@joshka joshka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a sidenote, I wonder if it would be possible to use https://doc.rust-lang.org/rustdoc/unstable-features.html#doc_auto_cfg-automatically-generate-doccfg instead of manually adding all these attributes? Are there places where you would not want the specified items to be documented with their required feature flags? I did see a couple of places where there's a different implementation depending on which flag is in use, perhaps that's the problem here?

@@ -391,7 +391,6 @@ impl<S: 'static> Task<S> {
///
/// [task ID]: crate::task::Id
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has no effect as the method is pub(crate)

//! - [`runtime::Builder::unhandled_panic`]
//! - [`task::Id`]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was stabilized in #6891

tokio/src/runtime/runtime.rs Show resolved Hide resolved
@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels Oct 18, 2024
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately auto cfg docs only works for features and not for --cfg flags like tokio_unstable.

@@ -728,6 +728,7 @@ impl Builder {
/// # }
/// ```
#[cfg(all(not(loom), tokio_unstable))]
#[cfg_attr(docsrs, doc(cfg(all(not(loom), tokio_unstable))))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loom should not be mentioned in docs.

Suggested change
#[cfg_attr(docsrs, doc(cfg(all(not(loom), tokio_unstable))))]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix all instances of this issue. Marking unresolved.

Darksonn and others added 2 commits October 18, 2024 13:23
Comment on lines 730 to 732
#[cfg(all(not(loom), tokio_unstable))]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub fn on_task_spawn<F>(&mut self, f: F) -> &mut Self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the docs blurb about this being unstable.

/// **Note**: This is an [unstable API][unstable]. The public API of this type
/// may break in 1.x releases. See [the documentation on unstable
/// features][unstable] for details.
///
/// [unstable]: crate#unstable-features

I would add it to on_task_spawn, on_task_terminate, and TaskMeta. Probably not to MultiThreadAlt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task spawning hooks specify the wrong stability information
2 participants