rt: Mention LocalRuntime in the new_current_thread builder#7820
Conversation
| /// | ||
| /// To spawn non-`Send` tasks on the resulting runtime, combine it with a | ||
| /// [`LocalSet`]. | ||
| /// [`LocalSet`], or call [`build_local`] to create a [`LocalRuntime`] (unstable). |
There was a problem hiding this comment.
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.
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 ?
There was a problem hiding this comment.
Docs should be built with unstable features enabled. I suspect the links are not broken in that case.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
https://github.com/tokio-rs/tokio/actions/runs/20660332515/job/59321300223?pr=7820 looks good!
False alarm! Sorry!
Motivation
I notice we don't mention the LocalRuntime on the
new_current_threaddocs in the Runtime Builder.Solution
Mention the possibility to spawn non-Send task on the current thread runtime with LocalRuntime.