Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  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. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement