From https://rust-lang.github.io/async-book/03_async_await/01_chapter.html:
Note that, when using a multithreaded
Future
executor, aFuture
may move between threads, so any variables used inasync
bodies must be able to travel between threads, as any.await
can potentially result in a switch to a new thread.
This means that it is not safe to useRc
,&RefCell
or any other types that don't implement theSend
trait, including references to types that don't implement theSync
trait.
Does Rust actually compiles when Rc
is referenced in an async
body? I.e., should I manually think about this situation, or will Rust make sure such situation always cause a compile error?