about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-04-16 10:09:59 +0900
committerYuki Okushi <huyuumi.dev@gmail.com>2020-04-17 06:16:15 +0900
commit0b85356387876b2482e3161bc4e8797193bec669 (patch)
tree23c68d832d4e172d1c453d8e59ca318d911efc78
parent119bbbe31a2101d6d6b457b7814a12fcc39f1934 (diff)
downloadrust-0b85356387876b2482e3161bc4e8797193bec669.tar.gz
rust-0b85356387876b2482e3161bc4e8797193bec669.zip
Add test for issue-67893
-rw-r--r--src/test/ui/async-await/issues/auxiliary/issue_67893.rs10
-rw-r--r--src/test/ui/async-await/issues/issue-67893.rs11
-rw-r--r--src/test/ui/async-await/issues/issue-67893.stderr24
3 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issues/auxiliary/issue_67893.rs b/src/test/ui/async-await/issues/auxiliary/issue_67893.rs
new file mode 100644
index 00000000000..387966a5064
--- /dev/null
+++ b/src/test/ui/async-await/issues/auxiliary/issue_67893.rs
@@ -0,0 +1,10 @@
+// edition:2018
+
+use std::sync::{Arc, Mutex};
+
+pub async fn f(_: ()) {}
+
+pub async fn run() {
+    let x: Arc<Mutex<()>> = unimplemented!();
+    f(*x.lock().unwrap()).await;
+}
diff --git a/src/test/ui/async-await/issues/issue-67893.rs b/src/test/ui/async-await/issues/issue-67893.rs
new file mode 100644
index 00000000000..9679e3807b6
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-67893.rs
@@ -0,0 +1,11 @@
+// aux-build: issue_67893.rs
+// edition:2018
+
+extern crate issue_67893;
+
+fn g(_: impl Send) {}
+
+fn main() {
+    g(issue_67893::run())
+    //~^ ERROR: `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
+}
diff --git a/src/test/ui/async-await/issues/issue-67893.stderr b/src/test/ui/async-await/issues/issue-67893.stderr
new file mode 100644
index 00000000000..567a4c91b55
--- /dev/null
+++ b/src/test/ui/async-await/issues/issue-67893.stderr
@@ -0,0 +1,24 @@
+error[E0277]: `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
+  --> $DIR/issue-67893.rs:9:5
+   |
+LL | fn g(_: impl Send) {}
+   |              ---- required by this bound in `g`
+...
+LL |     g(issue_67893::run())
+   |     ^ `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely
+   | 
+  ::: $DIR/auxiliary/issue_67893.rs:7:20
+   |
+LL | pub async fn run() {
+   |                    - within this `impl std::future::Future`
+   |
+   = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard<'_, ()>`
+   = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3> {std::future::ResumeTy, std::sync::Arc<std::sync::Mutex<()>>, &'r std::sync::Mutex<()>, std::result::Result<std::sync::MutexGuard<'s, ()>, std::sync::PoisonError<std::sync::MutexGuard<'t0, ()>>>, &'t1 std::sync::MutexGuard<'t2, ()>, std::sync::MutexGuard<'t3, ()>, (), impl std::future::Future}`
+   = note: required because it appears within the type `[static generator@DefId(15:11 ~ issue_67893[8787]::run[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3> {std::future::ResumeTy, std::sync::Arc<std::sync::Mutex<()>>, &'r std::sync::Mutex<()>, std::result::Result<std::sync::MutexGuard<'s, ()>, std::sync::PoisonError<std::sync::MutexGuard<'t0, ()>>>, &'t1 std::sync::MutexGuard<'t2, ()>, std::sync::MutexGuard<'t3, ()>, (), impl std::future::Future}]`
+   = note: required because it appears within the type `std::future::from_generator::GenFuture<[static generator@DefId(15:11 ~ issue_67893[8787]::run[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3> {std::future::ResumeTy, std::sync::Arc<std::sync::Mutex<()>>, &'r std::sync::Mutex<()>, std::result::Result<std::sync::MutexGuard<'s, ()>, std::sync::PoisonError<std::sync::MutexGuard<'t0, ()>>>, &'t1 std::sync::MutexGuard<'t2, ()>, std::sync::MutexGuard<'t3, ()>, (), impl std::future::Future}]>`
+   = note: required because it appears within the type `impl std::future::Future`
+   = note: required because it appears within the type `impl std::future::Future`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.