Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/tt_iter.rs')
-rw-r--r--crates/mbe/src/tt_iter.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs
index f9913cb6f9..e3d12d8707 100644
--- a/crates/mbe/src/tt_iter.rs
+++ b/crates/mbe/src/tt_iter.rs
@@ -1,9 +1,10 @@
//! A "Parser" structure for token trees. We use this when parsing a declarative
//! macro definition into a list of patterns and templates.
+use core::fmt;
+
use smallvec::{smallvec, SmallVec};
use syntax::SyntaxKind;
-use tt::Span;
use crate::{to_parser_input::to_parser_input, ExpandError, ExpandResult};
@@ -12,7 +13,7 @@ pub(crate) struct TtIter<'a, S> {
pub(crate) inner: std::slice::Iter<'a, tt::TokenTree<S>>,
}
-impl<'a, S: Span> TtIter<'a, S> {
+impl<'a, S: Copy> TtIter<'a, S> {
pub(crate) fn new(subtree: &'a tt::Subtree<S>) -> TtIter<'a, S> {
TtIter { inner: subtree.token_trees.iter() }
}
@@ -130,7 +131,12 @@ impl<'a, S: Span> TtIter<'a, S> {
_ => Ok(smallvec![first]),
}
}
+ pub(crate) fn peek_n(&self, n: usize) -> Option<&'a tt::TokenTree<S>> {
+ self.inner.as_slice().get(n)
+ }
+}
+impl<'a, S: Copy + fmt::Debug> TtIter<'a, S> {
pub(crate) fn expect_fragment(
&mut self,
entry_point: parser::PrefixEntryPoint,
@@ -185,10 +191,6 @@ impl<'a, S: Span> TtIter<'a, S> {
};
ExpandResult { value: res, err }
}
-
- pub(crate) fn peek_n(&self, n: usize) -> Option<&'a tt::TokenTree<S>> {
- self.inner.as_slice().get(n)
- }
}
impl<'a, S> Iterator for TtIter<'a, S> {