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

Merged
merged 5 commits into from
Oct 22, 2024

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?

tokio/src/runtime/task/mod.rs Show resolved Hide resolved
tokio/src/lib.rs Show resolved Hide resolved
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 7aaac8a4

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 6b438c15

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.

Thank you.

@Darksonn Darksonn merged commit 92ccade into tokio-rs:master Oct 22, 2024
87 checks passed
@joshka joshka deleted the jm/fix-stability-docs branch October 22, 2024 10:47
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