Mark ab/7061308 as merged in stage.

Bug: 180401296
Merged-In: I7689e32ef22c2c738436a491b2215272e032343c
Change-Id: Icc515d344f3f352daa17059a0f718e2350c44e1f
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index bb691dc..482e2e5 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "171724863db9c82929737d37bd93725e5a5f8af0"
+    "sha1": "d41882e2a18ea4459d8f3a3c7ba61c4c20b806b4"
   }
 }
diff --git a/Android.bp b/Android.bp
index bb0e701..d1a58e1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,22 @@
 // This file is generated by cargo2android.py --run --dependencies --tests.
 
+package {
+    default_applicable_licenses: ["external_rust_crates_tokio-macros_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+    name: "external_rust_crates_tokio-macros_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE",
+    ],
+}
+
 rust_proc_macro {
     name: "libtokio_macros",
     crate_name: "tokio_macros",
@@ -18,6 +35,9 @@
     srcs: ["src/lib.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
     edition: "2018",
     rustlibs: [
         "libproc_macro2",
@@ -29,28 +49,25 @@
 
 // dependent_library ["feature_list"]
 //   autocfg-1.0.1
-//   bytes-0.6.0 "default,std"
-//   cfg-if-0.1.10
+//   bytes-1.0.1 "default,std"
 //   cfg-if-1.0.0
-//   futures-core-0.3.8 "alloc,default,std"
 //   instant-0.1.9
-//   libc-0.2.81 "align,default,std"
+//   libc-0.2.86 "align,default,std"
 //   lock_api-0.4.2
-//   log-0.4.11
+//   log-0.4.14
 //   memchr-2.3.4 "default,std"
-//   mio-0.7.6 "default,net,os-ext,os-poll,os-util,tcp,udp,uds"
+//   mio-0.7.7 "default,net,os-ext,os-poll,os-util,tcp,udp,uds"
 //   num_cpus-1.13.0
 //   once_cell-1.5.2 "alloc,default,std"
 //   parking_lot-0.11.1 "default"
 //   parking_lot_core-0.8.2
-//   pin-project-lite-0.2.0
+//   pin-project-lite-0.2.4
 //   proc-macro2-1.0.24 "default,proc-macro"
 //   quote-1.0.8 "default,proc-macro"
 //   scopeguard-1.1.0
 //   signal-hook-registry-1.3.0
-//   slab-0.4.2
-//   smallvec-1.5.1
-//   syn-1.0.55 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote"
-//   tokio-0.3.6 "bytes,default,fs,full,futures-core,io-std,io-util,libc,macros,memchr,mio,net,num_cpus,once_cell,parking_lot,process,rt,rt-multi-thread,signal,signal-hook-registry,slab,stream,sync,time,tokio-macros,winapi"
-//   tokio-macros-0.3.2
+//   smallvec-1.6.1
+//   syn-1.0.60 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote"
+//   tokio-1.2.0 "bytes,default,fs,full,io-std,io-util,libc,macros,memchr,mio,net,num_cpus,once_cell,parking_lot,process,rt,rt-multi-thread,signal,signal-hook-registry,sync,time,tokio-macros,winapi"
+//   tokio-macros-1.1.0
 //   unicode-xid-0.2.1 "default"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 881da1e..6760b17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,10 @@
-# 0.3.2 (December 19, 2020)
+# 1.1.0 (February 5, 2021)
 
-### Fixed
+- add `start_paused` option to macros ([#3492])
 
-- fix outdated macro documentation ([#3180])
-- add portability note to `tokio::main` ([#3199])
+# 1.0.0 (December 23, 2020)
+
+- track `tokio` 1.0 release.
 
 # 0.3.1 (October 25, 2020)
 
@@ -58,5 +59,4 @@
 [#2177]: https://github.com/tokio-rs/tokio/pull/2177
 [#2225]: https://github.com/tokio-rs/tokio/pull/2225
 [#3038]: https://github.com/tokio-rs/tokio/pull/3038
-[#3180]: https://github.com/tokio-rs/tokio/pull/3180
-[#3199]: https://github.com/tokio-rs/tokio/pull/3199
+[#3492]: https://github.com/tokio-rs/tokio/pull/3492
diff --git a/Cargo.toml b/Cargo.toml
index 4dad0d6..8309bec 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,11 +13,11 @@
 [package]
 edition = "2018"
 name = "tokio-macros"
-version = "0.3.2"
+version = "1.1.0"
 authors = ["Tokio Contributors <team@tokio.rs>"]
 description = "Tokio's proc macros.\n"
 homepage = "https://tokio.rs"
-documentation = "https://docs.rs/tokio-macros/0.3.2/tokio_macros"
+documentation = "https://docs.rs/tokio-macros/1.1.0/tokio_macros"
 categories = ["asynchronous"]
 license = "MIT"
 repository = "https://github.com/tokio-rs/tokio"
@@ -36,7 +36,7 @@
 version = "1.0.3"
 features = ["full"]
 [dev-dependencies.tokio]
-version = "0.3.0"
+version = "1.0.0"
 features = ["full"]
 
 [features]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 7f312e8..ea7b2de 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -6,14 +6,14 @@
 # - Update doc url
 #   - Cargo.toml
 # - Update CHANGELOG.md.
-# - Create "v0.3.x" git tag.
-version = "0.3.2"
+# - Create "tokio-macros-1.0.x" git tag.
+version = "1.1.0"
 edition = "2018"
 authors = ["Tokio Contributors <team@tokio.rs>"]
 license = "MIT"
 repository = "https://github.com/tokio-rs/tokio"
 homepage = "https://tokio.rs"
-documentation = "https://docs.rs/tokio-macros/0.3.2/tokio_macros"
+documentation = "https://docs.rs/tokio-macros/1.1.0/tokio_macros"
 description = """
 Tokio's proc macros.
 """
@@ -30,7 +30,7 @@
 syn = { version = "1.0.3", features = ["full"] }
 
 [dev-dependencies]
-tokio = { version = "0.3.0", path = "../tokio", features = ["full"] }
+tokio = { version = "1.0.0", path = "../tokio", features = ["full"] }
 
 [package.metadata.docs.rs]
 all-features = true
diff --git a/LICENSE b/LICENSE
index 0fbb739..6c6df9c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2019 Tokio Contributors
+Copyright (c) 2020 Tokio Contributors
 
 Permission is hereby granted, free of charge, to any
 person obtaining a copy of this software and associated
diff --git a/METADATA b/METADATA
index bd97fb7..ce4408e 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/tokio-macros/tokio-macros-0.3.2.crate"
+    value: "https://static.crates.io/crates/tokio-macros/tokio-macros-1.1.0.crate"
   }
-  version: "0.3.2"
+  version: "1.1.0"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2020
-    month: 12
-    day: 22
+    year: 2021
+    month: 2
+    day: 9
   }
 }
diff --git a/TEST_MAPPING b/TEST_MAPPING
deleted file mode 100644
index d64ac43..0000000
--- a/TEST_MAPPING
+++ /dev/null
@@ -1,9 +0,0 @@
-// Generated by cargo2android.py for tests in Android.bp
-{
-  "presubmit": [
-    {
-      "host": true,
-      "name": "tokio-macros_host_test_src_lib"
-    }
-  ]
-}
diff --git a/src/entry.rs b/src/entry.rs
index 8f80499..f82a329 100644
--- a/src/entry.rs
+++ b/src/entry.rs
@@ -25,6 +25,7 @@
 struct FinalConfig {
     flavor: RuntimeFlavor,
     worker_threads: Option<usize>,
+    start_paused: Option<bool>,
 }
 
 struct Configuration {
@@ -32,6 +33,7 @@
     default_flavor: RuntimeFlavor,
     flavor: Option<RuntimeFlavor>,
     worker_threads: Option<(usize, Span)>,
+    start_paused: Option<(bool, Span)>,
 }
 
 impl Configuration {
@@ -44,6 +46,7 @@
             },
             flavor: None,
             worker_threads: None,
+            start_paused: None,
         }
     }
 
@@ -79,31 +82,57 @@
         Ok(())
     }
 
+    fn set_start_paused(&mut self, start_paused: syn::Lit, span: Span) -> Result<(), syn::Error> {
+        if self.start_paused.is_some() {
+            return Err(syn::Error::new(span, "`start_paused` set multiple times."));
+        }
+
+        let start_paused = parse_bool(start_paused, span, "start_paused")?;
+        self.start_paused = Some((start_paused, span));
+        Ok(())
+    }
+
     fn build(&self) -> Result<FinalConfig, syn::Error> {
         let flavor = self.flavor.unwrap_or(self.default_flavor);
         use RuntimeFlavor::*;
-        match (flavor, self.worker_threads) {
-            (CurrentThread, Some((_, worker_threads_span))) => Err(syn::Error::new(
-                worker_threads_span,
-                "The `worker_threads` option requires the `multi_thread` runtime flavor.",
-            )),
-            (CurrentThread, None) => Ok(FinalConfig {
-                flavor,
-                worker_threads: None,
-            }),
-            (Threaded, worker_threads) if self.rt_multi_thread_available => Ok(FinalConfig {
-                flavor,
-                worker_threads: worker_threads.map(|(val, _span)| val),
-            }),
+
+        let worker_threads = match (flavor, self.worker_threads) {
+            (CurrentThread, Some((_, worker_threads_span))) => {
+                return Err(syn::Error::new(
+                    worker_threads_span,
+                    "The `worker_threads` option requires the `multi_thread` runtime flavor.",
+                ))
+            }
+            (CurrentThread, None) => None,
+            (Threaded, worker_threads) if self.rt_multi_thread_available => {
+                worker_threads.map(|(val, _span)| val)
+            }
             (Threaded, _) => {
                 let msg = if self.flavor.is_none() {
                     "The default runtime flavor is `multi_thread`, but the `rt-multi-thread` feature is disabled."
                 } else {
                     "The runtime flavor `multi_thread` requires the `rt-multi-thread` feature."
                 };
-                Err(syn::Error::new(Span::call_site(), msg))
+                return Err(syn::Error::new(Span::call_site(), msg));
             }
-        }
+        };
+
+        let start_paused = match (flavor, self.start_paused) {
+            (Threaded, Some((_, start_paused_span))) => {
+                return Err(syn::Error::new(
+                    start_paused_span,
+                    "The `start_paused` option requires the `current_thread` runtime flavor.",
+                ));
+            }
+            (CurrentThread, Some((start_paused, _))) => Some(start_paused),
+            (_, None) => None,
+        };
+
+        Ok(FinalConfig {
+            flavor,
+            worker_threads,
+            start_paused,
+        })
     }
 }
 
@@ -134,6 +163,16 @@
     }
 }
 
+fn parse_bool(bool: syn::Lit, span: Span, field: &str) -> Result<bool, syn::Error> {
+    match bool {
+        syn::Lit::Bool(b) => Ok(b.value),
+        _ => Err(syn::Error::new(
+            span,
+            format!("Failed to parse {} as bool.", field),
+        )),
+    }
+}
+
 fn parse_knobs(
     mut input: syn::ItemFn,
     args: syn::AttributeArgs,
@@ -174,6 +213,9 @@
                     "flavor" => {
                         config.set_flavor(namevalue.lit.clone(), namevalue.span())?;
                     }
+                    "start_paused" => {
+                        config.set_start_paused(namevalue.lit.clone(), namevalue.span())?;
+                    }
                     "core_threads" => {
                         let msg = "Attribute `core_threads` is renamed to `worker_threads`";
                         return Err(syn::Error::new_spanned(namevalue, msg));
@@ -204,11 +246,11 @@
                             macro_name
                         )
                     }
-                    "flavor" | "worker_threads" => {
+                    "flavor" | "worker_threads" | "start_paused" => {
                         format!("The `{}` attribute requires an argument.", name)
                     }
                     name => {
-                        format!("Unknown attribute {} is specified; expected one of: `flavor`, `worker_threads`", name)
+                        format!("Unknown attribute {} is specified; expected one of: `flavor`, `worker_threads`, `start_paused`", name)
                     }
                 };
                 return Err(syn::Error::new_spanned(path, msg));
@@ -235,6 +277,9 @@
     if let Some(v) = config.worker_threads {
         rt = quote! { #rt.worker_threads(#v) };
     }
+    if let Some(v) = config.start_paused {
+        rt = quote! { #rt.start_paused(#v) };
+    }
 
     let header = {
         if is_test {
@@ -254,7 +299,7 @@
                 .enable_all()
                 .build()
                 .unwrap()
-                .block_on(async { #body })
+                .block_on(async #body)
         }
     };
 
diff --git a/src/lib.rs b/src/lib.rs
index b07005f..5e41a5e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,4 @@
-#![doc(html_root_url = "https://docs.rs/tokio-macros/0.3.2")]
+#![doc(html_root_url = "https://docs.rs/tokio-macros/1.1.0")]
 #![allow(clippy::needless_doctest_main)]
 #![warn(
     missing_debug_implementations,
@@ -24,8 +24,8 @@
 
 use proc_macro::TokenStream;
 
-/// Marks async function to be executed by the selected runtime. This macro helps
-/// set up a `Runtime` without requiring the user to use
+/// Marks async function to be executed by the selected runtime. This macro
+/// helps set up a `Runtime` without requiring the user to use
 /// [Runtime](../tokio/runtime/struct.Runtime.html) or
 /// [Builder](../tokio/runtime/struct.Builder.html) directly.
 ///
@@ -36,10 +36,10 @@
 /// powerful interface.
 ///
 /// Note: This macro can be used on any function and not just the `main`
-/// function. Using it on a non-main function makes the function behave
-/// as if it was synchronous by starting a new runtime each time it is called.
-/// If the function is called often, it is preferable to create the runtime using
-/// the runtime builder so the runtime can be reused across calls.
+/// function. Using it on a non-main function makes the function behave as if it
+/// was synchronous by starting a new runtime each time it is called. If the
+/// function is called often, it is preferable to create the runtime using the
+/// runtime builder so the runtime can be reused across calls.
 ///
 /// # Multi-threaded runtime
 ///
@@ -53,6 +53,9 @@
 /// The `worker_threads` option configures the number of worker threads, and
 /// defaults to the number of cpus on the system. This is the default flavor.
 ///
+/// Note: The multi-threaded runtime requires the `rt-multi-thread` feature
+/// flag.
+///
 /// # Current thread runtime
 ///
 /// To use the single-threaded runtime known as the `current_thread` runtime,
@@ -141,12 +144,36 @@
 /// }
 /// ```
 ///
+/// ### Configure the runtime to start with time paused
+///
+/// ```rust
+/// #[tokio::main(flavor = "current_thread", start_paused = true)]
+/// async fn main() {
+///     println!("Hello world");
+/// }
+/// ```
+///
+/// Equivalent code not using `#[tokio::main]`
+///
+/// ```rust
+/// fn main() {
+///     tokio::runtime::Builder::new_current_thread()
+///         .enable_all()
+///         .start_paused(true)
+///         .build()
+///         .unwrap()
+///         .block_on(async {
+///             println!("Hello world");
+///         })
+/// }
+/// ```
+///
 /// ### NOTE:
 ///
-/// If you rename the tokio crate in your dependencies this macro will not work.
-/// If you must rename the 0.3 version of tokio because you're also using the
-/// 0.1 version of tokio, you _must_ make the tokio 0.3 crate available as
-/// `tokio` in the module where this macro is expanded.
+/// If you rename the Tokio crate in your dependencies this macro will not work.
+/// If you must rename the current version of Tokio because you're also using an
+/// older version of Tokio, you _must_ make the current version of Tokio
+/// available as `tokio` in the module where this macro is expanded.
 #[proc_macro_attribute]
 #[cfg(not(test))] // Work around for rust-lang/rust#62127
 pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
@@ -188,11 +215,10 @@
 ///
 /// ### NOTE:
 ///
-/// If you rename the tokio crate in your dependencies this macro
-/// will not work. If you must rename the 0.3 version of tokio because
-/// you're also using the 0.1 version of tokio, you _must_ make the
-/// tokio 0.3 crate available as `tokio` in the module where this
-/// macro is expanded.
+/// If you rename the Tokio crate in your dependencies this macro will not work.
+/// If you must rename the current version of Tokio because you're also using an
+/// older version of Tokio, you _must_ make the current version of Tokio
+/// available as `tokio` in the module where this macro is expanded.
 #[proc_macro_attribute]
 #[cfg(not(test))] // Work around for rust-lang/rust#62127
 pub fn main_rt(args: TokenStream, item: TokenStream) -> TokenStream {
@@ -223,13 +249,21 @@
 /// }
 /// ```
 ///
+/// ### Configure the runtime to start with time paused
+///
+/// ```no_run
+/// #[tokio::test(start_paused = true)]
+/// async fn my_test() {
+///     assert!(true);
+/// }
+/// ```
+///
 /// ### NOTE:
 ///
-/// If you rename the tokio crate in your dependencies this macro
-/// will not work. If you must rename the 0.3 version of tokio because
-/// you're also using the 0.1 version of tokio, you _must_ make the
-/// tokio 0.3 crate available as `tokio` in the module where this
-/// macro is expanded.
+/// If you rename the Tokio crate in your dependencies this macro will not work.
+/// If you must rename the current version of Tokio because you're also using an
+/// older version of Tokio, you _must_ make the current version of Tokio
+/// available as `tokio` in the module where this macro is expanded.
 #[proc_macro_attribute]
 pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
     entry::test(args, item, true)
@@ -248,11 +282,10 @@
 ///
 /// ### NOTE:
 ///
-/// If you rename the tokio crate in your dependencies this macro
-/// will not work. If you must rename the 0.3 version of tokio because
-/// you're also using the 0.1 version of tokio, you _must_ make the
-/// tokio 0.3 crate available as `tokio` in the module where this
-/// macro is expanded.
+/// If you rename the Tokio crate in your dependencies this macro will not work.
+/// If you must rename the current version of Tokio because you're also using an
+/// older version of Tokio, you _must_ make the current version of Tokio
+/// available as `tokio` in the module where this macro is expanded.
 #[proc_macro_attribute]
 pub fn test_rt(args: TokenStream, item: TokenStream) -> TokenStream {
     entry::test(args, item, false)