Upgrade rust/crates/async-stream-impl to 0.3.2

Test: make
Change-Id: Ia83927e98e9f300aa1919fe4f6b2b08b5df87813
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 4a76e44..620b2af 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "8c22349b9367b981ad08db573d8d906069e66d8c"
+    "sha1": "b28da881695e3c66e1782f0c2c330d4e162eb7c2"
   }
 }
diff --git a/Android.bp b/Android.bp
index 839ba5f..7058e6a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -33,7 +33,7 @@
 }
 
 // dependent_library ["feature_list"]
-//   proc-macro2-1.0.26 "default,proc-macro"
+//   proc-macro2-1.0.27 "default,proc-macro"
 //   quote-1.0.9 "default,proc-macro"
-//   syn-1.0.72 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote,visit-mut"
+//   syn-1.0.73 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote,visit-mut"
 //   unicode-xid-0.2.2 "default"
diff --git a/Cargo.toml b/Cargo.toml
index ca12ae9..44a0cb9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,11 +13,11 @@
 [package]
 edition = "2018"
 name = "async-stream-impl"
-version = "0.3.1"
+version = "0.3.2"
 authors = ["Carl Lerche <me@carllerche.com>"]
 description = "proc macros for async-stream crate"
 homepage = "https://github.com/tokio-rs/async-stream"
-documentation = "https://docs.rs/async-stream-impl/0.3"
+documentation = "https://docs.rs/async-stream-impl"
 license = "MIT"
 repository = "https://github.com/tokio-rs/async-stream"
 
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 6682921..4317fdf 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,11 +1,11 @@
 [package]
 name = "async-stream-impl"
-version = "0.3.1"
+version = "0.3.2"
 edition = "2018"
 license = "MIT"
 authors = ["Carl Lerche <me@carllerche.com>"]
 description = "proc macros for async-stream crate"
-documentation = "https://docs.rs/async-stream-impl/0.3"
+documentation = "https://docs.rs/async-stream-impl"
 homepage = "https://github.com/tokio-rs/async-stream"
 repository = "https://github.com/tokio-rs/async-stream"
 
diff --git a/METADATA b/METADATA
index adebd05..f08d3d2 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/async-stream-impl/async-stream-impl-0.3.1.crate"
+    value: "https://static.crates.io/crates/async-stream-impl/async-stream-impl-0.3.2.crate"
   }
-  version: "0.3.1"
+  version: "0.3.2"
   license_type: NOTICE
   last_upgrade_date {
     year: 2021
-    month: 5
-    day: 19
+    month: 6
+    day: 21
   }
 }
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 73ad094..a83b104 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -14,15 +14,33 @@
       "name": "tokio-test_device_test_tests_macros"
     },
     {
+      "name": "tokio_device_test_tests__require_full"
+    },
+    {
       "name": "tokio_device_test_tests_buffered"
     },
     {
+      "name": "tokio_device_test_tests_io_async_fd"
+    },
+    {
       "name": "tokio_device_test_tests_io_async_read"
     },
     {
+      "name": "tokio_device_test_tests_io_chain"
+    },
+    {
+      "name": "tokio_device_test_tests_io_copy"
+    },
+    {
       "name": "tokio_device_test_tests_io_copy_bidirectional"
     },
     {
+      "name": "tokio_device_test_tests_io_driver"
+    },
+    {
+      "name": "tokio_device_test_tests_io_driver_drop"
+    },
+    {
       "name": "tokio_device_test_tests_io_lines"
     },
     {
@@ -35,9 +53,24 @@
       "name": "tokio_device_test_tests_io_read_buf"
     },
     {
+      "name": "tokio_device_test_tests_io_read_exact"
+    },
+    {
+      "name": "tokio_device_test_tests_io_read_line"
+    },
+    {
       "name": "tokio_device_test_tests_io_read_to_end"
     },
     {
+      "name": "tokio_device_test_tests_io_read_to_string"
+    },
+    {
+      "name": "tokio_device_test_tests_io_read_until"
+    },
+    {
+      "name": "tokio_device_test_tests_io_split"
+    },
+    {
       "name": "tokio_device_test_tests_io_take"
     },
     {
@@ -56,12 +89,36 @@
       "name": "tokio_device_test_tests_macros_join"
     },
     {
+      "name": "tokio_device_test_tests_macros_pin"
+    },
+    {
+      "name": "tokio_device_test_tests_macros_select"
+    },
+    {
+      "name": "tokio_device_test_tests_macros_test"
+    },
+    {
+      "name": "tokio_device_test_tests_macros_try_join"
+    },
+    {
+      "name": "tokio_device_test_tests_net_bind_resource"
+    },
+    {
+      "name": "tokio_device_test_tests_net_lookup_host"
+    },
+    {
       "name": "tokio_device_test_tests_no_rt"
     },
     {
+      "name": "tokio_device_test_tests_process_kill_on_drop"
+    },
+    {
       "name": "tokio_device_test_tests_rt_basic"
     },
     {
+      "name": "tokio_device_test_tests_rt_common"
+    },
+    {
       "name": "tokio_device_test_tests_rt_threaded"
     },
     {
@@ -77,15 +134,36 @@
       "name": "tokio_device_test_tests_sync_mpsc"
     },
     {
+      "name": "tokio_device_test_tests_sync_mutex"
+    },
+    {
       "name": "tokio_device_test_tests_sync_mutex_owned"
     },
     {
+      "name": "tokio_device_test_tests_sync_notify"
+    },
+    {
+      "name": "tokio_device_test_tests_sync_oneshot"
+    },
+    {
       "name": "tokio_device_test_tests_sync_rwlock"
     },
     {
+      "name": "tokio_device_test_tests_sync_semaphore"
+    },
+    {
+      "name": "tokio_device_test_tests_sync_semaphore_owned"
+    },
+    {
       "name": "tokio_device_test_tests_sync_watch"
     },
     {
+      "name": "tokio_device_test_tests_task_abort"
+    },
+    {
+      "name": "tokio_device_test_tests_task_blocking"
+    },
+    {
       "name": "tokio_device_test_tests_task_local"
     },
     {
@@ -95,18 +173,39 @@
       "name": "tokio_device_test_tests_tcp_accept"
     },
     {
+      "name": "tokio_device_test_tests_tcp_connect"
+    },
+    {
       "name": "tokio_device_test_tests_tcp_echo"
     },
     {
+      "name": "tokio_device_test_tests_tcp_into_split"
+    },
+    {
       "name": "tokio_device_test_tests_tcp_into_std"
     },
     {
+      "name": "tokio_device_test_tests_tcp_peek"
+    },
+    {
       "name": "tokio_device_test_tests_tcp_shutdown"
     },
     {
+      "name": "tokio_device_test_tests_tcp_socket"
+    },
+    {
+      "name": "tokio_device_test_tests_tcp_split"
+    },
+    {
       "name": "tokio_device_test_tests_time_rt"
     },
     {
+      "name": "tokio_device_test_tests_udp"
+    },
+    {
+      "name": "tokio_device_test_tests_uds_cred"
+    },
+    {
       "name": "tokio_device_test_tests_uds_split"
     }
   ]
diff --git a/src/lib.rs b/src/lib.rs
index bcd7b3f..81d3752 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,7 +2,7 @@
 use proc_macro::TokenStream;
 use proc_macro2::{Group, TokenStream as TokenStream2, TokenTree};
 use quote::quote;
-use syn::parse::Parser;
+use syn::parse::{Parse, ParseStream, Parser, Result};
 use syn::visit_mut::VisitMut;
 
 struct Scrub<'a> {
@@ -35,6 +35,80 @@
     }
 }
 
+struct Partial<T>(T, TokenStream2);
+
+impl<T: Parse> Parse for Partial<T> {
+    fn parse(input: ParseStream) -> Result<Self> {
+        Ok(Partial(input.parse()?, input.parse()?))
+    }
+}
+
+fn visit_token_stream_impl(
+    visitor: &mut Scrub<'_>,
+    tokens: TokenStream2,
+    modified: &mut bool,
+    out: &mut TokenStream2,
+) {
+    use quote::ToTokens;
+    use quote::TokenStreamExt;
+
+    let mut tokens = tokens.into_iter().peekable();
+    while let Some(tt) = tokens.next() {
+        match tt {
+            TokenTree::Ident(i) if i == "yield" => {
+                let stream = std::iter::once(TokenTree::Ident(i)).chain(tokens).collect();
+                match syn::parse2(stream) {
+                    Ok(Partial(yield_expr, rest)) => {
+                        let mut expr = syn::Expr::Yield(yield_expr);
+                        visitor.visit_expr_mut(&mut expr);
+                        expr.to_tokens(out);
+                        *modified = true;
+                        tokens = rest.into_iter().peekable();
+                    }
+                    Err(e) => {
+                        out.append_all(&mut e.to_compile_error().into_iter());
+                        *modified = true;
+                        return;
+                    }
+                }
+            }
+            TokenTree::Ident(i) if i == "stream" || i == "try_stream" => {
+                out.append(TokenTree::Ident(i));
+                match tokens.peek() {
+                    Some(TokenTree::Punct(p)) if p.as_char() == '!' => {
+                        out.extend(tokens.next()); // !
+                        if let Some(TokenTree::Group(_)) = tokens.peek() {
+                            out.extend(tokens.next()); // { .. } or [ .. ] or ( .. )
+                        }
+                    }
+                    _ => {}
+                }
+            }
+            TokenTree::Group(group) => {
+                let mut content = group.stream();
+                *modified |= visitor.visit_token_stream(&mut content);
+                let mut new = Group::new(group.delimiter(), content);
+                new.set_span(group.span());
+                out.append(new);
+            }
+            other => out.append(other),
+        }
+    }
+}
+
+impl Scrub<'_> {
+    fn visit_token_stream(&mut self, tokens: &mut TokenStream2) -> bool {
+        let (mut out, mut modified) = (TokenStream2::new(), false);
+        visit_token_stream_impl(self, tokens.clone(), &mut modified, &mut out);
+
+        if modified {
+            *tokens = out;
+        }
+
+        modified
+    }
+}
+
 impl VisitMut for Scrub<'_> {
     fn visit_expr_mut(&mut self, i: &mut syn::Expr) {
         match i {
@@ -110,8 +184,20 @@
         }
     }
 
-    fn visit_item_mut(&mut self, _: &mut syn::Item) {
-        // Don't transform inner items.
+    fn visit_macro_mut(&mut self, mac: &mut syn::Macro) {
+        let mac_ident = mac.path.segments.last().map(|p| &p.ident);
+        if mac_ident.map_or(false, |i| i == "stream" || i == "try_stream") {
+            return;
+        }
+
+        self.visit_token_stream(&mut mac.tokens);
+    }
+
+    fn visit_item_mut(&mut self, i: &mut syn::Item) {
+        // Recurse into macros but otherwise don't transform inner items.
+        if let syn::Item::Macro(i) = i {
+            self.visit_macro_mut(&mut i.mac);
+        }
     }
 }