Skip to content

Commit ce5d2a4

Browse files
authored
task: fix some doc and test things related to stabilizing JoinSet (#4965)
1 parent e5467ca commit ce5d2a4

6 files changed

Lines changed: 25 additions & 36 deletions

File tree

tokio/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@
349349
//! Likewise, some parts of the API are only available with the same flag:
350350
//!
351351
//! - [`task::Builder`]
352-
//!
352+
//! - Some methods on [`task::JoinSet`]
353+
//! - [`runtime::RuntimeMetrics`]
354+
//! - [`runtime::Builder::unhandled_panic`]
355+
//! - [`task::Id`]
356+
//!
353357
//! This flag enables **unstable** features. The public API of these features
354358
//! may break in 1.x releases. To enable these features, the `--cfg
355359
//! tokio_unstable` argument must be passed to `rustc` when compiling. This

tokio/src/macros/cfg.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,6 @@ macro_rules! cfg_unstable {
406406
};
407407
}
408408

409-
macro_rules! cfg_not_unstable {
410-
($($item:item)*) => {
411-
$(
412-
#[cfg(not(tokio_unstable))]
413-
#[cfg_attr(docsrs, doc(cfg(not(tokio_unstable))))]
414-
$item
415-
)*
416-
};
417-
}
418-
419409
macro_rules! cfg_not_trace {
420410
($($item:item)*) => {
421411
$(

tokio/src/runtime/tests/loom_join_set.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg(tokio_unstable)]
21
use crate::runtime::Builder;
32
use crate::task::JoinSet;
43

tokio/src/task/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,14 @@ cfg_rt! {
311311
pub use join_set::JoinSet;
312312
pub use crate::runtime::task::AbortHandle;
313313

314-
cfg_not_unstable! {
315-
mod join_set;
316-
}
314+
// Uses #[cfg(...)] instead of macro since the macro adds docsrs annotations.
315+
#[cfg(not(tokio_unstable))]
316+
mod join_set;
317+
#[cfg(tokio_unstable)]
318+
pub mod join_set;
317319

318320
cfg_unstable! {
319321
pub use crate::runtime::task::Id;
320-
321-
pub mod join_set;
322322
}
323323

324324
cfg_trace! {

tokio/tests/async_send_sync.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,14 @@ assert_value!(tokio::sync::watch::Ref<'_, YY>: !Send & Sync & Unpin);
394394
assert_value!(tokio::sync::watch::Sender<NN>: !Send & !Sync & Unpin);
395395
assert_value!(tokio::sync::watch::Sender<YN>: !Send & !Sync & Unpin);
396396
assert_value!(tokio::sync::watch::Sender<YY>: Send & Sync & Unpin);
397+
assert_value!(tokio::task::JoinError: Send & Sync & Unpin);
398+
assert_value!(tokio::task::JoinHandle<NN>: !Send & !Sync & Unpin);
399+
assert_value!(tokio::task::JoinHandle<YN>: Send & Sync & Unpin);
400+
assert_value!(tokio::task::JoinHandle<YY>: Send & Sync & Unpin);
401+
assert_value!(tokio::task::JoinSet<NN>: !Send & !Sync & Unpin);
402+
assert_value!(tokio::task::JoinSet<YN>: Send & Sync & Unpin);
403+
assert_value!(tokio::task::JoinSet<YY>: Send & Sync & Unpin);
404+
assert_value!(tokio::task::LocalSet: !Send & !Sync & Unpin);
397405
async_assert_fn!(tokio::sync::Barrier::wait(_): Send & Sync & !Unpin);
398406
async_assert_fn!(tokio::sync::Mutex<NN>::lock(_): !Send & !Sync & !Unpin);
399407
async_assert_fn!(tokio::sync::Mutex<NN>::lock_owned(_): !Send & !Sync & !Unpin);
@@ -466,6 +474,12 @@ async_assert_fn!(tokio::sync::watch::Receiver<YY>::changed(_): Send & Sync & !Un
466474
async_assert_fn!(tokio::sync::watch::Sender<NN>::closed(_): !Send & !Sync & !Unpin);
467475
async_assert_fn!(tokio::sync::watch::Sender<YN>::closed(_): !Send & !Sync & !Unpin);
468476
async_assert_fn!(tokio::sync::watch::Sender<YY>::closed(_): Send & Sync & !Unpin);
477+
async_assert_fn!(tokio::task::JoinSet<Cell<u32>>::join_next(_): Send & Sync & !Unpin);
478+
async_assert_fn!(tokio::task::JoinSet<Cell<u32>>::shutdown(_): Send & Sync & !Unpin);
479+
async_assert_fn!(tokio::task::JoinSet<Rc<u32>>::join_next(_): !Send & !Sync & !Unpin);
480+
async_assert_fn!(tokio::task::JoinSet<Rc<u32>>::shutdown(_): !Send & !Sync & !Unpin);
481+
async_assert_fn!(tokio::task::JoinSet<u32>::join_next(_): Send & Sync & !Unpin);
482+
async_assert_fn!(tokio::task::JoinSet<u32>::shutdown(_): Send & Sync & !Unpin);
469483
async_assert_fn!(tokio::task::LocalKey<Cell<u32>>::scope(_, Cell<u32>, BoxFuture<()>): !Send & !Sync & !Unpin);
470484
async_assert_fn!(tokio::task::LocalKey<Cell<u32>>::scope(_, Cell<u32>, BoxFutureSend<()>): Send & !Sync & !Unpin);
471485
async_assert_fn!(tokio::task::LocalKey<Cell<u32>>::scope(_, Cell<u32>, BoxFutureSync<()>): Send & !Sync & !Unpin);
@@ -479,24 +493,6 @@ async_assert_fn!(tokio::task::LocalSet::run_until(_, BoxFutureSync<()>): !Send &
479493
async_assert_fn!(tokio::task::unconstrained(BoxFuture<()>): !Send & !Sync & Unpin);
480494
async_assert_fn!(tokio::task::unconstrained(BoxFutureSend<()>): Send & !Sync & Unpin);
481495
async_assert_fn!(tokio::task::unconstrained(BoxFutureSync<()>): Send & Sync & Unpin);
482-
assert_value!(tokio::task::JoinError: Send & Sync & Unpin);
483-
assert_value!(tokio::task::JoinHandle<NN>: !Send & !Sync & Unpin);
484-
assert_value!(tokio::task::JoinHandle<YN>: Send & Sync & Unpin);
485-
assert_value!(tokio::task::JoinHandle<YY>: Send & Sync & Unpin);
486-
#[cfg(tokio_unstable)]
487-
mod unstable {
488-
use super::*;
489-
async_assert_fn!(tokio::task::JoinSet<Cell<u32>>::join_next(_): Send & Sync & !Unpin);
490-
async_assert_fn!(tokio::task::JoinSet<Cell<u32>>::shutdown(_): Send & Sync & !Unpin);
491-
async_assert_fn!(tokio::task::JoinSet<Rc<u32>>::join_next(_): !Send & !Sync & !Unpin);
492-
async_assert_fn!(tokio::task::JoinSet<Rc<u32>>::shutdown(_): !Send & !Sync & !Unpin);
493-
async_assert_fn!(tokio::task::JoinSet<u32>::join_next(_): Send & Sync & !Unpin);
494-
async_assert_fn!(tokio::task::JoinSet<u32>::shutdown(_): Send & Sync & !Unpin);
495-
assert_value!(tokio::task::JoinSet<YY>: Send & Sync & Unpin);
496-
assert_value!(tokio::task::JoinSet<YN>: Send & Sync & Unpin);
497-
assert_value!(tokio::task::JoinSet<NN>: !Send & !Sync & Unpin);
498-
assert_value!(tokio::task::LocalSet: !Send & !Sync & Unpin);
499-
}
500496

501497
assert_value!(tokio::runtime::Builder: Send & Sync & Unpin);
502498
assert_value!(tokio::runtime::EnterGuard<'_>: Send & Sync & Unpin);

tokio/tests/task_join_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(rust_2018_idioms)]
2-
#![cfg(all(feature = "full", tokio_unstable))]
2+
#![cfg(all(feature = "full"))]
33

44
use tokio::sync::oneshot;
55
use tokio::task::JoinSet;

0 commit comments

Comments
 (0)