1
Fork 0

Move help link to error index

This commit is contained in:
1000teslas 2021-01-13 23:37:49 +11:00
parent 3ee3071344
commit 7f41465f6d
2 changed files with 23 additions and 3 deletions

View file

@ -50,3 +50,25 @@ fn foo() -> Box<Fn(u32) -> u32> {
Now that the closure has its own copy of the data, there's no need to worry Now that the closure has its own copy of the data, there's no need to worry
about safety. about safety.
This error may also be encountered while using `async` blocks:
```compile_fail,E0373
use std::sync::Arc;
use tokio::runtime::Runtime; // 0.3.1
async fn f() {
let room_ref = Arc::new(Vec::new());
let gameloop_handle = Runtime::new().unwrap().spawn(async {
game_loop(Arc::clone(&room_ref))
});
gameloop_handle.await;
}
fn game_loop(v: Arc<Vec<usize>>) {}
```
Similarly to closures, `async` blocks are not executed immediately and may
capture closed-over data by reference. For more information, see
https://rust-lang.github.io/async-book/03_async_await/01_chapter.html.

View file

@ -1335,11 +1335,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if matches!(generator_kind, GeneratorKind::Async(_))) if matches!(generator_kind, GeneratorKind::Async(_)))
{ {
err.note( err.note(
"async blocks are not executed immediately and either must take a \ "async blocks are not executed immediately and must either take a \
reference or ownership of outside variables they use", reference or ownership of outside variables they use",
); );
err.help("see https://rust-lang.github.io/async-book/03_async_await/01_chapter.html#awaiting-on-a-multithreaded-executor \
for more information");
} else { } else {
let msg = format!("function requires argument type to outlive `{}`", fr_name); let msg = format!("function requires argument type to outlive `{}`", fr_name);
err.span_note(constraint_span, &msg); err.span_note(constraint_span, &msg);