Rollup merge of #72141 - kornelski:dontsleep, r=joshtriplett

Warn against thread::sleep in async fn

I've seen `thread::sleep` wrecking havoc in async servers. There's already an [issue for clippy](https://github.com/rust-lang/rust-clippy/issues/4377), but the std docs could warn against it too.
This commit is contained in:
Dylan DPC 2020-05-14 18:21:53 +02:00 committed by GitHub
commit d732aeff91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -737,6 +737,8 @@ pub fn panicking() -> bool {
/// The thread may sleep longer than the duration specified due to scheduling
/// specifics or platform-dependent functionality. It will never sleep less.
///
/// This function is blocking, and should not be used in `async` functions.
///
/// # Platform-specific behavior
///
/// On Unix platforms, the underlying syscall may be interrupted by a
@ -763,6 +765,8 @@ pub fn sleep_ms(ms: u32) {
/// The thread may sleep longer than the duration specified due to scheduling
/// specifics or platform-dependent functionality. It will never sleep less.
///
/// This function is blocking, and should not be used in `async` functions.
///
/// # Platform-specific behavior
///
/// On Unix platforms, the underlying syscall may be interrupted by a