Skip to content

Commit 174135f

Browse files
Fix error E0373 documentation
1 parent a9ead34 commit 174135f

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

compiler/rustc_error_codes/src/error_codes/E0373.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,35 @@ about safety.
5454
This error may also be encountered while using `async` blocks:
5555

5656
```compile_fail,E0373
57-
use std::sync::Arc;
58-
use tokio::runtime::Runtime; // 0.3.1
57+
use std::{sync::Arc, future::Future, pin::Pin, task::{Context, Poll}};
5958
6059
async fn f() {
61-
let room_ref = Arc::new(Vec::new());
60+
let v = Arc::new(Vec::new());
6261
63-
let gameloop_handle = Runtime::new().unwrap().spawn(async {
64-
game_loop(Arc::clone(&room_ref))
62+
let handle = spawn(async { //~ ERROR E0373
63+
g(Arc::clone(&v))
6564
});
66-
gameloop_handle.await;
65+
handle.await;
6766
}
6867
69-
fn game_loop(v: Arc<Vec<usize>>) {}
68+
fn g(v: Arc<Vec<usize>>) {}
69+
70+
fn spawn<F>(future: F) -> JoinHandle
71+
where
72+
F: Future + Send + 'static,
73+
F::Output: Send + 'static,
74+
{
75+
unimplemented!()
76+
}
77+
78+
struct JoinHandle;
79+
80+
impl Future for JoinHandle {
81+
type Output = ();
82+
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
83+
unimplemented!()
84+
}
85+
}
7086
```
7187

7288
Similarly to closures, `async` blocks are not executed immediately and may

src/test/ui/async-await/issues/issue-78938-async-block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// edition:2018
22

3-
use std::{sync::Arc, future::Future, pin::Pin, task::{Context,Poll}};
3+
use std::{sync::Arc, future::Future, pin::Pin, task::{Context, Poll}};
44

55
async fn f() {
66
let room_ref = Arc::new(Vec::new());

0 commit comments

Comments
 (0)