Skip to content

Commit 3265dc7

Browse files
committed
Add test for issue-66868
1 parent 6ec3a63 commit 3265dc7

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// edition:2018
2+
3+
#![crate_type = "lib"]
4+
5+
use std::{
6+
future::Future,
7+
pin::Pin,
8+
sync::RwLock,
9+
task::{Context, Poll},
10+
};
11+
12+
struct S {}
13+
14+
impl Future for S {
15+
type Output = ();
16+
fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
17+
Poll::Pending
18+
}
19+
}
20+
21+
pub async fn f() {
22+
let fo = RwLock::new(S {});
23+
24+
(&mut *fo.write().unwrap()).await;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Fixed by #67071
2+
// aux-build: issue_66868_closure_typeck.rs
3+
// edition:2018
4+
5+
extern crate issue_66868_closure_typeck;
6+
7+
pub fn g<T>(task: T)
8+
where
9+
T: Send,
10+
{
11+
}
12+
13+
fn main() {
14+
g(issue_66868_closure_typeck::f()); //~ ERROR: cannot be sent between threads safely
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0277]: `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>` cannot be sent between threads safely
2+
--> $DIR/issue-66868-closure-typeck.rs:14:5
3+
|
4+
LL | pub fn g<T>(task: T)
5+
| -
6+
LL | where
7+
LL | T: Send,
8+
| ---- required by this bound in `g`
9+
...
10+
LL | g(issue_66868_closure_typeck::f());
11+
| ^ `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>` cannot be sent between threads safely
12+
|
13+
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::RwLockWriteGuard<'_, issue_66868_closure_typeck::S>`
14+
= note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}`
15+
= note: required because it appears within the type `[static generator@DefId(14:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]`
16+
= note: required because it appears within the type `std::future::GenFuture<[static generator@DefId(14:16 ~ issue_66868_closure_typeck[8787]::f[0]::{{closure}}[0]) for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5> {std::sync::RwLock<issue_66868_closure_typeck::S>, &'r std::sync::RwLock<issue_66868_closure_typeck::S>, std::sync::RwLock<issue_66868_closure_typeck::S>, std::result::Result<std::sync::RwLockWriteGuard<'s, issue_66868_closure_typeck::S>, std::sync::PoisonError<std::sync::RwLockWriteGuard<'t0, issue_66868_closure_typeck::S>>>, &'t1 mut std::sync::RwLockWriteGuard<'t2, issue_66868_closure_typeck::S>, std::sync::RwLockWriteGuard<'t3, issue_66868_closure_typeck::S>, issue_66868_closure_typeck::S, &'t4 mut issue_66868_closure_typeck::S, &'t5 mut issue_66868_closure_typeck::S, ()}]>`
17+
= note: required because it appears within the type `impl std::future::Future`
18+
= note: required because it appears within the type `impl std::future::Future`
19+
20+
error: aborting due to previous error
21+
22+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)