Upgrade rust/crates/proc-macro-hack to 0.5.16

Test: None
Change-Id: If211fb7376a0bee11173aac2e3681e0b785e1eb0
diff --git a/src/iter.rs b/src/iter.rs
new file mode 100644
index 0000000..722013c
--- /dev/null
+++ b/src/iter.rs
@@ -0,0 +1,42 @@
+use proc_macro::{token_stream, Delimiter, TokenStream, TokenTree};
+
+pub type Iter<'a> = &'a mut IterImpl;
+
+pub struct IterImpl {
+    stack: Vec<token_stream::IntoIter>,
+    peeked: Option<TokenTree>,
+}
+
+pub fn new(tokens: TokenStream) -> IterImpl {
+    IterImpl {
+        stack: vec![tokens.into_iter()],
+        peeked: None,
+    }
+}
+
+impl IterImpl {
+    pub fn peek(&mut self) -> Option<&TokenTree> {
+        self.peeked = self.next();
+        self.peeked.as_ref()
+    }
+}
+
+impl Iterator for IterImpl {
+    type Item = TokenTree;
+
+    fn next(&mut self) -> Option<Self::Item> {
+        if let Some(tt) = self.peeked.take() {
+            return Some(tt);
+        }
+        loop {
+            let top = self.stack.last_mut()?;
+            match top.next() {
+                None => drop(self.stack.pop()),
+                Some(TokenTree::Group(ref group)) if group.delimiter() == Delimiter::None => {
+                    self.stack.push(group.stream().into_iter());
+                }
+                Some(tt) => return Some(tt),
+            }
+        }
+    }
+}
diff --git a/src/lib.rs b/src/lib.rs
index 292ac74..16d7823 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,11 @@
+//! [![github]](https://github.com/dtolnay/proc-macro-hack)&ensp;[![crates-io]](https://crates.io/crates/proc-macro-hack)&ensp;[![docs-rs]](https://docs.rs/proc-macro-hack)
+//!
+//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
+//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
+//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
+//!
+//! <br>
+//!
 //! As of Rust 1.30, the language supports user-defined function-like procedural
 //! macros. However these can only be invoked in item position, not in
 //! statements or expressions.
@@ -14,7 +22,7 @@
 //! This crate must contain nothing but procedural macros. Private helper
 //! functions and private modules are fine but nothing can be public.
 //!
-//! [> example of an implementation crate][demo-hack-impl]
+//! [&raquo; example of an implementation crate][demo-hack-impl]
 //!
 //! Just like you would use a #\[proc_macro\] attribute to define a natively
 //! supported procedural macro, use proc-macro-hack's #\[proc_macro_hack\]
@@ -48,7 +56,7 @@
 //! This crate is allowed to contain other public things if you need, for
 //! example traits or functions or ordinary macros.
 //!
-//! [> example of a declaration crate][demo-hack]
+//! [&raquo; example of a declaration crate][demo-hack]
 //!
 //! Within the declaration crate there needs to be a re-export of your
 //! procedural macro from the implementation crate. The re-export also carries a
@@ -86,7 +94,7 @@
 //! Users of your crate depend on your declaration crate (not your
 //! implementation crate), then use your procedural macros as usual.
 //!
-//! [> example of a downstream crate][example]
+//! [&raquo; example of a downstream crate][example]
 //!
 //! ```
 //! use demo_hack::add_one;
@@ -131,15 +139,17 @@
 mod quote;
 
 mod error;
+mod iter;
 mod parse;
 
 use crate::error::{compile_error, Error};
-use crate::parse::*;
-use proc_macro::{token_stream, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
+use crate::iter::Iter;
+use crate::parse::{
+    parse_define_args, parse_enum_hack, parse_export_args, parse_fake_call_site, parse_input,
+};
+use proc_macro::{Ident, Punct, Spacing, Span, TokenStream, TokenTree};
 use std::fmt::Write;
-use std::iter::Peekable;
 
-type Iter<'a> = &'a mut Peekable<token_stream::IntoIter>;
 type Visibility = Option<Span>;
 
 enum Input {
@@ -169,8 +179,8 @@
 
 #[proc_macro_attribute]
 pub fn proc_macro_hack(args: TokenStream, input: TokenStream) -> TokenStream {
-    let ref mut args = args.into_iter().peekable();
-    let ref mut input = input.into_iter().peekable();
+    let ref mut args = iter::new(args);
+    let ref mut input = iter::new(input);
     expand_proc_macro_hack(args, input).unwrap_or_else(compile_error)
 }
 
@@ -190,7 +200,7 @@
 #[doc(hidden)]
 #[proc_macro_derive(ProcMacroHack)]
 pub fn enum_hack(input: TokenStream) -> TokenStream {
-    let ref mut input = input.into_iter().peekable();
+    let ref mut input = iter::new(input);
     parse_enum_hack(input).unwrap_or_else(compile_error)
 }
 
@@ -202,8 +212,8 @@
 #[doc(hidden)]
 #[proc_macro_attribute]
 pub fn fake_call_site(args: TokenStream, input: TokenStream) -> TokenStream {
-    let ref mut args = args.into_iter().peekable();
-    let ref mut input = input.into_iter().peekable();
+    let ref mut args = iter::new(args);
+    let ref mut input = iter::new(input);
     expand_fake_call_site(args, input).unwrap_or_else(compile_error)
 }
 
diff --git a/src/parse.rs b/src/parse.rs
index c6b1665..de7c599 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -1,7 +1,7 @@
-use crate::{Define, Error, Export, ExportArgs, FakeCallSite, Input, Iter, Macro, Visibility};
+use crate::iter::{self, Iter, IterImpl};
+use crate::{Define, Error, Export, ExportArgs, FakeCallSite, Input, Macro, Visibility};
 use proc_macro::Delimiter::{Brace, Bracket, Parenthesis};
-use proc_macro::{token_stream, Delimiter, Ident, Span, TokenStream, TokenTree};
-use std::iter::Peekable;
+use proc_macro::{Delimiter, Ident, Span, TokenStream, TokenTree};
 
 pub(crate) fn parse_input(tokens: Iter) -> Result<Input, Error> {
     let attrs = parse_attributes(tokens)?;
@@ -29,7 +29,7 @@
     let mut macros = Vec::new();
     match tokens.peek() {
         Some(TokenTree::Group(group)) if group.delimiter() == Brace => {
-            let ref mut content = group.stream().into_iter().peekable();
+            let ref mut content = iter::new(group.stream());
             loop {
                 macros.push(parse_macro(content)?);
                 if content.peek().is_none() {
@@ -124,13 +124,10 @@
     }
 }
 
-fn parse_group(
-    tokens: Iter,
-    delimiter: Delimiter,
-) -> Result<Peekable<token_stream::IntoIter>, Error> {
+fn parse_group(tokens: Iter, delimiter: Delimiter) -> Result<IterImpl, Error> {
     match &tokens.next() {
         Some(TokenTree::Group(group)) if group.delimiter() == delimiter => {
-            Ok(group.stream().into_iter().peekable())
+            Ok(iter::new(group.stream()))
         }
         tt => Err(Error::new(
             tt.as_ref().map_or_else(Span::call_site, TokenTree::span),