From 5468d9805aba869e7712b5aadabb021e692ba1d0 Mon Sep 17 00:00:00 2001 From: 1000teslas <47207223+1000teslas@users.noreply.github.com> Date: Fri, 15 Jan 2021 16:50:48 +1100 Subject: [PATCH] Simplify E0373 async code example --- .../src/error_codes/E0373.md | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0373.md b/compiler/rustc_error_codes/src/error_codes/E0373.md index 540a88a0d95..effa597aad9 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0373.md +++ b/compiler/rustc_error_codes/src/error_codes/E0373.md @@ -54,35 +54,18 @@ about safety. This error may also be encountered while using `async` blocks: ```compile_fail,E0373,edition2018 -use std::{sync::Arc, future::Future, pin::Pin, task::{Context, Poll}}; +use std::future::Future; async fn f() { - let v = Arc::new(Vec::new()); - - let handle = spawn(async { //~ ERROR E0373 - g(Arc::clone(&v)) + let v = vec![1, 2, 3i32]; + spawn(async { //~ ERROR E0373 + println!("{:?}", v) }); - handle.await; } -fn g(v: Arc>) {} - -fn spawn(future: F) -> JoinHandle -where - F: Future + Send + 'static, - F::Output: Send + 'static, -{ +fn spawn(future: F) { unimplemented!() } - -struct JoinHandle; - -impl Future for JoinHandle { - type Output = (); - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - unimplemented!() - } -} ``` Similarly to closures, `async` blocks are not executed immediately and may