]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/issue-71137.rs
Merge commit '9809f5d21990d9e24b3e9876ea7da756fd4e9def' into libgccjit-codegen
[rust.git] / src / test / ui / async-await / issue-71137.rs
1 // edition:2018
2
3 use std::future::Future;
4 use std::sync::Mutex;
5
6 fn fake_spawn<F: Future + Send + 'static>(f: F) { }
7
8 async fn wrong_mutex() {
9   let m = Mutex::new(1);
10   {
11     let mut guard = m.lock().unwrap();
12     (async { "right"; }).await;
13     *guard += 1;
14   }
15
16   (async { "wrong"; }).await;
17 }
18
19 fn main() {
20   fake_spawn(wrong_mutex()); //~ Error future cannot be sent between threads safely
21 }