summaryrefslogtreecommitdiffstats
path: root/tokio-macros
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-06-25 20:14:21 -0700
committerGitHub <noreply@github.com>2019-06-25 20:14:21 -0700
commitdc5fa80a09ff65728d5e9848f2efc1b83de38741 (patch)
tree5d0211429f43f8be96099be60fbcb1c721a37a6b /tokio-macros
parent455782b964df5ea96101085d55298f52fe425bc7 (diff)
macros: re-export `main` macro from `tokio` (#1198)
Includes minor fixes and a very basic example. Fixes #1183
Diffstat (limited to 'tokio-macros')
-rw-r--r--tokio-macros/src/lib.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs
index 000b3773..80c838e6 100644
--- a/tokio-macros/src/lib.rs
+++ b/tokio-macros/src/lib.rs
@@ -17,9 +17,11 @@ use syn::spanned::Spanned;
/// ```
/// #[tokio::main]
/// async fn main() {
-/// println!("Hello world");
+/// println!("Hello from Tokio!");
/// }
+/// ```
#[proc_macro_attribute]
+#[cfg(not(test))] // Work around for rust-lang/rust#62127
pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(item as syn::ItemFn);
@@ -38,7 +40,7 @@ pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
let result = quote! {
fn #name() #ret {
let mut rt = tokio::runtime::Runtime::new().unwrap();
- rt.block_on_async(async { #body })
+ rt.block_on(async { #body })
}
};
@@ -49,7 +51,7 @@ pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
///
/// # Examples
///
-/// ```
+/// ```ignore
/// #[tokio::test]
/// async fn my_test() {
/// assert!(true);