SHARE
TWEET

Untitled

a guest Sep 15th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5.     println!("{:?}", {
  6.         async fn foo() { 5 } foo().await
  7.     });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12.    Compiling playground v0.0.1 (/playground)
  13. error[E0728]: `await` is only allowed inside `async` functions and blocks
  14.  --> src/main.rs:6:30
  15.   |
  16. 4 | fn main() {
  17.   |    ---- this is not `async`
  18. 5 |     println!("{:?}", {
  19. 6 |         async fn foo() { 5 } foo().await
  20.   |                              ^^^^^^^^^^^ only allowed inside `async` functions and blocks
  21.  
  22. error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
  23.  --> src/main.rs:6:24
  24.   |
  25. 6 |         async fn foo() { 5 } foo().await
  26.   |                        ^ expected integer, found ()
  27.   |
  28.   = note: expected type `{integer}`
  29.              found type `()`
  30.   = note: the return type of a function must have a statically known size
  31.  
  32. error: aborting due to 2 previous errors
  33.  
  34. For more information about this error, try `rustc --explain E0271`.
  35. error: Could not compile `playground`.
  36.  
  37. To learn more, run the command again with --verbose.
  38.  
  39. */
  40.  
  41. /* ~~~~=== stdout ===~~~~
  42.  
  43. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top