]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/issue-71137.rs
Auto merge of #103217 - mejrs:track, r=eholk
[rust.git] / src / test / ui / async-await / issue-71137.rs
1 // edition:2018
2 #![feature(must_not_suspend)]
3 #![allow(must_not_suspend)]
4
5 use std::future::Future;
6 use std::sync::Mutex;
7
8 fn fake_spawn<F: Future + Send + 'static>(f: F) { }
9
10 async fn wrong_mutex() {
11   let m = Mutex::new(1);
12   {
13     let mut guard = m.lock().unwrap();
14     (async { "right"; }).await;
15     *guard += 1;
16   }
17
18   (async { "wrong"; }).await;
19 }
20
21 fn main() {
22   fake_spawn(wrong_mutex()); //~ Error future cannot be sent between threads safely
23 }