Skip to content

rt: Mention LocalRuntime in the new_current_thread builder#7820

Merged
Darksonn merged 2 commits intotokio-rs:masterfrom
mattiapitossi:update-builder-docs-for-local-runtime
Jan 2, 2026
Merged

rt: Mention LocalRuntime in the new_current_thread builder#7820
Darksonn merged 2 commits intotokio-rs:masterfrom
mattiapitossi:update-builder-docs-for-local-runtime

Conversation

@mattiapitossi
Copy link
Contributor

Motivation

I notice we don't mention the LocalRuntime on the new_current_thread docs in the Runtime Builder.

Solution

Mention the possibility to spawn non-Send task on the current thread runtime with LocalRuntime.

image

@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels Jan 2, 2026
Copy link
Member

@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.

Thanks!

@Darksonn Darksonn merged commit 16f20c3 into tokio-rs:master Jan 2, 2026
98 checks passed
@mattiapitossi mattiapitossi deleted the update-builder-docs-for-local-runtime branch January 2, 2026 16:36
///
/// To spawn non-`Send` tasks on the resulting runtime, combine it with a
/// [`LocalSet`].
/// [`LocalSet`], or call [`build_local`] to create a [`LocalRuntime`] (unstable).
Copy link
Member

Choose a reason for hiding this comment

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

I wanted to test that (unstable) is not used as a target for [LocalRuntime] - it is not! All good here!

But "[LocalRuntime]: crate::runtime::LocalRuntime" and "[build_local]: crate::runtime::Builder::build_local" below are broken for me.

Image

cargo doc reports many broken items:

 cargo doc
warning: unresolved link to `task::Builder`
   --> tokio/src/lib.rs:357:9
    |
357 | //! - [`task::Builder`]
    |         ^^^^^^^^^^^^^ no item named `Builder` in module `task`
    |
    = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: unresolved link to `runtime::Builder::on_task_spawn`
   --> tokio/src/lib.rs:360:9
    |
360 | //! - [`runtime::Builder::on_task_spawn`]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `Builder` has no field or associated item named `on_task_spawn`

warning: unresolved link to `runtime::Builder::on_task_terminate`
   --> tokio/src/lib.rs:361:9
    |
361 | //! - [`runtime::Builder::on_task_terminate`]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `Builder` has no field or associated item named `on_task_terminate`

warning: unresolved link to `runtime::Builder::unhandled_panic`
   --> tokio/src/lib.rs:362:9
    |
362 | //! - [`runtime::Builder::unhandled_panic`]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `Builder` has no field or associated item named `unhandled_panic`

warning: public documentation for `tokio` links to private item `runtime::TaskMeta`
   --> tokio/src/lib.rs:363:9
    |
363 | //! - [`runtime::TaskMeta`]
    |         ^^^^^^^^^^^^^^^^^ this item is private
    |
    = note: this link will resolve properly if you pass `--document-private-items`
    = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default

warning: unresolved link to `windows::named_pipe`
  --> tokio/src/net/mod.rs:28:42
   |
28 | //! [`tokio::net::windows::named_pipe`]: windows::named_pipe
   |                                          ^^^^^^^^^^^^^^^^^^^ no item named `windows` in scope

warning: public documentation for `runtime` links to private item `crate::runtime::Builder::disable_lifo_slot`
   --> tokio/src/runtime/mod.rs:366:35
    |
366 | //! [the lifo slot optimization]: crate::runtime::Builder::disable_lifo_slot
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
    |
    = note: this link will resolve properly if you pass `--document-private-items`

warning: unresolved link to `crate::runtime::RuntimeMetrics::worker_mean_poll_time`
   --> tokio/src/runtime/mod.rs:368:32
    |
368 | //! [`worker_mean_poll_time`]: crate::runtime::RuntimeMetrics::worker_mean_poll_time
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `RuntimeMetrics` has no field or associated item named `worker_mean_poll_time`

warning: public documentation for `runtime` links to private item `crate::runtime::Builder::disable_lifo_slot`
   --> tokio/src/runtime/mod.rs:365:28
    |
365 | //! [`disable_lifo_slot`]: crate::runtime::Builder::disable_lifo_slot
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
    |
    = note: this link will resolve properly if you pass `--document-private-items`

warning: unresolved link to `crate::runtime::Builder::build_local`
   --> tokio/src/runtime/builder.rs:245:26
    |
245 |     /// [`build_local`]: crate::runtime::Builder::build_local
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `Builder` has no field or associated item named `build_local`

warning: unresolved link to `crate::runtime::LocalRuntime`
   --> tokio/src/runtime/builder.rs:244:27
    |
244 |     /// [`LocalRuntime`]: crate::runtime::LocalRuntime
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `LocalRuntime` in module `runtime`

warning: unresolved link to `crate::runtime::LocalRuntime`
   --> tokio/src/task/local.rs:395:27
    |
395 |     /// [`LocalRuntime`]: struct@crate::runtime::LocalRuntime
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `LocalRuntime` in module `runtime`

warning: unresolved link to `crate::runtime::LocalRuntime`
   --> tokio/src/task/join_set.rs:183:27
    |
183 |     /// [`LocalRuntime`]: crate::runtime::LocalRuntime
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `LocalRuntime` in module `runtime`

warning: `tokio` (lib doc) generated 13 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
   Generated /home/martin/git/rust/tokio/target/doc/tests_build/index.html and 7 other files

@Darksonn Maybe these should be fixed for 1.49.0 ?

Copy link
Member

Choose a reason for hiding this comment

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

Docs should be built with unstable features enabled. I suspect the links are not broken in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Right! Thanks!

With --cfg tokio_unstable only two links are not resolved:

$ RUSTDOCFLAGS="--cfg tokio_unstable" cargo doc --open
...
warning: unresolved link to `task::Builder`
   --> tokio/src/lib.rs:357:9
    |
357 | //! - [`task::Builder`]
    |         ^^^^^^^^^^^^^ no item named `Builder` in module `task`
    |
    = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: unresolved link to `windows::named_pipe`
  --> tokio/src/net/mod.rs:28:42
   |
28 | //! [`tokio::net::windows::named_pipe`]: windows::named_pipe
   |                                          ^^^^^^^^^^^^^^^^^^^ no item named `windows` in scope

warning: `tokio` (lib doc) generated 2 warnings

Let me compare it with the CI job to see what else I might be missing!

Copy link
Member

Choose a reason for hiding this comment

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

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 T-docs Topic: documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants