From b36aeb383a31ad8317ccbd5ec9d05ad9e9f5cb1b Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Tue, 26 Nov 2024 15:44:53 -0800 Subject: [PATCH] Add troubleshooting section to hello-tokio Fixes: https://github.com/tokio-rs/website/issues/461 --- content/tokio/tutorial/hello-tokio.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/content/tokio/tutorial/hello-tokio.md b/content/tokio/tutorial/hello-tokio.md index 1d77c26b..9ef326b0 100644 --- a/content/tokio/tutorial/hello-tokio.md +++ b/content/tokio/tutorial/hello-tokio.md @@ -96,6 +96,24 @@ You can find the full code [here][full]. [full]: https://github.com/tokio-rs/website/blob/master/tutorial-code/hello-tokio/src/main.rs +# Troubleshooting + +A common mistake is to forget to add `.await` on calls to asynchronous +functions. This is particularly easy to forget for functions where the return +value is not used by the application. The compiler warns you and teaches you how +to fix this error. + +```plain +warning: unused implementer of `std::future::Future` that must be used + --> examples/hello-redis.rs:12:5 + | +12 | client.set("hello", "world".into()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: futures do nothing unless you `.await` or poll them + = note: `#[warn(unused_must_use)]` on by default +``` + # Breaking it down Let's take some time to go over what we just did. There isn't much code, but a